Browse Source

clear code

Marino Faggiana 6 years ago
parent
commit
47caff3bf1

+ 2 - 0
iOSClient/CCGlobal.h

@@ -300,6 +300,8 @@
 // Nextcloud unsupported
 #define k_nextcloud_unsupported                         12
 
+// Toolbar Detail
+#define k_detail_Toolbar_Height                         49
 
 // -----------------------------------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------------------------------

+ 2 - 2
iOSClient/Main/CCDetail.m

@@ -225,7 +225,7 @@
             
             [ocNetworking createLinkRichdocumentsWithFileID:self.metadataDetail.fileID success:^(NSString *link) {
                 
-                [[NCViewerRichdocument sharedInstance] viewRichDocumentAt:link viewDetail:self];
+                [[NCViewerRichdocument sharedInstance] viewRichDocumentAt:link detail:self];
                 
             } failure:^(NSString *message, NSInteger errorCode) {
                 
@@ -302,7 +302,7 @@
         safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
     }
     
-    [[NCViewerDocumentWeb sharedInstance] viewDocumentWebAt:self.metadataDetail viewDetail:self width:self.view.bounds.size.width height:self.view.bounds.size.height - TOOLBAR_HEIGHT - safeAreaBottom];
+    [[NCViewerDocumentWeb sharedInstance] viewDocumentWebAt:self.metadataDetail detail:self width:self.view.bounds.size.width height:self.view.bounds.size.height - TOOLBAR_HEIGHT - safeAreaBottom];
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 76 - 3
iOSClient/Viewer/NCViewerDocumentWeb.swift

@@ -32,10 +32,10 @@ class NCViewerDocumentWeb: NSObject {
     
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     
-    @objc func viewDocumentWebAt(_ metadata: tableMetadata, viewDetail: CCDetail, width: Int, height: Int) {
+    @objc func viewDocumentWebAt(_ metadata: tableMetadata, detail: CCDetail, width: Int, height: Int) {
         
         if !CCUtility.fileProviderStorageExists(metadata.fileID, fileNameView: metadata.fileNameView) {
-            viewDetail.navigationController?.popViewController(animated: true)
+            detail.navigationController?.popViewController(animated: true)
             return
         }
         
@@ -112,6 +112,79 @@ class NCViewerDocumentWeb: NSObject {
             webView.load(URLRequest(url: url))
         }
         
-        viewDetail.view.addSubview(webView)
+        detail.view.addSubview(webView)
     }
+    
+    func createToolbar(detail: CCDetail) {
+
+        var safeAreaBottom: CGFloat = 0
+        
+        guard let rootView = UIApplication.shared.keyWindow else {
+            return
+        }
+        if #available(iOS 11.0, *) {
+            safeAreaBottom = rootView.safeAreaInsets.bottom
+        }
+        
+        guard let detailView = detail.view else {
+            return
+        }
+
+        let toolbar = UITabBar(frame: CGRect(x: 0 as CGFloat, y: detailView.bounds.size.height - CGFloat(k_detail_Toolbar_Height) - safeAreaBottom, width: detailView.bounds.size.width, height: CGFloat(k_detail_Toolbar_Height)))
+        
+        let flexible = UIBarButtonItem.init(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: detail, action: nil)
+        let fixedSpaceMini = UIBarButtonItem.init(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: detail, action: nil)
+        fixedSpaceMini.width = 25
+        
+       
+        
+        
+    }
+    
+    
+    /*
+ - (void)createToolbar
+ {
+ CGFloat safeAreaBottom = 0;
+ NSString *serverUrl = [[NCManageDatabase sharedInstance] getServerUrl:_metadataDetail.directoryID];
+ if (!serverUrl)
+ return;
+ 
+ if (@available(iOS 11, *)) {
+ safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
+ }
+ 
+ self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - TOOLBAR_HEIGHT - safeAreaBottom, self.view.bounds.size.width, TOOLBAR_HEIGHT)];
+ 
+ UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
+ UIBarButtonItem *fixedSpaceMini = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
+ fixedSpaceMini.width = 25;
+ 
+ buttonModifyTxt = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"actionSheetModify"] style:UIBarButtonItemStylePlain target:self action:@selector(modifyTxtButtonPressed:)];
+ if (![NCBrandOptions sharedInstance].disable_openin_file) {
+ self.buttonAction = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"openFile"] style:UIBarButtonItemStylePlain target:self action:@selector(actionButtonPressed:)];
+ }
+ buttonShare  = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"share"] style:UIBarButtonItemStylePlain target:self action:@selector(shareButtonPressed:)];
+ buttonDelete = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteButtonPressed:)];
+ 
+ if ([CCUtility isDocumentModifiableExtension:fileNameExtension]) {
+ if ([CCUtility isFolderEncrypted:serverUrl account:appDelegate.activeAccount]) // E2EE
+ [self.toolbar setItems:[NSArray arrayWithObjects: buttonModifyTxt, flexible, buttonDelete, fixedSpaceMini, self.buttonAction,  nil]];
+ else
+ [self.toolbar setItems:[NSArray arrayWithObjects: buttonModifyTxt, flexible, buttonDelete, fixedSpaceMini, buttonShare, fixedSpaceMini, self.buttonAction,  nil]];
+ } else {
+ if ([CCUtility isFolderEncrypted:serverUrl account:appDelegate.activeAccount]) // E2EE
+ [self.toolbar setItems:[NSArray arrayWithObjects: flexible, buttonDelete, fixedSpaceMini, self.buttonAction,  nil]];
+ else
+ [self.toolbar setItems:[NSArray arrayWithObjects: flexible, buttonDelete, fixedSpaceMini, buttonShare, fixedSpaceMini, self.buttonAction,  nil]];
+ }
+ 
+ [self.toolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
+ 
+ self.toolbar.barTintColor = [NCBrandColor sharedInstance].tabBar;
+ self.toolbar.tintColor = [NCBrandColor sharedInstance].brandElement;
+ 
+ [self.view addSubview:self.toolbar];
+ }
+ */
 }

+ 9 - 9
iOSClient/Viewer/NCViewerRichdocument.swift

@@ -30,20 +30,20 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
         return instance
     }()
     
-    var viewDetail: CCDetail!
+    var detail: CCDetail!
     var webView: WKWebView!
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
-    @objc func viewRichDocumentAt(_ link: String, viewDetail: CCDetail) {
+    @objc func viewRichDocumentAt(_ link: String, detail: CCDetail) {
         
-        self.viewDetail = viewDetail
+        self.detail = detail
         
         let contentController = WKUserContentController()
         contentController.add(self, name: "RichDocumentsMobileInterface")
         let configuration = WKWebViewConfiguration()
         configuration.userContentController = contentController
         
-        webView = WKWebView(frame: viewDetail.view.bounds, configuration: configuration)
+        webView = WKWebView(frame: detail.view.bounds, configuration: configuration)
         webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 //        webView.scrollView.showsHorizontalScrollIndicator = true
 //        webView.scrollView.showsVerticalScrollIndicator = true
@@ -58,7 +58,7 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
         webView.customUserAgent = userAgent
         webView.load(request)
         
-        viewDetail.view.addSubview(webView)
+        detail.view.addSubview(webView)
     }
     
     //MARK: -
@@ -71,8 +71,8 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
 
                 self.webView.removeFromSuperview()
                 
-                self.viewDetail.navigationController?.popToRootViewController(animated: true)
-                self.viewDetail.navigationController?.navigationBar.topItem?.title = ""
+                self.detail.navigationController?.popToRootViewController(animated: true)
+                self.detail.navigationController?.navigationBar.topItem?.title = ""
             }
             
             if message.body as! String == "insertGraphic" {
@@ -93,11 +93,11 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
                 moveViewController.selectFile = true
                 
                 movieNavigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-                self.viewDetail.present(movieNavigationController, animated: true, completion: nil)
+                self.detail.present(movieNavigationController, animated: true, completion: nil)
             }
             
             if message.body as! String == "share" {
-                appDelegate.activeMain.openWindowShare(viewDetail.metadataDetail)
+                appDelegate.activeMain.openWindowShare(self.detail.metadataDetail)
             }
         }
     }