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 @@
FlutterBoostPlugin* instance = [self.class sharedInstance];
instance.methodChannel = channel;
[registrar addMethodCallDelegate:instance channel:channel];
[registrar addApplicationDelegate:instance];
}
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
......@@ -215,4 +216,9 @@
self.methodChannel = nil;
self.application = nil;
}
#pragma mark appDelegate
- (void)applicationDidBecomeActive:(UIApplication *)application{
[self sendEvent:@"applicationDidBecomeActive" arguments:@{@"status":@"applicationDidBecomeActive"}];
}
@end
......@@ -42,15 +42,14 @@ 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 =
......@@ -84,7 +83,8 @@ class FlutterBoost {
});
}
static TransitionBuilder init({TransitionBuilder builder,
static TransitionBuilder init(
{TransitionBuilder builder,
PrePushRoute prePush,
PostPushRoute postPush}) {
if (Platform.isAndroid) {
......@@ -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
......@@ -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,28 +179,50 @@ 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);
}
return PageRouteBuilder(
transitionDuration: Duration(milliseconds: 300),
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(
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));
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,
);
});
......@@ -294,7 +317,8 @@ class FlutterBoost {
///unregister for Container lifecycle callbacks
void removeBoostContainerLifeCycleObserver(
BoostContainerLifeCycleObserver observer) =>
_observersHolder.removeObserver<BoostContainerLifeCycleObserver>(observer);
_observersHolder
.removeObserver<BoostContainerLifeCycleObserver>(observer);
///register callbacks for Navigators push & pop
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