Marino Faggiana 8 лет назад
Родитель
Сommit
59af879b07

+ 12 - 8
iOSClient/Library/SwiftWebVC/SwiftModalWebVC.swift

@@ -17,9 +17,10 @@ public protocol SwiftModalWebVCDelegate: class {
 public class SwiftModalWebVC: UINavigationController {
     
     public weak var delegateWeb: SwiftModalWebVCDelegate?
+    var doneButtonHide: Bool! = true
     
     public enum SwiftModalWebVCTheme {
-        case lightBlue, lightBlack, dark, loginWeb
+        case lightBlue, lightBlack, dark, custom
     }
     
     weak var webViewDelegate: UIWebViewDelegate? = nil
@@ -49,6 +50,8 @@ public class SwiftModalWebVC: UINavigationController {
         let webViewController = SwiftWebVC(aRequest: request)
         webViewController.storedStatusColor = UINavigationBar.appearance().barStyle
         
+        super.init(rootViewController: webViewController)
+
         let doneButton = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: "SwiftWebVCDismiss"),
                                          style: UIBarButtonItemStyle.plain,
                                          target: webViewController,
@@ -70,13 +73,16 @@ public class SwiftModalWebVC: UINavigationController {
             webViewController.buttonColor = UIColor.white
             webViewController.titleColor = UIColor.groupTableViewBackground
             UINavigationBar.appearance().barStyle = UIBarStyle.black
-        case .loginWeb:
-            webViewController.buttonColor = UIColor.white
-            UINavigationBar.appearance().barStyle = UIBarStyle.default
-            webViewController.toobar = false
+        case .custom:
+            doneButton.tintColor = colorText
+            webViewController.buttonColor = colorText
+            webViewController.titleColor = colorText
+            UINavigationBar.appearance().barTintColor = color
+            self.navigationBar.isTranslucent = false
+            self.toolbar.backgroundColor = color
         }
         
-        if (theme != .loginWeb) {
+        if (doneButtonHide == false) {
             if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad) {
                 webViewController.navigationItem.leftBarButtonItem = doneButton
             }
@@ -84,8 +90,6 @@ public class SwiftModalWebVC: UINavigationController {
                 webViewController.navigationItem.rightBarButtonItem = doneButton
             }
         }
-        
-        super.init(rootViewController: webViewController)
         webViewController.delegate = self
     }
     

+ 11 - 18
iOSClient/Library/SwiftWebVC/SwiftWebVC.swift

@@ -22,7 +22,7 @@ public class SwiftWebVC: UIViewController {
     var buttonColor: UIColor? = nil
     var titleColor: UIColor? = nil
     var closing: Bool! = false
-    var toobar: Bool! = true
+    //var toobar: Bool! = true
     
     lazy var backBarButtonItem: UIBarButtonItem =  {
         var tempBackBarButtonItem = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: "SwiftWebVCBack"),
@@ -103,11 +103,14 @@ public class SwiftWebVC: UIViewController {
     }
     
     func loadRequest(_ request: URLRequest) {
+        
+        let userAgent : String = CCUtility.getUserAgent()
+        
         if #available(iOS 9.0, *) {
-            webView.customUserAgent = "Mozilla/5.0 (iOS) Nextcloud-iOS"
+            webView.customUserAgent = userAgent
         } else {
             // Fallback on earlier versions
-            UserDefaults.standard.register(defaults: ["UserAgent": "Mozilla/5.0 (iOS) Nextcloud-iOS"])
+            UserDefaults.standard.register(defaults: ["UserAgent": userAgent])
         }
         webView.load(request)
     }
@@ -145,18 +148,12 @@ public class SwiftWebVC: UIViewController {
         
         super.viewWillAppear(true)
         
-        if (toobar == true) {
-        
-            if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone) {
-                self.navigationController?.setToolbarHidden(false, animated: false)
-            }
-            else if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad) {
-                self.navigationController?.setToolbarHidden(true, animated: true)
-            }
-            
-        } else {
-            self.navigationController?.setToolbarHidden(true, animated: true)
+        if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone) {
+            self.navigationController?.setToolbarHidden(false, animated: false)
         }
+        else if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad) {
+            self.navigationController?.setToolbarHidden(true, animated: true)
+        }            
     }
     
     override public func viewWillDisappear(_ animated: Bool) {
@@ -177,10 +174,6 @@ public class SwiftWebVC: UIViewController {
     
     func updateToolbarItems() {
         
-        if (toobar == false) {
-            return
-        }
-        
         backBarButtonItem.isEnabled = webView.canGoBack
         forwardBarButtonItem.isEnabled = webView.canGoForward
         

+ 1 - 1
iOSClient/Login/CCLoginWeb.swift

@@ -24,7 +24,7 @@ public class CCLoginWeb: UIViewController {
         
         self.viewController = vc
         
-        let webVC = SwiftModalWebVC(urlString: k_loginBaseUrl, theme: .loginWeb, color: Constant.GlobalConstants.k_Color_NavigationBar, colorText: Constant.GlobalConstants.k_Color_NavigationBar_Text)
+        let webVC = SwiftModalWebVC(urlString: k_loginBaseUrl, theme: .custom, color: Constant.GlobalConstants.k_Color_NavigationBar, colorText: Constant.GlobalConstants.k_Color_NavigationBar_Text)
         webVC.delegateWeb = self
         vc.present(webVC, animated: false, completion: nil)
     }