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,19 +42,18 @@ export 'container/container_coordinator.dart' show BoostRouteSettings; ...@@ -42,19 +42,18 @@ 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 =
GlobalKey<ContainerManagerState>(); GlobalKey<ContainerManagerState>();
final ObserversHolder _observersHolder = ObserversHolder(); final ObserversHolder _observersHolder = ObserversHolder();
final BoostChannel _boostChannel = BoostChannel(); final BoostChannel _boostChannel = BoostChannel();
...@@ -84,14 +83,15 @@ class FlutterBoost { ...@@ -84,14 +83,15 @@ class FlutterBoost {
}); });
} }
static TransitionBuilder init({TransitionBuilder builder, static TransitionBuilder init(
PrePushRoute prePush, {TransitionBuilder builder,
PostPushRoute postPush}) { PrePushRoute prePush,
PostPushRoute postPush}) {
if (Platform.isAndroid) { if (Platform.isAndroid) {
onPageStart(); onPageStart();
} else if (Platform.isIOS) { } else if (Platform.isIOS) {
assert(() { assert(() {
() async { () async {
onPageStart(); onPageStart();
}(); }();
return true; return true;
...@@ -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
...@@ -156,8 +154,8 @@ class FlutterBoost { ...@@ -156,8 +154,8 @@ class FlutterBoost {
**/ **/
Future<Map<dynamic, dynamic>> openInCurrentContainer(String url, Future<Map<dynamic, dynamic>> openInCurrentContainer(String url,
{Map<String, dynamic> urlParams, {Map<String, dynamic> urlParams,
Map<String, dynamic> exts, Map<String, dynamic> exts,
FlutterBoostRouteBuilder routeBuilder}) { FlutterBoostRouteBuilder routeBuilder}) {
final BoostRouteSettings routeSettings = ContainerCoordinator.singleton final BoostRouteSettings routeSettings = ContainerCoordinator.singleton
.createRouteSettings(url, urlParams: urlParams, exts: exts); .createRouteSettings(url, urlParams: urlParams, exts: exts);
...@@ -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,26 +179,23 @@ class FlutterBoost { ...@@ -178,26 +179,23 @@ 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, settings: routeSettings, builder: (BuildContext context) => page);
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>( var offsetAnimation =
begin: Offset(1.0, 0.0), end: Offset(0.0, 0.0)) Tween<Offset>(begin: Offset(1.0, 0.0), end: Offset(0.0, 0.0))
.animate( .animate(CurvedAnimation(
CurvedAnimation(parent: animation, curve: Curves.fastOutSlowIn)); parent: animation, curve: Curves.fastOutSlowIn));
return SlideTransition( return SlideTransition(
position: offsetAnimation, position: offsetAnimation,
child: child, child: child,
...@@ -205,6 +203,31 @@ class FlutterBoost { ...@@ -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 * close flutter page but not close container if there has more than one page in contaienr
*/ */
...@@ -284,7 +307,7 @@ class FlutterBoost { ...@@ -284,7 +307,7 @@ class FlutterBoost {
///register for Container lifecycle callbacks ///register for Container lifecycle callbacks
VoidCallback addBoostContainerLifeCycleObserver( VoidCallback addBoostContainerLifeCycleObserver(
BoostContainerLifeCycleObserver observer) => BoostContainerLifeCycleObserver observer) =>
_observersHolder.addObserver<BoostContainerLifeCycleObserver>(observer); _observersHolder.addObserver<BoostContainerLifeCycleObserver>(observer);
///unregister for Container changed callbacks ///unregister for Container changed callbacks
...@@ -293,8 +316,9 @@ class FlutterBoost { ...@@ -293,8 +316,9 @@ 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