소스 검색

FIX: trigger onDestroy and hide topBar in fullScree mode

https://github.com/dart-flitter/flutter_webview_plugin/issues/5

https://github.com/dart-flitter/flutter_webview_plugin/issues/4
Toufik Zitouni 8 년 전
부모
커밋
d06a18ca31
3개의 변경된 파일12개의 추가작업 그리고 20개의 파일을 삭제
  1. 10 4
      ios/Classes/FlutterWebviewPlugin.m
  2. 1 1
      ios/Classes/WebviewController.h
  3. 1 15
      ios/Classes/WebviewController.m

+ 10 - 4
ios/Classes/FlutterWebviewPlugin.m

@@ -39,14 +39,20 @@ static NSString *const CHANNEL_NAME = @"flutter_webview_plugin";
     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

+ 1 - 1
ios/Classes/WebviewController.h

@@ -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

+ 1 - 15
ios/Classes/WebviewController.m

@@ -14,19 +14,17 @@
 @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;
 }
@@ -54,21 +52,9 @@
     [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