Commit 5d638134 authored by 李增强's avatar 李增强

Merge branch 'v1.22.4-hotfixes' of...

Merge branch 'v1.22.4-hotfixes' of git.xiaomanxiong.com:lizengqiang/flutter_boost_1.22.4 into v1.22.4-hotfixes
parents 11f17985 b55554f0
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
FlutterBoostPlugin* instance = [self.class sharedInstance]; FlutterBoostPlugin* instance = [self.class sharedInstance];
instance.methodChannel = channel; instance.methodChannel = channel;
[registrar addMethodCallDelegate:instance channel:channel]; [registrar addMethodCallDelegate:instance channel:channel];
[registrar addApplicationDelegate:instance];
} }
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
...@@ -215,4 +216,9 @@ ...@@ -215,4 +216,9 @@
self.methodChannel = nil; self.methodChannel = nil;
self.application = nil; self.application = nil;
} }
#pragma mark appDelegate
- (void)applicationDidBecomeActive:(UIApplication *)application{
[self sendEvent:@"applicationDidBecomeActive" arguments:@{@"status":@"applicationDidBecomeActive"}];
}
@end @end
...@@ -42,15 +42,14 @@ export 'container/container_coordinator.dart' show BoostRouteSettings; ...@@ -42,15 +42,14 @@ export 'container/container_coordinator.dart' show BoostRouteSettings;
typedef Widget PageBuilder(String pageName, Map params, String uniqueId); typedef Widget PageBuilder(String pageName, Map params, String uniqueId);
typedef Route PrePushRoute(String url, String uniqueId, Map params, typedef Route PrePushRoute(
Route route); String url, String uniqueId, Map params, Route route);
typedef void PostPushRoute(String url, String uniqueId, Map params, Route route, typedef void PostPushRoute(
Future result); String url, String uniqueId, Map params, Route route, Future result);
typedef Route FlutterBoostRouteBuilder(Widget widget); typedef Route FlutterBoostRouteBuilder(Widget widget);
class FlutterBoost { class FlutterBoost {
static final FlutterBoost _instance = FlutterBoost(); static final FlutterBoost _instance = FlutterBoost();
final GlobalKey<ContainerManagerState> containerManagerKey = final GlobalKey<ContainerManagerState> containerManagerKey =
...@@ -84,7 +83,8 @@ class FlutterBoost { ...@@ -84,7 +83,8 @@ class FlutterBoost {
}); });
} }
static TransitionBuilder init({TransitionBuilder builder, static TransitionBuilder init(
{TransitionBuilder builder,
PrePushRoute prePush, PrePushRoute prePush,
PostPushRoute postPush}) { PostPushRoute postPush}) {
if (Platform.isAndroid) { if (Platform.isAndroid) {
...@@ -139,8 +139,7 @@ class FlutterBoost { ...@@ -139,8 +139,7 @@ class FlutterBoost {
} }
Future<Map<dynamic, dynamic>> open(String url, Future<Map<dynamic, dynamic>> open(String url,
{Map<String, dynamic> urlParams, {Map<String, dynamic> urlParams, Map<String, dynamic> exts}) {
Map<String, dynamic> exts}) {
Map<String, dynamic> properties = new Map<String, dynamic>(); Map<String, dynamic> properties = new Map<String, dynamic>();
properties["url"] = url; properties["url"] = url;
properties["urlParams"] = urlParams; properties["urlParams"] = urlParams;
...@@ -148,7 +147,6 @@ class FlutterBoost { ...@@ -148,7 +147,6 @@ class FlutterBoost {
return channel.invokeMethod<Map<dynamic, dynamic>>('openPage', properties); return channel.invokeMethod<Map<dynamic, dynamic>>('openPage', properties);
} }
/** /**
* *
* when flutter page->flutter page,do not open the new Activity Container * when flutter page->flutter page,do not open the new Activity Container
...@@ -168,9 +166,12 @@ class FlutterBoost { ...@@ -168,9 +166,12 @@ class FlutterBoost {
return open(url, urlParams: urlParams, exts: exts); return open(url, urlParams: urlParams, exts: exts);
} }
final Route<Map<dynamic, dynamic>> route = routeBuilder != null Route<Map<dynamic, dynamic>> route = routeBuilder != null
? routeBuilder(page) ? routeBuilder(page)
: defaultRoute(page, routeSettings); : defaultRoute(page, routeSettings);
if (exts != null && exts.containsKey('present')) {
route = presentStyleRoute(page, routeSettings);
}
GlobalRouteSettingsManager.instance.addSettings(route, routeSettings); GlobalRouteSettingsManager.instance.addSettings(route, routeSettings);
...@@ -178,28 +179,50 @@ class FlutterBoost { ...@@ -178,28 +179,50 @@ class FlutterBoost {
return FlutterBoost.containerManager?.onstageContainer?.push(route); return FlutterBoost.containerManager?.onstageContainer?.push(route);
} }
Route<Map<dynamic, dynamic>> defaultRoute(
Route<Map<dynamic, dynamic>> defaultRoute(Widget page, Widget page, BoostRouteSettings settings) {
BoostRouteSettings settings) { RouteSettings routeSettings =
RouteSettings routeSettings = new RouteSettings( new RouteSettings(name: settings.name, arguments: settings.params);
name: settings.name, arguments: settings.params);
if (Platform.isIOS) { if (Platform.isIOS) {
return CupertinoPageRoute<Map<dynamic, dynamic>>( return CupertinoPageRoute<Map<dynamic, dynamic>>(
settings: routeSettings, builder: (BuildContext context) => page);
}
return PageRouteBuilder(
transitionDuration: Duration(milliseconds: 300),
settings: routeSettings, settings: routeSettings,
builder: (BuildContext context) => page 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));
return SlideTransition(
position: offsetAnimation,
child: child,
); );
});
} }
//从下往上的跳转动画
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( return PageRouteBuilder(
transitionDuration: Duration(milliseconds: 300), transitionDuration: Duration(milliseconds: 300),
settings: routeSettings, settings: routeSettings,
pageBuilder: (context, animation, secondaryAnimation) => page, pageBuilder: (context, animation, secondaryAnimation) => page,
transitionsBuilder: (context, animation, secondaryAnimation, child) { 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));
return SlideTransition( return SlideTransition(
position: offsetAnimation, position:
Tween<Offset>(begin: Offset(0.0, 1.0), end: Offset(0.0, 0.0))
.animate(CurvedAnimation(
parent: animation, curve: Curves.fastOutSlowIn)),
child: child, child: child,
); );
}); });
...@@ -294,7 +317,8 @@ class FlutterBoost { ...@@ -294,7 +317,8 @@ class FlutterBoost {
///unregister for Container lifecycle callbacks ///unregister for Container lifecycle callbacks
void removeBoostContainerLifeCycleObserver( void removeBoostContainerLifeCycleObserver(
BoostContainerLifeCycleObserver observer) => BoostContainerLifeCycleObserver observer) =>
_observersHolder.removeObserver<BoostContainerLifeCycleObserver>(observer); _observersHolder
.removeObserver<BoostContainerLifeCycleObserver>(observer);
///register callbacks for Navigators push & pop ///register callbacks for Navigators push & pop
void addBoostNavigatorObserver(NavigatorObserver observer) => void addBoostNavigatorObserver(NavigatorObserver observer) =>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment