Add setInitialRoute on FlutterViewController (flutter/engine#3754)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user