فهرست منبع

New share extension

marinofaggiana 4 سال پیش
والد
کامیت
22674b9571

+ 32 - 38
Share/NCShareExtension.swift

@@ -79,38 +79,37 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
         refreshControl.addTarget(self, action: #selector(reloadDatasource), for: .valueChanged)
         
         // Empty
-        emptyDataSet = NCEmptyDataSet.init(view: collectionView, offset: 0, delegate: self)
+        emptyDataSet = NCEmptyDataSet.init(view: collectionView, offset: -50, delegate: self)
 
         separatorView.backgroundColor = NCBrandColor.shared.separator
-    }
-    
-    override func viewWillAppear(_ animated: Bool) {
-        super.viewWillAppear(animated)
         
-        guard let account = NCManageDatabase.shared.getAccountActive() else {
-            extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
-            return
-        }
-        self.activeAccount = account
-        
-        let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
-        let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
-        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-      
         // LOG
         let levelLog = CCUtility.getLogLevel()
-        NCCommunicationCommon.shared.levelLog = levelLog
+        let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
+        let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
         
+        NCCommunicationCommon.shared.levelLog = levelLog
         if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
             NCCommunicationCommon.shared.pathLog = pathDirectoryGroup
         }
-        
         if isSimulatorOrTestFlight {
             NCCommunicationCommon.shared.writeLog("Start session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
         } else {
             NCCommunicationCommon.shared.writeLog("Start session with level \(levelLog) " + versionNextcloudiOS)
         }
+    }
+    
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        
+        guard let account = NCManageDatabase.shared.getAccountActive() else {
+            extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
+            return
+        }
+        self.activeAccount = account
         
+        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+      
         // NETWORKING
         NCCommunicationCommon.shared.setup(account: account.account, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account), urlBase: account.urlBase, userAgent: CCUtility.getUserAgent(), webDav: NCUtilityFileSystem.shared.getWebDAV(account: account.account), dav: NCUtilityFileSystem.shared.getDAV(), nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
                 
@@ -122,7 +121,6 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
                
         // Load data source
         serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, account: activeAccount.account)
-        // ROOT load files
         getFilesExtensionContext { (filesName, error) in
             DispatchQueue.main.async {
                 self.filesName = filesName
@@ -136,9 +134,7 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
         }
         
         shares = NCManageDatabase.shared.getTableShares(account: activeAccount.account, serverUrl: serverUrl)
-        
         reloadDatasource(withLoadFolder: true)
-        
         setNavigationBar()
     }
     
@@ -170,8 +166,10 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
         // BACK BUTTON
 
         let backButton = UIButton(type: .custom)
-        backButton.setImage(UIImage(named: "back"), for: .normal)
-        backButton.setTitle("Back", for: .normal)
+        backButton.setImage(UIImage(named: "back")?.image(color: .systemBlue, size: 30), for: .normal)
+        backButton.semanticContentAttribute = .forceLeftToRight
+        backButton.sizeToFit()
+        backButton.setTitle(" "+NSLocalizedString("_back_", comment: ""), for: .normal)
         backButton.setTitleColor(.systemBlue, for: .normal)
         backButton.addTarget(self, action: #selector(backButtonTapped(sender:)), for: .touchUpInside)
         
@@ -270,6 +268,13 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
     
     @objc func backButtonTapped(sender: Any) {
         
+        if let serverUrlTemp = CCUtility.deleteLastPathServerUrl(serverUrl) {
+        
+            serverUrl = serverUrlTemp
+            shares = NCManageDatabase.shared.getTableShares(account: activeAccount.account, serverUrl: serverUrl)
+            reloadDatasource(withLoadFolder: true)
+            setNavigationBar()
+        }
     }
     
     @objc func profileButtonTapped(sender: Any) {
@@ -296,23 +301,12 @@ extension NCShareExtension: UICollectionViewDelegate {
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         
         guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return }
-                
-        if metadata.directory {
-            
-            /*
-            guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName) else { return }
-            guard let viewController = UIStoryboard(name: "MainInterface", bundle: nil).instantiateViewController(withIdentifier: "NCShareExtension.storyboard") as? NCShareExtension else { return }
-
-            self.serverUrlPush = serverUrlPush
-            self.metadataTouch = metadata
+        guard let serverUrlTemp = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName) else { return }
             
-            viewController.titleCurrentFolder = metadataTouch!.fileNameView
-            viewController.serverUrl = serverUrlPush
-            viewController.filesName = filesName
-                   
-            self.navigationController?.pushViewController(viewController, animated: true)
-            */
-        }
+        serverUrl = serverUrlTemp
+        shares = NCManageDatabase.shared.getTableShares(account: activeAccount.account, serverUrl: serverUrl)
+        reloadDatasource(withLoadFolder: true)
+        setNavigationBar()
     }
 }
 

+ 4 - 1
iOSClient/Images.xcassets/back.imageset/Contents.json

@@ -1,12 +1,15 @@
 {
   "images" : [
     {
-      "filename" : "back.png",
+      "filename" : "less-than.svg",
       "idiom" : "universal"
     }
   ],
   "info" : {
     "author" : "xcode",
     "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
   }
 }

BIN
iOSClient/Images.xcassets/back.imageset/back.png


+ 1 - 0
iOSClient/Images.xcassets/back.imageset/less-than.svg

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M18.5,4.14L19.5,5.86L8.97,12L19.5,18.14L18.5,19.86L5,12L18.5,4.14Z" /></svg>

+ 1 - 0
iOSClient/Utility/CCUtility.h

@@ -185,6 +185,7 @@
 + (NSString *)removeForbiddenCharactersServer:(NSString *)fileName;
 + (NSString *)removeForbiddenCharactersFileSystem:(NSString *)fileName;
 
++ (NSString *)deleteLastPathServerUrl:(NSString *)serverUrl;
 + (NSString *)stringAppendServerUrl:(NSString *)serverUrl addFileName:(NSString *)addFileName;
 
 + (NSString *)createRandomString:(int)numChars;

+ 13 - 0
iOSClient/Utility/CCUtility.m

@@ -789,6 +789,19 @@
     return fileName;
 }
 
++ (NSString *)deleteLastPathServerUrl:(NSString *)serverUrl
+{
+    NSURL *url = [NSURL URLWithString:serverUrl];
+    url = [url URLByDeletingLastPathComponent];
+    
+    NSString *path = url.absoluteString;
+    if ([path hasSuffix:@"/"]) {
+        path = [path substringToIndex:[path length]-1];
+    }
+
+    return path;
+}
+
 + (NSString*)stringAppendServerUrl:(NSString *)serverUrl addFileName:(NSString *)addFileName
 {
     NSString *result;