Skip to content

Commit

Permalink
Implement restore functions on Android and iOS (flutter#6322)
Browse files Browse the repository at this point in the history
This will not be active on the Framework until flutter/flutter#22221 lands.
  • Loading branch information
GaryQian authored Sep 25, 2018
1 parent 2ead5c0 commit 8247ce2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public void onMethodCall(MethodCall call, Result result) {
} else if (method.equals("SystemChrome.setEnabledSystemUIOverlays")) {
setSystemChromeEnabledSystemUIOverlays((JSONArray) arguments);
result.success(null);
} else if (method.equals("SystemChrome.restoreSystemUIOverlays")) {
restoreSystemChromeSystemUIOverlays();
result.success(null);
} else if (method.equals("SystemChrome.setSystemUIOverlayStyle")) {
setSystemChromeSystemUIOverlayStyle((JSONObject) arguments);
result.success(null);
Expand Down Expand Up @@ -224,6 +227,10 @@ private void updateSystemUiOverlays(){
}
}

private void restoreSystemChromeSystemUIOverlays() {
updateSystemUiOverlays();
}

private void setSystemChromeSystemUIOverlayStyle(JSONObject message) {
Window window = mActivity.getWindow();
View view = window.getDecorView();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
} else if ([method isEqualToString:@"SystemChrome.setEnabledSystemUIOverlays"]) {
[self setSystemChromeEnabledSystemUIOverlays:args];
result(nil);
} else if ([method isEqualToString:@"SystemChrome.restoreSystemUIOverlays"]) {
[self restoreSystemChromeSystemUIOverlays];
result(nil);
} else if ([method isEqualToString:@"SystemChrome.setSystemUIOverlayStyle"]) {
[self setSystemChromeSystemUIOverlayStyle:args];
result(nil);
Expand Down Expand Up @@ -116,11 +119,10 @@ - (void)setSystemChromePreferredOrientations:(NSArray*)orientations {

if (!mask)
return;
[[NSNotificationCenter defaultCenter] postNotificationName:@(kOrientationUpdateNotificationName)
object:nil
userInfo:@{
@(kOrientationUpdateNotificationKey) : @(mask)
}];
[[NSNotificationCenter defaultCenter]
postNotificationName:@(kOrientationUpdateNotificationName)
object:nil
userInfo:@{@(kOrientationUpdateNotificationKey) : @(mask)}];
}

- (void)setSystemChromeApplicationSwitcherDescription:(NSDictionary*)object {
Expand All @@ -138,6 +140,10 @@ - (void)setSystemChromeEnabledSystemUIOverlays:(NSArray*)overlays {
![overlays containsObject:@"SystemUiOverlay.top"];
}

- (void)restoreSystemChromeSystemUIOverlays {
// Nothing to do on iOS.
}

- (void)setSystemChromeSystemUIOverlayStyle:(NSDictionary*)message {
NSString* style = message[@"statusBarBrightness"];
if (style == (id)[NSNull null])
Expand All @@ -160,9 +166,7 @@ - (void)setSystemChromeSystemUIOverlayStyle:(NSDictionary*)message {
[[NSNotificationCenter defaultCenter]
postNotificationName:@(kOverlayStyleUpdateNotificationName)
object:nil
userInfo:@{
@(kOverlayStyleUpdateNotificationKey) : @(statusBarStyle)
}];
userInfo:@{@(kOverlayStyleUpdateNotificationKey) : @(statusBarStyle)}];
} else {
// Note: -[UIApplication setStatusBarStyle] is deprecated in iOS9
// in favor of delegating to the view controller
Expand Down

0 comments on commit 8247ce2

Please sign in to comment.