Commit 74dac2ed authored by 余玠's avatar 余玠

fix #625 on v1.12.13-hotfixes

parent 80d02b98
...@@ -21,6 +21,7 @@ class _MyAppState extends State<MyApp> { ...@@ -21,6 +21,7 @@ class _MyAppState extends State<MyApp> {
'first': (pageName, params, _) => FirstRouteWidget(), 'first': (pageName, params, _) => FirstRouteWidget(),
'firstFirst': (pageName, params, _) => FirstFirstRouteWidget(), 'firstFirst': (pageName, params, _) => FirstFirstRouteWidget(),
'second': (pageName, params, _) => SecondRouteWidget(), 'second': (pageName, params, _) => SecondRouteWidget(),
'secondStateful': (pageName, params, _) => SecondStatefulRouteWidget(),
'tab': (pageName, params, _) => TabRouteWidget(), 'tab': (pageName, params, _) => TabRouteWidget(),
'platformView': (pageName, params, _) => PlatformRouteWidget(), 'platformView': (pageName, params, _) => PlatformRouteWidget(),
'flutterFragment': (pageName, params, _) => FragmentRouteWidget(params), 'flutterFragment': (pageName, params, _) => FragmentRouteWidget(params),
......
...@@ -60,7 +60,7 @@ class _FirstRouteWidgetState extends State<FirstRouteWidget>{ ...@@ -60,7 +60,7 @@ class _FirstRouteWidgetState extends State<FirstRouteWidget>{
print("open natve page!"); print("open natve page!");
FlutterBoost.singleton.open("native").then((Map value) { FlutterBoost.singleton.open("native").then((Map value) {
print( print(
"call me when page is finished. did recieve second route result $value"); "call me when page is finished. did recieve native route result $value");
}); });
}, },
), ),
...@@ -85,6 +85,16 @@ class _FirstRouteWidgetState extends State<FirstRouteWidget>{ ...@@ -85,6 +85,16 @@ class _FirstRouteWidgetState extends State<FirstRouteWidget>{
}, },
), ),
RaisedButton(
child: Text('Present second stateful route'),
onPressed: () {
print("Present second stateful page!");
FlutterBoost.singleton.open("secondStateful",urlParams:<dynamic,dynamic>{"present":true}).then((Map value) {
print(
"call me when page is finished. did recieve second stateful route result $value");
});
},
),
RaisedButton( RaisedButton(
child: Text('Present second route'), child: Text('Present second route'),
onPressed: () { onPressed: () {
...@@ -195,7 +205,44 @@ class _EmbededFirstRouteWidgetState extends State<EmbededFirstRouteWidget> { ...@@ -195,7 +205,44 @@ class _EmbededFirstRouteWidgetState extends State<EmbededFirstRouteWidget> {
} }
@override @override
void dispose() { void dispose() {
print('[XDEBUG]:_EmbededFirstRouteWidgetState dispose called!'); print('[XDEBUG]:_EmbededFirstRouteWidgetState disposing~');
super.dispose();
}
}
class SecondStatefulRouteWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _SecondStatefulRouteWidgetState();
}
}
class _SecondStatefulRouteWidgetState extends State<SecondStatefulRouteWidget>{
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("SecondStateful Route"),
),
body: Center(
child: RaisedButton(
onPressed: () {
// Navigate back to first route when tapped.
BoostContainerSettings settings =
BoostContainer.of(context).settings;
FlutterBoost.singleton.close(settings.uniqueId,
result: <dynamic,dynamic>{"result": "data from second"});
},
child: Text('Go back with result!'),
),
),
);
}
@override
void dispose() {
print('[XDEBUG]:SecondStatefulRouteWidget disposing~');
super.dispose(); super.dispose();
} }
} }
...@@ -557,6 +604,7 @@ class _PushWidgetState extends State<PushWidget> { ...@@ -557,6 +604,7 @@ class _PushWidgetState extends State<PushWidget> {
@override @override
void dispose() { void dispose() {
// TODO: implement dispose // TODO: implement dispose
print('[XDEBUG] - PushWidget is disposing~');
super.dispose(); super.dispose();
_backPressedListenerUnsub?.call(); _backPressedListenerUnsub?.call();
} }
......
...@@ -232,8 +232,7 @@ ...@@ -232,8 +232,7 @@
NSString *oldName = params[@"oldName"]; NSString *oldName = params[@"oldName"];
NSString *newName = params[@"newName"]; NSString *newName = params[@"newName"];
if (oldName!=nil && [newName isEqualToString:@"default"]) { if (oldName!=nil && [newName isEqualToString:@"default"]) {
FLBFlutterViewContainer *viewController = (FLBFlutterViewContainer *)self.flutterProvider.engine.viewController; [self.flutterProvider detach];
[viewController surfaceUpdated:NO];
} }
} }
......
...@@ -108,6 +108,7 @@ ...@@ -108,6 +108,7 @@
- (void)detach - (void)detach
{ {
if(_engine.viewController != _dummy){ if(_engine.viewController != _dummy){
[(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
_engine.viewController = _dummy; _engine.viewController = _dummy;
} }
} }
......
...@@ -157,23 +157,33 @@ static NSUInteger kInstanceCounter = 0; ...@@ -157,23 +157,33 @@ static NSUInteger kInstanceCounter = 0;
} }
- (void)willMoveToParentViewController:(UIViewController *)parent { - (void)willMoveToParentViewController:(UIViewController *)parent {
if (parent) { if (parent && _name) {
//当VC将要被移动到Parent中的时候,才出发flutter层面的page init
[BoostMessageChannel didInitPageContainer:^(NSNumber *r) {} [BoostMessageChannel didInitPageContainer:^(NSNumber *r) {}
pageName:_name pageName:_name
params:_params params:_params
uniqueId:[self uniqueIDString]]; uniqueId:[self uniqueIDString]];
} }
[super willMoveToParentViewController:parent];
} }
- (void)didMoveToParentViewController:(UIViewController *)parent { - (void)didMoveToParentViewController:(UIViewController *)parent {
if (!parent) { if (!parent) {
//当VC被移出parent时,就通知flutter层销毁page
[self notifyWillDealloc]; [self notifyWillDealloc];
} }
[super didMoveToParentViewController:parent];
} }
- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion { - (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
[super dismissViewControllerAnimated:flag completion:^(){
if (completion) {
completion();
}
//当VC被dismiss时,就通知flutter层销毁page
[self notifyWillDealloc]; [self notifyWillDealloc];
[super dismissViewControllerAnimated:flag completion:completion]; }];
} }
- (void)dealloc - (void)dealloc
......
...@@ -102,7 +102,7 @@ class ContainerCoordinator { ...@@ -102,7 +102,7 @@ class ContainerCoordinator {
Map map = event; Map map = event;
final String type = map['type']; final String type = map['type'];
Logger.log("onEvent $type"); Logger.log('onEvent $type');
switch (type) { switch (type) {
//Handler back key pressed event. //Handler back key pressed event.
...@@ -242,7 +242,7 @@ class ContainerCoordinator { ...@@ -242,7 +242,7 @@ class ContainerCoordinator {
ContainerLifeCycle.Appear); ContainerLifeCycle.Appear);
Logger.log( Logger.log(
'native containner did show,\nmanager dump:\n${FlutterBoost.containerManager?.dump()}'); 'native containner did show-$name,\nmanager dump:\n${FlutterBoost.containerManager?.dump()}');
return true; return true;
} }
...@@ -275,7 +275,7 @@ class ContainerCoordinator { ...@@ -275,7 +275,7 @@ class ContainerCoordinator {
FlutterBoost.containerManager?.remove(pageId); FlutterBoost.containerManager?.remove(pageId);
Logger.log( Logger.log(
'native containner dealloc, \n manager dump:\n${FlutterBoost.containerManager?.dump()}'); 'native containner dealloc for $name, \n manager dump:\n${FlutterBoost.containerManager?.dump()}');
return true; return true;
} }
......
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