未验证 提交 8247ce26 编写于 作者: G Gary Qian 提交者: GitHub

Implement restore functions on Android and iOS (#6322)

This will not be active on the Framework until https://github.com/flutter/flutter/pull/22221 lands.
上级 2ead5c06
...@@ -58,6 +58,9 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe ...@@ -58,6 +58,9 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe
} else if (method.equals("SystemChrome.setEnabledSystemUIOverlays")) { } else if (method.equals("SystemChrome.setEnabledSystemUIOverlays")) {
setSystemChromeEnabledSystemUIOverlays((JSONArray) arguments); setSystemChromeEnabledSystemUIOverlays((JSONArray) arguments);
result.success(null); result.success(null);
} else if (method.equals("SystemChrome.restoreSystemUIOverlays")) {
restoreSystemChromeSystemUIOverlays();
result.success(null);
} else if (method.equals("SystemChrome.setSystemUIOverlayStyle")) { } else if (method.equals("SystemChrome.setSystemUIOverlayStyle")) {
setSystemChromeSystemUIOverlayStyle((JSONObject) arguments); setSystemChromeSystemUIOverlayStyle((JSONObject) arguments);
result.success(null); result.success(null);
...@@ -224,6 +227,10 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe ...@@ -224,6 +227,10 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe
} }
} }
private void restoreSystemChromeSystemUIOverlays() {
updateSystemUiOverlays();
}
private void setSystemChromeSystemUIOverlayStyle(JSONObject message) { private void setSystemChromeSystemUIOverlayStyle(JSONObject message) {
Window window = mActivity.getWindow(); Window window = mActivity.getWindow();
View view = window.getDecorView(); View view = window.getDecorView();
......
...@@ -51,6 +51,9 @@ using namespace shell; ...@@ -51,6 +51,9 @@ using namespace shell;
} else if ([method isEqualToString:@"SystemChrome.setEnabledSystemUIOverlays"]) { } else if ([method isEqualToString:@"SystemChrome.setEnabledSystemUIOverlays"]) {
[self setSystemChromeEnabledSystemUIOverlays:args]; [self setSystemChromeEnabledSystemUIOverlays:args];
result(nil); result(nil);
} else if ([method isEqualToString:@"SystemChrome.restoreSystemUIOverlays"]) {
[self restoreSystemChromeSystemUIOverlays];
result(nil);
} else if ([method isEqualToString:@"SystemChrome.setSystemUIOverlayStyle"]) { } else if ([method isEqualToString:@"SystemChrome.setSystemUIOverlayStyle"]) {
[self setSystemChromeSystemUIOverlayStyle:args]; [self setSystemChromeSystemUIOverlayStyle:args];
result(nil); result(nil);
...@@ -116,11 +119,10 @@ using namespace shell; ...@@ -116,11 +119,10 @@ using namespace shell;
if (!mask) if (!mask)
return; return;
[[NSNotificationCenter defaultCenter] postNotificationName:@(kOrientationUpdateNotificationName) [[NSNotificationCenter defaultCenter]
object:nil postNotificationName:@(kOrientationUpdateNotificationName)
userInfo:@{ object:nil
@(kOrientationUpdateNotificationKey) : @(mask) userInfo:@{@(kOrientationUpdateNotificationKey) : @(mask)}];
}];
} }
- (void)setSystemChromeApplicationSwitcherDescription:(NSDictionary*)object { - (void)setSystemChromeApplicationSwitcherDescription:(NSDictionary*)object {
...@@ -138,6 +140,10 @@ using namespace shell; ...@@ -138,6 +140,10 @@ using namespace shell;
![overlays containsObject:@"SystemUiOverlay.top"]; ![overlays containsObject:@"SystemUiOverlay.top"];
} }
- (void)restoreSystemChromeSystemUIOverlays {
// Nothing to do on iOS.
}
- (void)setSystemChromeSystemUIOverlayStyle:(NSDictionary*)message { - (void)setSystemChromeSystemUIOverlayStyle:(NSDictionary*)message {
NSString* style = message[@"statusBarBrightness"]; NSString* style = message[@"statusBarBrightness"];
if (style == (id)[NSNull null]) if (style == (id)[NSNull null])
...@@ -160,9 +166,7 @@ using namespace shell; ...@@ -160,9 +166,7 @@ using namespace shell;
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
postNotificationName:@(kOverlayStyleUpdateNotificationName) postNotificationName:@(kOverlayStyleUpdateNotificationName)
object:nil object:nil
userInfo:@{ userInfo:@{@(kOverlayStyleUpdateNotificationKey) : @(statusBarStyle)}];
@(kOverlayStyleUpdateNotificationKey) : @(statusBarStyle)
}];
} else { } else {
// Note: -[UIApplication setStatusBarStyle] is deprecated in iOS9 // Note: -[UIApplication setStatusBarStyle] is deprecated in iOS9
// in favor of delegating to the view controller // in favor of delegating to the view controller
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册