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
Jonatas
2020-12-29 15:05:13 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a7083f07088c5fc6ccccd8ce968562e911f85fe2
a7083f07
1 parent
e6ae658c
use constraints rather map on parser
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
43 deletions
lib/get_navigation/src/root/parse_route.dart
lib/get_navigation/src/routes/default_route.dart
lib/get_navigation/src/routes/get_route.dart
lib/get_state_manager/src/simple/get_state.dart
lib/get_navigation/src/root/parse_route.dart
View file @
a7083f0
...
...
@@ -48,10 +48,13 @@ class ParseRouteTree {
final
pageMiddlewares
=
page
.
middlewares
??
<
GetMiddleware
>[];
pageMiddlewares
.
addAll
(
route
.
middlewares
??
<
GetMiddleware
>[]);
result
.
add
(
_addChild
(
page
,
parentPath
,
pageMiddlewares
));
page
.
bindings
.
addAll
(
route
.
bindings
);
final
children
=
_flattenPage
(
page
);
for
(
var
child
in
children
)
{
pageMiddlewares
.
addAll
(
child
.
middlewares
??
<
GetMiddleware
>[]);
result
.
add
(
_addChild
(
child
,
parentPath
,
pageMiddlewares
));
page
.
bindings
.
addAll
(
route
.
bindings
);
}
}
return
result
;
...
...
@@ -85,7 +88,7 @@ class ParseRouteTree {
(
route
)
{
return
_match
(
name
,
route
.
path
[
'regex'
]
as
RegExp
,
route
.
path
.
regex
,
);
},
orElse:
()
=>
null
,
...
...
@@ -94,18 +97,13 @@ class ParseRouteTree {
return
route
;
}
Map
<
String
,
String
>
_parseParams
(
String
path
,
Map
<
String
,
dynamic
>
routePath
)
{
Map
<
String
,
String
>
_parseParams
(
String
path
,
PathDecoded
routePath
)
{
final
params
=
<
String
,
String
>{};
Match
paramsMatch
=
(
routePath
[
'regex'
]
as
RegExp
).
firstMatch
(
path
);
for
(
var
i
=
0
;
i
<
(
routePath
[
'keys'
].
length
as
int
);
i
++)
{
String
param
;
try
{
param
=
Uri
.
decodeQueryComponent
(
paramsMatch
[
i
+
1
]);
}
on
Exception
catch
(
_
)
{
param
=
paramsMatch
[
i
+
1
];
}
params
[
routePath
[
'keys'
][
i
]
as
String
]
=
param
;
Match
paramsMatch
=
routePath
.
regex
.
firstMatch
(
path
);
for
(
var
i
=
0
;
i
<
routePath
.
keys
.
length
;
i
++)
{
var
param
=
Uri
.
decodeQueryComponent
(
paramsMatch
[
i
+
1
]);
params
[
routePath
.
keys
[
i
]]
=
param
;
}
return
params
;
}
...
...
lib/get_navigation/src/routes/default_route.dart
View file @
a7083f0
...
...
@@ -11,8 +11,8 @@ import 'default_transitions.dart';
import
'transitions_type.dart'
;
class
GetPageRoute
<
T
>
extends
PageRoute
<
T
>
{
GetPageRoute
(
{
RouteSettings
settings
,
GetPageRoute
({
RouteSettings
settings
,
this
.
transitionDuration
=
const
Duration
(
milliseconds:
300
),
this
.
opaque
=
true
,
this
.
parameter
,
...
...
@@ -30,8 +30,8 @@ class GetPageRoute<T> extends PageRoute<T> {
this
.
barrierLabel
,
this
.
maintainState
=
true
,
bool
fullscreenDialog
=
false
,
this
.
middlewares
})
:
assert
(
opaque
!=
null
),
this
.
middlewares
,
})
:
assert
(
opaque
!=
null
),
assert
(
barrierDismissible
!=
null
),
assert
(
maintainState
!=
null
),
assert
(
fullscreenDialog
!=
null
),
...
...
lib/get_navigation/src/routes/get_route.dart
View file @
a7083f0
...
...
@@ -5,6 +5,12 @@ import '../../get_navigation.dart';
import
'custom_transition.dart'
;
import
'transitions_type.dart'
;
class
PathDecoded
{
const
PathDecoded
(
this
.
regex
,
this
.
keys
);
final
RegExp
regex
;
final
List
<
String
>
keys
;
}
class
GetPage
{
final
String
name
;
final
GetPageBuilder
page
;
...
...
@@ -24,8 +30,8 @@ class GetPage {
final
RouteSettings
settings
;
final
List
<
GetPage
>
children
;
final
List
<
GetMiddleware
>
middlewares
;
final
Map
<
String
,
dynamic
>
path
;
final
List
<
String
>
keys
;
final
PathDecoded
path
;
GetPage
({
@required
this
.
name
,
@required
this
.
page
,
...
...
@@ -39,43 +45,37 @@ class GetPage {
this
.
transitionDuration
,
this
.
popGesture
,
this
.
binding
,
this
.
bindings
,
this
.
bindings
=
const
[]
,
this
.
transition
,
this
.
customTransition
,
this
.
fullscreenDialog
=
false
,
this
.
children
,
this
.
keys
,
this
.
middlewares
,
})
:
path
=
normalize
(
name
,
keysList:
keys
),
})
:
path
=
_nameToRegex
(
name
),
assert
(
page
!=
null
),
assert
(
name
!=
null
),
assert
(
maintainState
!=
null
),
assert
(
fullscreenDialog
!=
null
);
static
Map
<
String
,
dynamic
>
normalize
(
String
path
,
{
List
<
String
>
keysList
,
})
{
var
keys
=
List
<
String
>.
from
(
keysList
??
const
<
String
>[]);
var
stringPath
=
'
$path
/?'
.
replaceAllMapped
(
RegExp
(
r'(\.)?:(\w+)(\?)?'
),
(
placeholder
)
{
var
replace
=
StringBuffer
(
'(?:'
);
static
PathDecoded
_nameToRegex
(
String
path
)
{
var
keys
=
<
String
>[];
if
(
placeholder
[
1
]
!=
null
)
{
replace
.
write
(
'
\
.'
);
}
String
_replace
(
Match
pattern
)
{
var
buffer
=
StringBuffer
(
'(?:'
);
replace
.
write
(
'([
\\
w%+-._~!
\$
&
\'
()*,;=:@]+))'
);
if
(
pattern
[
1
]
!=
null
)
buffer
.
write
(
'
\
.'
);
buffer
.
write
(
'([
\\
w%+-._~!
\$
&
\'
()*,;=:@]+))'
);
if
(
pattern
[
3
]
!=
null
)
buffer
.
write
(
'?'
);
if
(
placeholder
[
3
]
!=
null
)
{
replace
.
write
(
'?'
);
keys
.
add
(
pattern
[
2
]);
return
"
$buffer
"
;
}
keys
.
add
(
placeholder
[
2
]);
return
replace
.
toString
();
}).
replaceAll
(
'//'
,
'/'
);
var
stringPath
=
'
$path
/?'
.
replaceAllMapped
(
RegExp
(
r'(\.)?:(\w+)(\?)?'
),
_replace
)
.
replaceAll
(
'//'
,
'/'
);
return
{
'regex'
:
RegExp
(
'^
$stringPath
\$
'
),
'keys'
:
keys
}
;
return
PathDecoded
(
RegExp
(
'^
$stringPath
\$
'
),
keys
)
;
}
GetPage
copyWith
({
...
...
@@ -95,7 +95,6 @@ class GetPage {
Duration
transitionDuration
,
bool
fullscreenDialog
,
RouteSettings
settings
,
List
<
String
>
keys
,
List
<
GetPage
>
children
,
List
<
GetMiddleware
>
middlewares
,
})
{
...
...
@@ -116,7 +115,6 @@ class GetPage {
transitionDuration:
transitionDuration
??
this
.
transitionDuration
,
fullscreenDialog:
fullscreenDialog
??
this
.
fullscreenDialog
,
settings:
settings
??
this
.
settings
,
keys:
keys
??
this
.
keys
,
children:
children
??
this
.
children
,
middlewares:
middlewares
??
this
.
middlewares
,
);
...
...
lib/get_state_manager/src/simple/get_state.dart
View file @
a7083f0
...
...
@@ -102,8 +102,6 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>>
VoidCallback
remove
;
Object
_selector
;
List
<
VoidCallback
>
_removeToOthers
=
<
VoidCallback
>[];
@override
void
initState
()
{
super
.
initState
();
...
...
Please
register
or
login
to post a comment