Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ FLUTTER_EXPORT

@property(strong, nonatomic) UIWindow* window;

/**
* Handle StatusBar touches.
*
* Call this from your AppDelegate's `touchesBegan:withEvent:` to have Flutter respond to StatusBar
* touches. For example, to enable scroll-to-top behavior. FlutterAppDelegate already calls it so
* you only need to manually call it if you aren't using a FlutterAppDelegate.
*/
+ (void)handleStatusBarTouches:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event;

@end

#endif // FLUTTER_FLUTTERDARTPROJECT_H_
14 changes: 7 additions & 7 deletions shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ - (BOOL)application:(UIApplication*)application

// Returns the key window's rootViewController, if it's a FlutterViewController.
// Otherwise, returns nil.
- (FlutterViewController*)rootFlutterViewController {
+ (FlutterViewController*)rootFlutterViewController {
UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
if ([viewController isKindOfClass:[FlutterViewController class]]) {
return (FlutterViewController*)viewController;
}
return nil;
}

- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
[super touchesBegan:touches withEvent:event];
+ (void)handleStatusBarTouches:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event {
[self.rootFlutterViewController handleStatusBarTouches:event];
}

// Pass status bar taps to key window Flutter rootViewController.
if (self.rootFlutterViewController != nil) {
[self.rootFlutterViewController handleStatusBarTouches:event];
}
- (void)touchesBegan:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event {
[super touchesBegan:touches withEvent:event];
[[self class] handleStatusBarTouches:touches withEvent:event];
}

#pragma GCC diagnostic push
Expand Down