提交 f44bc00a 编写于 作者: S Sarah Zakarias 提交者: GitHub

Add setInitialRoute on FlutterViewController (#3754)

上级 e6da0a2b
......@@ -20,6 +20,14 @@ FLUTTER_EXPORT
bundle:(NSBundle*)nibBundleOrNil NS_DESIGNATED_INITIALIZER;
- (void)handleStatusBarTouches:(UIEvent*)event;
/**
Sets the first route that the Flutter app shows. The default is "/".
- Parameter route: The name of the first route to show.
*/
- (void)setInitialRoute:(NSString*)route;
@end
#endif // FLUTTER_FLUTTERVIEWCONTROLLER_H_
......@@ -72,6 +72,7 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
fml::scoped_nsprotocol<FlutterBasicMessageChannel*> _lifecycleChannel;
fml::scoped_nsprotocol<FlutterBasicMessageChannel*> _systemChannel;
BOOL _initialized;
BOOL _connected;
}
+ (void)initialize {
......@@ -164,7 +165,6 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
[self setupNotificationCenterObservers];
[self connectToEngineAndLoad];
}
- (void)setupNotificationCenterObservers {
......@@ -225,6 +225,11 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
object:nil];
}
- (void)setInitialRoute:(NSString*)route {
[_navigationChannel.get() invokeMethod:@"setInitialRoute"
arguments:route];
}
#pragma mark - Initializing the engine
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
......@@ -232,6 +237,10 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
}
- (void)connectToEngineAndLoad {
if (_connected)
return;
_connected = YES;
TRACE_EVENT0("flutter", "connectToEngineAndLoad");
// We ask the VM to check what it supports.
......@@ -264,6 +273,11 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
[view release];
}
- (void)viewWillAppear:(BOOL)animated {
[self connectToEngineAndLoad];
[super viewWillAppear:animated];
}
#pragma mark - Application lifecycle notifications
- (void)applicationBecameActive:(NSNotification*)notification {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册