Skip to content

Commit

Permalink
FIX: trigger onDestroy and hide topBar in fullScree mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Toufik Zitouni authored and Toufik Zitouni committed Jun 22, 2017
1 parent f94a84d commit d06a18c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
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

0 comments on commit d06a18c

Please sign in to comment.