Macos systemnavigator pop (flutter/engine#9019)

Adds the flutter/platform channel to the macOS shell, and implements
SystemNavigator.pop.

Other methods from this channel will be implement in the future.

macOS part of flutter/flutter#30713
This commit is contained in:
stuartmorgan
2019-05-20 16:15:58 -04:00
committed by GitHub
parent 8ab4eb57a0
commit 1cf094e38b

View File

@@ -101,6 +101,11 @@ static const int kDefaultWindowFramebuffer = 0;
*/
- (void)onSettingsChanged:(NSNotification*)notification;
/**
* Handles messages received from the Flutter engine on the _*Channel channels.
*/
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
@end
#pragma mark - Static methods provided to engine configuration
@@ -194,6 +199,9 @@ static bool HeadlessOnMakeResourceCurrent(FLEViewController* controller) {
// A message channel for sending user settings to the flutter engine.
FlutterBasicMessageChannel* _settingsChannel;
// A method channel for miscellaneous platform functionality.
FlutterMethodChannel* _platformChannel;
}
@dynamic view;
@@ -316,6 +324,14 @@ static void CommonInit(FLEViewController* controller) {
[FlutterBasicMessageChannel messageChannelWithName:@"flutter/settings"
binaryMessenger:self
codec:[FlutterJSONMessageCodec sharedInstance]];
_platformChannel =
[FlutterMethodChannel methodChannelWithName:@"flutter/platform"
binaryMessenger:self
codec:[FlutterJSONMethodCodec sharedInstance]];
__weak FLEViewController* weakSelf = self;
[_platformChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
[weakSelf handleMethodCall:call result:result];
}];
}
- (BOOL)launchEngineInternalWithAssetsPath:(NSURL*)assets
@@ -515,6 +531,15 @@ static void CommonInit(FLEViewController* controller) {
[self onSettingsChanged:nil];
}
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
if ([call.method isEqualToString:@"SystemNavigator.pop"]) {
[NSApp terminate:self];
result(nil);
} else {
result(FlutterMethodNotImplemented);
}
}
#pragma mark - FLEReshapeListener
/**