Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
flutter_boost_1.22.4
Commits
b55554f0
Commit
b55554f0
authored
Mar 06, 2021
by
xgz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改flutter动画
parent
5822c69d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
31 deletions
+55
-31
lib/flutter_boost.dart
lib/flutter_boost.dart
+55
-31
No files found.
lib/flutter_boost.dart
View file @
b55554f0
...
...
@@ -42,19 +42,18 @@ export 'container/container_coordinator.dart' show BoostRouteSettings;
typedef
Widget
PageBuilder
(
String
pageName
,
Map
params
,
String
uniqueId
);
typedef
Route
PrePushRoute
(
String
url
,
String
uniqueId
,
Map
params
,
Route
route
);
typedef
Route
PrePushRoute
(
String
url
,
String
uniqueId
,
Map
params
,
Route
route
);
typedef
void
PostPushRoute
(
String
url
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
result
);
typedef
void
PostPushRoute
(
String
url
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
result
);
typedef
Route
FlutterBoostRouteBuilder
(
Widget
widget
);
class
FlutterBoost
{
static
final
FlutterBoost
_instance
=
FlutterBoost
();
final
GlobalKey
<
ContainerManagerState
>
containerManagerKey
=
GlobalKey
<
ContainerManagerState
>();
GlobalKey
<
ContainerManagerState
>();
final
ObserversHolder
_observersHolder
=
ObserversHolder
();
final
BoostChannel
_boostChannel
=
BoostChannel
();
...
...
@@ -84,14 +83,15 @@ class FlutterBoost {
});
}
static
TransitionBuilder
init
({
TransitionBuilder
builder
,
PrePushRoute
prePush
,
PostPushRoute
postPush
})
{
static
TransitionBuilder
init
(
{
TransitionBuilder
builder
,
PrePushRoute
prePush
,
PostPushRoute
postPush
})
{
if
(
Platform
.
isAndroid
)
{
onPageStart
();
}
else
if
(
Platform
.
isIOS
)
{
assert
(()
{
()
async
{
()
async
{
onPageStart
();
}();
return
true
;
...
...
@@ -139,8 +139,7 @@ class FlutterBoost {
}
Future
<
Map
<
dynamic
,
dynamic
>>
open
(
String
url
,
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
})
{
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
})
{
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
properties
[
"url"
]
=
url
;
properties
[
"urlParams"
]
=
urlParams
;
...
...
@@ -148,7 +147,6 @@ class FlutterBoost {
return
channel
.
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
'openPage'
,
properties
);
}
/**
*
* when flutter page->flutter page,do not open the new Activity Container
...
...
@@ -156,8 +154,8 @@ class FlutterBoost {
**/
Future
<
Map
<
dynamic
,
dynamic
>>
openInCurrentContainer
(
String
url
,
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
,
FlutterBoostRouteBuilder
routeBuilder
})
{
Map
<
String
,
dynamic
>
exts
,
FlutterBoostRouteBuilder
routeBuilder
})
{
final
BoostRouteSettings
routeSettings
=
ContainerCoordinator
.
singleton
.
createRouteSettings
(
url
,
urlParams:
urlParams
,
exts:
exts
);
...
...
@@ -168,9 +166,12 @@ class FlutterBoost {
return
open
(
url
,
urlParams:
urlParams
,
exts:
exts
);
}
final
Route
<
Map
<
dynamic
,
dynamic
>>
route
=
routeBuilder
!=
null
Route
<
Map
<
dynamic
,
dynamic
>>
route
=
routeBuilder
!=
null
?
routeBuilder
(
page
)
:
defaultRoute
(
page
,
routeSettings
);
if
(
exts
!=
null
&&
exts
.
containsKey
(
'present'
))
{
route
=
presentStyleRoute
(
page
,
routeSettings
);
}
GlobalRouteSettingsManager
.
instance
.
addSettings
(
route
,
routeSettings
);
...
...
@@ -178,26 +179,23 @@ class FlutterBoost {
return
FlutterBoost
.
containerManager
?.
onstageContainer
?.
push
(
route
);
}
Route
<
Map
<
dynamic
,
dynamic
>>
defaultRoute
(
Widget
page
,
BoostRouteSettings
settings
)
{
RouteSettings
routeSettings
=
new
RouteSettings
(
name:
settings
.
name
,
arguments:
settings
.
params
);
Route
<
Map
<
dynamic
,
dynamic
>>
defaultRoute
(
Widget
page
,
BoostRouteSettings
settings
)
{
RouteSettings
routeSettings
=
new
RouteSettings
(
name:
settings
.
name
,
arguments:
settings
.
params
);
if
(
Platform
.
isIOS
)
{
return
CupertinoPageRoute
<
Map
<
dynamic
,
dynamic
>>(
settings:
routeSettings
,
builder:
(
BuildContext
context
)
=>
page
);
settings:
routeSettings
,
builder:
(
BuildContext
context
)
=>
page
);
}
return
PageRouteBuilder
(
transitionDuration:
Duration
(
milliseconds:
300
),
settings:
routeSettings
,
pageBuilder:
(
context
,
animation
,
secondaryAnimation
)
=>
page
,
transitionsBuilder:
(
context
,
animation
,
secondaryAnimation
,
child
)
{
var
offsetAnimation
=
Tween
<
Offset
>(
begin:
Offset
(
1.0
,
0.0
),
end:
Offset
(
0.0
,
0.0
))
.
animate
(
CurvedAnimation
(
parent:
animation
,
curve:
Curves
.
fastOutSlowIn
));
var
offsetAnimation
=
Tween
<
Offset
>(
begin:
Offset
(
1.0
,
0.0
),
end:
Offset
(
0.0
,
0.0
))
.
animate
(
CurvedAnimation
(
parent:
animation
,
curve:
Curves
.
fastOutSlowIn
));
return
SlideTransition
(
position:
offsetAnimation
,
child:
child
,
...
...
@@ -205,6 +203,31 @@ class FlutterBoost {
});
}
//从下往上的跳转动画
Route
<
Map
<
dynamic
,
dynamic
>>
presentStyleRoute
(
Widget
page
,
BoostRouteSettings
settings
)
{
RouteSettings
routeSettings
=
new
RouteSettings
(
name:
settings
.
name
,
arguments:
settings
.
params
);
// if (Platform.isIOS) {
// return CupertinoPageRoute<Map<dynamic, dynamic>>(
// settings: routeSettings, builder: (BuildContext context) => page,
// );
// }
return
PageRouteBuilder
(
transitionDuration:
Duration
(
milliseconds:
300
),
settings:
routeSettings
,
pageBuilder:
(
context
,
animation
,
secondaryAnimation
)
=>
page
,
transitionsBuilder:
(
context
,
animation
,
secondaryAnimation
,
child
)
{
return
SlideTransition
(
position:
Tween
<
Offset
>(
begin:
Offset
(
0.0
,
1.0
),
end:
Offset
(
0.0
,
0.0
))
.
animate
(
CurvedAnimation
(
parent:
animation
,
curve:
Curves
.
fastOutSlowIn
)),
child:
child
,
);
});
}
/**
* close flutter page but not close container if there has more than one page in contaienr
*/
...
...
@@ -284,7 +307,7 @@ class FlutterBoost {
///register for Container lifecycle callbacks
VoidCallback
addBoostContainerLifeCycleObserver
(
BoostContainerLifeCycleObserver
observer
)
=>
BoostContainerLifeCycleObserver
observer
)
=>
_observersHolder
.
addObserver
<
BoostContainerLifeCycleObserver
>(
observer
);
///unregister for Container changed callbacks
...
...
@@ -293,8 +316,9 @@ class FlutterBoost {
///unregister for Container lifecycle callbacks
void
removeBoostContainerLifeCycleObserver
(
BoostContainerLifeCycleObserver
observer
)
=>
_observersHolder
.
removeObserver
<
BoostContainerLifeCycleObserver
>(
observer
);
BoostContainerLifeCycleObserver
observer
)
=>
_observersHolder
.
removeObserver
<
BoostContainerLifeCycleObserver
>(
observer
);
///register callbacks for Navigators push & pop
void
addBoostNavigatorObserver
(
NavigatorObserver
observer
)
=>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment