Skip to content

FIX: trigger onDestroy and hide topBar in fullScree mode #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2017
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
14 changes: 10 additions & 4 deletions ios/Classes/FlutterWebviewPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ - (void)showWebView:(FlutterMethodCall*)call {
NSNumber *clearCookies = call.arguments[@"clearCookies"];
NSNumber *fullScreen = call.arguments[@"fullScreen"];

self.webviewController = [[WebviewController alloc] initWithUrl:url withJavascript:withJavascript clearCache:clearCache clearCookes:clearCookies fullScreen:fullScreen];
self.webviewController = [[WebviewController alloc] initWithUrl:url withJavascript:withJavascript clearCache:clearCache clearCookes:clearCookies];

UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:self.webviewController];
[_viewController presentModalViewController:navigation animated:YES];
if ([fullScreen boolValue]) {
[self.viewController presentViewController:self.webviewController animated:YES completion:nil];
} else {
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:self.webviewController];
[self.viewController presentModalViewController:navigation animated:YES];
}
}

- (void)closeWebView {
[self.webviewController dismissViewControllerAnimated:YES completion:nil];
[self.webviewController dismissViewControllerAnimated:YES completion:^{
[channel invokeMethod:@"onDestroy" arguments:nil];
}];
}

@end
2 changes: 1 addition & 1 deletion ios/Classes/WebviewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#import <UIKit/UIKit.h>

@interface WebviewController : UIViewController
- (instancetype)initWithUrl:(NSString *)url withJavascript:(NSNumber *)withJavascript clearCache:(NSNumber *)clearCache clearCookes:(NSNumber *)clearCookies fullScreen:(NSNumber *)fullScreen;
- (instancetype)initWithUrl:(NSString *)url withJavascript:(NSNumber *)withJavascript clearCache:(NSNumber *)clearCache clearCookes:(NSNumber *)clearCookies;
@end
16 changes: 1 addition & 15 deletions ios/Classes/WebviewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ @interface WebviewController ()
@property NSNumber *withJavascript;
@property NSNumber *clearCache;
@property NSNumber *clearCookies;
@property NSNumber *fullScreen;
@end

@implementation WebviewController

- (instancetype)initWithUrl:(NSString *)url withJavascript:(NSNumber *)withJavascript clearCache:(NSNumber *)clearCache clearCookes:(NSNumber *)clearCookies fullScreen:(NSNumber *)fullScreen {
- (instancetype)initWithUrl:(NSString *)url withJavascript:(NSNumber *)withJavascript clearCache:(NSNumber *)clearCache clearCookes:(NSNumber *)clearCookies {
self = [super init];
if (self) {
self.url = url;
self.withJavascript = withJavascript;
self.clearCache = clearCache;
self.clearCookies = clearCookies;
self.fullScreen = fullScreen;
}
return self;
}
Expand Down Expand Up @@ -54,21 +52,9 @@ - (void)viewDidLoad {
[self.view addSubview:webView];
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

if ([self.fullScreen boolValue]) {
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
}

- (IBAction)backButtonPressed:(id)sender {
[channel invokeMethod:@"onBackPressed" arguments:nil];
[self dismissViewControllerAnimated:YES completion:nil];
}

- (void)dealloc {
[channel invokeMethod:@"onDestroy" arguments:nil];
}

@end