Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jonny Borges
2021-06-04 15:50:26 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6165e8b6961a4f6fdb6df32cf73ab7a060d907eb
6165e8b6
1 parent
d21bd69c
add transitions to nav 2 and GetNavigator
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
66 deletions
example_nav2/lib/app/modules/home/views/home_view.dart
example_nav2/lib/app/modules/root/views/root_view.dart
example_nav2/lib/app/routes/app_pages.dart
lib/get_navigation/src/nav2/get_router_delegate.dart
lib/get_navigation/src/nav2/router_outlet.dart
lib/get_navigation/src/routes/get_route.dart
example_nav2/lib/app/modules/home/views/home_view.dart
View file @
6165e8b
...
...
@@ -21,6 +21,7 @@ class HomeView extends GetView<HomeController> {
}
return
Scaffold
(
body:
GetRouterOutlet
(
name:
Routes
.
HOME
,
emptyPage:
(
delegate
)
=>
DashboardView
(),
pickPages:
(
currentNavStack
)
{
print
(
'Home RouterOutlet:
$currentNavStack
'
);
...
...
example_nav2/lib/app/modules/root/views/root_view.dart
View file @
6165e8b
...
...
@@ -19,6 +19,7 @@ class RootView extends GetView<RootController> {
centerTitle:
true
,
),
body:
GetRouterOutlet
(
name:
'/'
,
emptyPage:
(
delegate
)
{
return
Center
(
child:
Column
(
...
...
example_nav2/lib/app/routes/app_pages.dart
View file @
6165e8b
...
...
@@ -42,12 +42,14 @@ class AppPages {
name:
_Paths
.
PROFILE
,
page:
()
=>
ProfileView
(),
title:
'Profile'
,
transition:
Transition
.
size
,
binding:
ProfileBinding
(),
),
GetPage
(
name:
_Paths
.
PRODUCTS
,
page:
()
=>
ProductsView
(),
title:
'Products'
,
transition:
Transition
.
zoom
,
binding:
ProductsBinding
(),
children:
[
GetPage
(
...
...
lib/get_navigation/src/nav2/get_router_delegate.dart
View file @
6165e8b
...
...
@@ -2,7 +2,6 @@ import 'dart:async';
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get_navigation/src/nav2/router_outlet.dart'
;
import
'../../../get.dart'
;
import
'../../../get_state_manager/src/simple/list_notifier.dart'
;
...
...
@@ -343,3 +342,37 @@ class GetDelegate extends RouterDelegate<GetNavConfig>
return
true
;
}
}
class
GetNavigator
extends
StatelessWidget
{
const
GetNavigator
({
Key
?
key
,
this
.
navigatorKey
,
required
this
.
onPopPage
,
required
this
.
pages
,
this
.
observers
,
this
.
transitionDelegate
,
required
this
.
name
,
})
:
super
(
key:
key
);
final
GlobalKey
<
NavigatorState
>?
navigatorKey
;
final
bool
Function
(
Route
<
dynamic
>,
dynamic
)
onPopPage
;
final
List
<
Page
>
pages
;
final
List
<
NavigatorObserver
>?
observers
;
final
TransitionDelegate
?
transitionDelegate
;
final
String
name
;
@override
Widget
build
(
BuildContext
context
)
{
Get
.
key
;
return
Navigator
(
key:
navigatorKey
??
Get
.
nestedKey
(
name
),
onPopPage:
onPopPage
,
pages:
pages
,
observers:
[
GetObserver
(),
if
(
observers
!=
null
)
...
observers
!,
],
transitionDelegate:
transitionDelegate
??
const
DefaultTransitionDelegate
<
dynamic
>(),
);
}
}
...
...
lib/get_navigation/src/nav2/router_outlet.dart
View file @
6165e8b
...
...
@@ -20,18 +20,17 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object>
RouterOutlet
({
TDelegate
?
delegate
,
required
List
<
RouteSettings
>
Function
(
T
currentNavStack
)
pickPages
,
required
List
<
GetPage
>
Function
(
T
currentNavStack
)
pickPages
,
required
Widget
Function
(
BuildContext
context
,
TDelegate
,
RouteSettings
?
page
,
GetPage
?
page
,
)
pageBuilder
,
})
:
this
.
builder
(
builder:
(
context
,
rDelegate
,
currentConfig
)
{
final
picked
=
currentConfig
==
null
?
<
RouteSettings
>[]
:
pickPages
(
currentConfig
);
final
picked
=
currentConfig
==
null
?
<
GetPage
>[]
:
pickPages
(
currentConfig
);
if
(
picked
.
length
==
0
)
{
return
pageBuilder
(
context
,
rDelegate
,
null
);
}
...
...
@@ -92,15 +91,20 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetNavConfig> {
GetRouterOutlet
({
Widget
Function
(
GetDelegate
delegate
)?
emptyPage
,
required
List
<
GetPage
>
Function
(
GetNavConfig
currentNavStack
)
pickPages
,
bool
Function
(
Route
<
dynamic
>,
dynamic
)?
onPopPage
,
required
String
name
,
})
:
super
(
pageBuilder:
(
context
,
rDelegate
,
page
)
{
final
pageRoute
=
rDelegate
.
getPageRoute
(
page
);
if
(
page
!=
null
)
{
//TODO: transitions go here !
return
pageRoute
.
buildPage
(
context
,
pageRoute
.
animation
,
pageRoute
.
secondaryAnimation
,
return
GetNavigator
(
onPopPage:
onPopPage
??
(
a
,
c
)
{
return
true
;
},
pages:
[
page
],
name:
name
,
);
}
...
...
lib/get_navigation/src/routes/get_route.dart
View file @
6165e8b
...
...
@@ -161,59 +161,4 @@ class GetPage<T> extends Page<T> {
unknownRoute
,
).
page
<
T
>();
}
@override
bool
operator
==(
Object
other
)
{
if
(
identical
(
this
,
other
))
return
true
;
if
(
other
is
GetPage
<
T
>)
{
print
(
other
.
path
.
hashCode
==
path
.
hashCode
);
}
return
other
is
GetPage
<
T
>
&&
other
.
page
.
runtimeType
==
page
.
runtimeType
&&
other
.
popGesture
==
popGesture
&&
// mapEquals(other.parameter, parameter) &&
other
.
preventDuplicates
==
preventDuplicates
&&
other
.
title
==
title
&&
other
.
transition
==
transition
&&
other
.
curve
==
curve
&&
other
.
alignment
==
alignment
&&
other
.
maintainState
==
maintainState
&&
other
.
opaque
==
opaque
&&
other
.
binding
==
binding
&&
// listEquals(other.bindings, bindings) &&
other
.
customTransition
==
customTransition
&&
other
.
transitionDuration
==
transitionDuration
&&
other
.
fullscreenDialog
==
fullscreenDialog
&&
other
.
name
==
name
&&
// listEquals(other.children, children) &&
// listEquals(other.middlewares, middlewares) &&
other
.
path
==
path
&&
other
.
unknownRoute
==
unknownRoute
;
}
@override
int
get
hashCode
{
return
//page.hashCode ^
popGesture
.
hashCode
^
// parameter.hashCode ^
preventDuplicates
.
hashCode
^
title
.
hashCode
^
transition
.
hashCode
^
curve
.
hashCode
^
alignment
.
hashCode
^
maintainState
.
hashCode
^
opaque
.
hashCode
^
binding
.
hashCode
^
// bindings.hashCode ^
customTransition
.
hashCode
^
transitionDuration
.
hashCode
^
fullscreenDialog
.
hashCode
^
name
.
hashCode
^
// children.hashCode ^
// middlewares.hashCode ^
path
.
hashCode
^
unknownRoute
.
hashCode
;
}
}
...
...
Please
register
or
login
to post a comment