Browse Source

Main menu as drawer

Signed-off-by: Philippe Weidmann <philippe.weidmann@infomaniak.com>
Philippe Weidmann 5 years ago
parent
commit
5837826b2e

+ 4 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		3704EB2A23D5A58400455C5B /* Menu.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3704EB2923D5A58400455C5B /* Menu.storyboard */; };
 		371B5A2E23D0B04500FAFAE9 /* MainMenuTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371B5A2D23D0B04500FAFAE9 /* MainMenuTableViewController.swift */; };
 		371B5A3123D0B71B00FAFAE9 /* MainMenuManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371B5A3023D0B71A00FAFAE9 /* MainMenuManager.swift */; };
 		371B5A3323D0BD5500FAFAE9 /* FloatingPanel.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 371B5A3223D0BD5500FAFAE9 /* FloatingPanel.framework */; };
@@ -664,6 +665,7 @@
 		08EA97451E6554FC004C83FA /* FirebaseCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = FirebaseCore.framework; sourceTree = "<group>"; };
 		08EA97461E6554FC004C83FA /* FirebaseInstanceID.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = FirebaseInstanceID.framework; sourceTree = "<group>"; };
 		08EA97471E6554FC004C83FA /* GoogleToolboxForMac.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = GoogleToolboxForMac.framework; sourceTree = "<group>"; };
+		3704EB2923D5A58400455C5B /* Menu.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Menu.storyboard; sourceTree = "<group>"; };
 		371B5A2D23D0B04500FAFAE9 /* MainMenuTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuTableViewController.swift; sourceTree = "<group>"; };
 		371B5A3023D0B71A00FAFAE9 /* MainMenuManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuManager.swift; sourceTree = "<group>"; };
 		371B5A3223D0BD5500FAFAE9 /* FloatingPanel.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FloatingPanel.framework; path = Carthage/Build/iOS/FloatingPanel.framework; sourceTree = "<group>"; };
@@ -1507,6 +1509,7 @@
 				371B5A2D23D0B04500FAFAE9 /* MainMenuTableViewController.swift */,
 				371B5A3023D0B71A00FAFAE9 /* MainMenuManager.swift */,
 				37ECC83A23D0C7400082EFA2 /* MenuAction.swift */,
+				3704EB2923D5A58400455C5B /* Menu.storyboard */,
 			);
 			path = MainMenu;
 			sourceTree = "<group>";
@@ -3186,6 +3189,7 @@
 				F7D4233E1F0596AC009C9782 /* Reader-Email.png in Resources */,
 				F7D423361F0596AC009C9782 /* AppIcon-167.png in Resources */,
 				F7F54CF71E5B14C700E19C62 /* PlayButtonOverlayLargeTap.png in Resources */,
+				3704EB2A23D5A58400455C5B /* Menu.storyboard in Resources */,
 				F7E0E1DE22327DBA006B0911 /* NCAudioRecorderViewController.storyboard in Resources */,
 				F710E8111EF95C9C00DC2427 /* ImagesIntro.xcassets in Resources */,
 				F7F54D021E5B14C700E19C62 /* UIBarButtonItemGrid@3x.png in Resources */,

+ 1 - 2
iOSClient/AppDelegate.m

@@ -872,8 +872,7 @@ PKPushRegistry *pushRegistry;
     tableDirectory *tableDirectory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", self.activeAccount, self.activeMain.serverUrl]];
     
     if ([tableDirectory.permissions containsString:@"CK"]) {
-        [[MainMenuManager sharedInstance] showMenuInViewController:self.window.rootViewController];
-        //(void)[[NCCreateMenuAdd alloc] initWithViewController:self.window.rootViewController view:[(UIButton *)sender superview]];
+        [self showMenuInViewController:self.window.rootViewController];
     } else {
         [[NCContentPresenter shared] messageNotification:@"_warning_" description:@"_no_permission_add_file_" delay:k_dismissAfterSecond type:messageTypeInfo errorCode:0];
     }

+ 1 - 52
iOSClient/Main/Main.storyboard

@@ -162,7 +162,7 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <imageView userInteractionEnabled="NO" tag="999" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="zlU-MP-ZVs">
-                                <rect key="frame" x="-16" y="290.5" width="446" height="315"/>
+                                <rect key="frame" x="95.5" y="369.5" width="223" height="157.5"/>
                             </imageView>
                         </subviews>
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -237,57 +237,6 @@
             </objects>
             <point key="canvasLocation" x="5857" y="327"/>
         </scene>
-        <!--Main Menu Table View Controller-->
-        <scene sceneID="dK1-c7-3On">
-            <objects>
-                <tableViewController storyboardIdentifier="MainMenuTableViewController" id="vca-n7-IIz" customClass="MainMenuTableViewController" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
-                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="60" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="NK9-kS-MOD">
-                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
-                        <prototypes>
-                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="menuActionCell" rowHeight="60" id="EQz-WZ-NOm">
-                                <rect key="frame" x="0.0" y="28" width="414" height="60"/>
-                                <autoresizingMask key="autoresizingMask"/>
-                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="EQz-WZ-NOm" id="MXz-fX-a54">
-                                    <rect key="frame" x="0.0" y="0.0" width="414" height="60"/>
-                                    <autoresizingMask key="autoresizingMask"/>
-                                    <subviews>
-                                        <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="1" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Zd5-qC-6Ie">
-                                            <rect key="frame" x="8" y="14" width="32" height="32"/>
-                                            <constraints>
-                                                <constraint firstAttribute="height" constant="32" id="AYg-rj-RAh"/>
-                                                <constraint firstAttribute="width" constant="32" id="TcB-NO-Ncg"/>
-                                            </constraints>
-                                        </imageView>
-                                        <label opaque="NO" userInteractionEnabled="NO" tag="2" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J4O-BZ-xXZ">
-                                            <rect key="frame" x="56" y="19.5" width="330" height="21"/>
-                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                            <nil key="textColor"/>
-                                            <nil key="highlightedColor"/>
-                                        </label>
-                                    </subviews>
-                                    <constraints>
-                                        <constraint firstItem="Zd5-qC-6Ie" firstAttribute="leading" secondItem="MXz-fX-a54" secondAttribute="leading" constant="8" id="HNF-b3-0lw"/>
-                                        <constraint firstItem="J4O-BZ-xXZ" firstAttribute="centerY" secondItem="MXz-fX-a54" secondAttribute="centerY" id="OnH-41-zTd"/>
-                                        <constraint firstAttribute="trailingMargin" secondItem="J4O-BZ-xXZ" secondAttribute="trailing" constant="8" id="iY7-5r-hah"/>
-                                        <constraint firstItem="J4O-BZ-xXZ" firstAttribute="leading" secondItem="Zd5-qC-6Ie" secondAttribute="trailing" constant="16" id="nqb-ga-0n3"/>
-                                        <constraint firstItem="Zd5-qC-6Ie" firstAttribute="centerY" secondItem="MXz-fX-a54" secondAttribute="centerY" id="vQ3-Yx-pNG"/>
-                                    </constraints>
-                                </tableViewCellContentView>
-                            </tableViewCell>
-                        </prototypes>
-                        <sections/>
-                        <connections>
-                            <outlet property="dataSource" destination="vca-n7-IIz" id="oDQ-s9-30j"/>
-                            <outlet property="delegate" destination="vca-n7-IIz" id="1ab-Sp-XUo"/>
-                        </connections>
-                    </tableView>
-                </tableViewController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="BsJ-MF-U6v" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="6836" y="297"/>
-        </scene>
         <!--Favorites-->
         <scene sceneID="33n-4d-goO">
             <objects>

+ 120 - 11
iOSClient/Main/MainMenu/MainMenuManager.swift

@@ -8,18 +8,127 @@
 
 import FloatingPanel
 
-@objc class MainMenuManager: NSObject {
-    
-    
-    @objc public static let sharedInstance = MainMenuManager()
-    
-    private override init(){
-    
+extension AppDelegate {
+
+    private func initMenu() -> [MenuAction] {
+        var actions = [MenuAction]()
+        let appDelegate = UIApplication.shared.delegate as! AppDelegate
+        var isNextcloudTextAvailable = false
+
+        if appDelegate.reachability.isReachable() && NCBrandBeta.shared.directEditing && NCManageDatabase.sharedInstance.getDirectEditingCreators(account: appDelegate.activeAccount) != nil {
+            isNextcloudTextAvailable = true
+        }
+
+        actions.append(MenuAction(title: NSLocalizedString("_upload_photos_videos_", comment: ""), icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "file_photo"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon), action: { menuAction in
+                appDelegate.activeMain.openAssetsPickerController()
+            }))
+
+        actions.append(MenuAction(title: NSLocalizedString("_upload_file_", comment: ""), icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "file"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
+            action: { menuAction in
+                appDelegate.activeMain.openImportDocumentPicker()
+            }))
+
+        if NCBrandOptions.sharedInstance.use_imi_viewer {
+            actions.append(MenuAction(title: NSLocalizedString("_im_create_new_file", tableName: "IMLocalizable", bundle: Bundle.main, value: "", comment: ""), icon: CCGraphics.scale(UIImage.init(named: "imagemeter"), to: CGSize(width: 25, height: 25), isAspectRation: true), action: { menuAction in
+                    _ = IMCreate.init(serverUrl: appDelegate.activeMain.serverUrl)
+                }))
+        }
+
+        if isNextcloudTextAvailable {
+            actions.append(MenuAction(title: NSLocalizedString("_create_nextcloudtext_document_", comment: ""), icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "file_txt"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon), action: { menuAction in
+                    guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
+                        return
+                    }
+                    navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+
+                    let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                    viewController.typeTemplate = k_nextcloudtext_document
+                    viewController.serverUrl = appDelegate.activeMain.serverUrl
+                    viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
+
+                    appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+                }))
+        } else {
+            actions.append(MenuAction(title: NSLocalizedString("_upload_file_text_", comment: ""), icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "file_txt"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon), action: { menuAction in
+                    let storyboard = UIStoryboard(name: "NCText", bundle: nil)
+                    let controller = storyboard.instantiateViewController(withIdentifier: "NCText")
+                    controller.modalPresentationStyle = UIModalPresentationStyle.pageSheet
+                    appDelegate.activeMain.present(controller, animated: true, completion: nil)
+                }))
+        }
+
+        #if !targetEnvironment(simulator)
+            if #available(iOS 11.0, *) {
+                actions.append(MenuAction(title: NSLocalizedString("_scans_document_", comment: ""), icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "scan"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)), action: { menuAction in
+                        if #available(iOS 11.0, *) {
+                            NCCreateScanDocument.sharedInstance.openScannerDocument(viewController: appDelegate.activeMain)
+                        }
+                    })
+            }
+        #endif
+
+        actions.append(MenuAction(title: NSLocalizedString("_create_voice_memo_", comment: ""), icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "microphone"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon), action: { menuAction in
+                NCMainCommon.sharedInstance.startAudioRecorder()
+            }))
+
+        actions.append(MenuAction(title: NSLocalizedString("_create_folder_", comment: ""), icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 50, height: 50, color: NCBrandColor.sharedInstance.brandElement), action: { menuAction in
+                appDelegate.activeMain.createFolder()
+            }))
+
+        if let richdocumentsMimetypes = NCManageDatabase.sharedInstance.getRichdocumentsMimetypes(account: appDelegate.activeAccount) {
+            if richdocumentsMimetypes.count > 0 {
+                actions.append(MenuAction(title: NSLocalizedString("_create_new_document_", comment: ""), icon: UIImage.init(named: "create_file_document")!,
+                    action: { menuAction in
+                        guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
+                            return
+                        }
+                        navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+
+                        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                        viewController.typeTemplate = k_richdocument_document
+                        viewController.serverUrl = appDelegate.activeMain.serverUrl
+                        viewController.titleForm = NSLocalizedString("_create_new_document_", comment: "")
+
+                        appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+                    }))
+                actions.append(MenuAction(title: NSLocalizedString("_create_new_spreadsheet_", comment: ""), icon: UIImage(named: "create_file_xls")!,
+                    action: { menuAction in
+                        guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
+                            return
+                        }
+                        navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+
+                        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                        viewController.typeTemplate = k_richdocument_spreadsheet
+                        viewController.serverUrl = appDelegate.activeMain.serverUrl
+                        viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
+
+                        appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+                    }))
+                actions.append(MenuAction(title: NSLocalizedString("_create_new_presentation_", comment: ""), icon: UIImage(named: "create_file_ppt")!,
+                    action: { menuAction in
+                        guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
+                            return
+                        }
+                        navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+
+                        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                        viewController.typeTemplate = k_richdocument_presentation
+                        viewController.serverUrl = appDelegate.activeMain.serverUrl
+                        viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
+
+                        appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+                    }))
+            }
+        }
+
+        return actions
     }
-    
-    @objc public func showMenuIn(viewController: UIViewController){
-        let mainMenuViewController = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MainMenuTableViewController") as! MainMenuTableViewController
-        
+
+    @objc public func showMenuIn(viewController: UIViewController) {
+        let mainMenuViewController = UIStoryboard.init(name: "Menu", bundle: nil).instantiateViewController(withIdentifier: "MainMenuTableViewController") as! MainMenuTableViewController
+        mainMenuViewController.actions = self.initMenu()
+
         let fpc = FloatingPanelController()
         fpc.surfaceView.grabberHandle.isHidden = true
         fpc.delegate = mainMenuViewController

+ 29 - 135
iOSClient/Main/MainMenu/MainMenuTableViewController.swift

@@ -9,132 +9,18 @@
 import UIKit
 import FloatingPanel
 
-class MainMenuTableViewController: UITableViewController{
-    
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    var isNextcloudTextAvailable = false
+class MainMenuTableViewController: UITableViewController {
+
     var actions = [MenuAction]()
 
     override func viewDidLoad() {
         super.viewDidLoad()
-        
-        if self.appDelegate.reachability.isReachable() && NCBrandBeta.shared.directEditing && NCManageDatabase.sharedInstance.getDirectEditingCreators(account: self.appDelegate.activeAccount) != nil {
-            isNextcloudTextAvailable = true
-        }
-        
-        actions.append(MenuAction(title: NSLocalizedString("_upload_photos_videos_", comment: ""), value: 10, icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "file_photo"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
-        
-        actions.append(MenuAction(title: NSLocalizedString("_upload_file_", comment: ""), value: 20, icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "file"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
-        
-        if NCBrandOptions.sharedInstance.use_imi_viewer {
-            actions.append(MenuAction(title: NSLocalizedString("_im_create_new_file", tableName: "IMLocalizable", bundle: Bundle.main, value: "", comment: ""), value: 21, icon: CCGraphics.scale(UIImage.init(named: "imagemeter"), to: CGSize(width: 25, height: 25), isAspectRation: true)))
-        }
-        
-        if isNextcloudTextAvailable {
-            actions.append(MenuAction(title: NSLocalizedString("_create_nextcloudtext_document_", comment: ""), value: 31, icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "file_txt"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
-        } else {
-            actions.append(MenuAction(title: NSLocalizedString("_upload_file_text_", comment: ""), value: 30, icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "file_txt"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
-        }
-        
-        #if !targetEnvironment(simulator)
-                if #available(iOS 11.0, *) {
-                    actions.append(MenuAction(title: NSLocalizedString("_scans_document_", comment: ""), value: 40, icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "scan"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
-                }
-        #endif
-        
-        actions.append(MenuAction(title: NSLocalizedString("_create_voice_memo_", comment: ""), value: 50, icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "microphone"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
-
-        actions.append(MenuAction(title: NSLocalizedString("_create_folder_", comment: ""), value: 60, icon: CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 50, height: 50, color: NCBrandColor.sharedInstance.brandElement)))
-        
-        if let richdocumentsMimetypes = NCManageDatabase.sharedInstance.getRichdocumentsMimetypes(account: appDelegate.activeAccount) {
-            if richdocumentsMimetypes.count > 0 {
-                actions.append(MenuAction(title: NSLocalizedString("_create_new_document_", comment: ""), value: 70, icon: UIImage.init(named: "create_file_document")!))
-                actions.append(MenuAction(title: NSLocalizedString("_create_new_spreadsheet_", comment: ""), value: 80, icon: UIImage(named: "create_file_xls")!))
-                actions.append(MenuAction(title: NSLocalizedString("_create_new_presentation_", comment: ""), value: 90, icon: UIImage(named: "create_file_ppt")!))
-            }
-        }
     }
-    
+
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        let action = actions[indexPath.row]
-        
+        let menuAction = actions[indexPath.row]
         self.dismiss(animated: true, completion: nil)
-        if action.value == 10 {
-            self.appDelegate.activeMain.openAssetsPickerController()
-        }
-        if action.value == 20 { self.appDelegate.activeMain.openImportDocumentPicker() }
-        if action.value == 21 {
-            _ = IMCreate.init(serverUrl: self.appDelegate.activeMain.serverUrl)
-        }
-        if action.value == 30 {
-            let storyboard = UIStoryboard(name: "NCText", bundle: nil)
-            let controller = storyboard.instantiateViewController(withIdentifier: "NCText")
-            controller.modalPresentationStyle = UIModalPresentationStyle.pageSheet
-            self.appDelegate.activeMain.present(controller, animated: true, completion: nil)
-        }
-        if action.value == 31 {
-            guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
-                return
-            }
-            navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-            
-            let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-            viewController.typeTemplate = k_nextcloudtext_document
-            viewController.serverUrl = self.appDelegate.activeMain.serverUrl
-            viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
-            
-            self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
-        }
-        if action.value == 40 {
-            if #available(iOS 11.0, *) {
-                NCCreateScanDocument.sharedInstance.openScannerDocument(viewController: self.appDelegate.activeMain)
-            }
-        }
-        
-        if action.value == 50 { NCMainCommon.sharedInstance.startAudioRecorder() }
-        
-        if action.value == 60 { self.appDelegate.activeMain.createFolder() }
-        
-        if action.value == 70 {
-            guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
-                return
-            }
-            navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-            
-            let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-            viewController.typeTemplate = k_richdocument_document
-            viewController.serverUrl = self.appDelegate.activeMain.serverUrl
-            viewController.titleForm = NSLocalizedString("_create_new_document_", comment: "")
-            
-            self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
-        }
-        if action.value == 80 {
-            guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
-                return
-            }
-            navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-            
-            let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-            viewController.typeTemplate = k_richdocument_spreadsheet
-            viewController.serverUrl = self.appDelegate.activeMain.serverUrl
-            viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
-            
-            self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
-        }
-        if action.value == 90 {
-            guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
-                return
-            }
-            navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-            
-            let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-            viewController.typeTemplate = k_richdocument_presentation
-            viewController.serverUrl = self.appDelegate.activeMain.serverUrl
-            viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
-            
-            self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
-        }
-                
+        menuAction.action?(menuAction)
     }
 
     // MARK: - Table view data source
@@ -149,24 +35,32 @@ class MainMenuTableViewController: UITableViewController{
 
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCell(withIdentifier: "menuActionCell", for: indexPath)
-        
+        cell.tintColor = NCBrandColor.sharedInstance.customer
         let action = actions[indexPath.row]
         let actionIconView = cell.viewWithTag(1) as! UIImageView
         let actionNameLabel = cell.viewWithTag(2) as! UILabel
-            
-        actionIconView.image = action.icon
-        actionNameLabel.text = action.title
-            
+
+        if (action.isOn) {
+            actionIconView.image = action.onIcon
+            actionNameLabel.text = action.onTitle
+        } else {
+            actionIconView.image = action.icon
+            actionNameLabel.text = action.title
+        }
+
+        cell.accessoryType = action.selectable && action.selected ? .checkmark : .none
+
+
         return cell
     }
 
 }
-extension MainMenuTableViewController: FloatingPanelControllerDelegate{
-    
+extension MainMenuTableViewController: FloatingPanelControllerDelegate {
+
     func floatingPanel(_ vc: FloatingPanelController, layoutFor newCollection: UITraitCollection) -> FloatingPanelLayout? {
         return MainMenuFloatingPanelLayout(height: self.actions.count * 60)
     }
-    
+
     func floatingPanel(_ vc: FloatingPanelController, behaviorFor newCollection: UITraitCollection) -> FloatingPanelBehavior? {
         return MainMenuFloatingPanelBehavior()
     }
@@ -174,21 +68,21 @@ extension MainMenuTableViewController: FloatingPanelControllerDelegate{
 }
 
 class MainMenuFloatingPanelLayout: FloatingPanelLayout {
-    
+
     let height: CGFloat
-    
-    init(height: Int){
+
+    init(height: Int) {
         self.height = CGFloat(height)
     }
-    
+
     var initialPosition: FloatingPanelPosition {
         return .tip
     }
-    
+
     var supportedPositions: Set<FloatingPanelPosition> {
         return [.half]
     }
-    
+
     func insetFor(position: FloatingPanelPosition) -> CGFloat? {
         switch position {
         case .half: return height
@@ -196,7 +90,7 @@ class MainMenuFloatingPanelLayout: FloatingPanelLayout {
         default: return nil
         }
     }
-    
+
 
     func backdropAlphaFor(position: FloatingPanelPosition) -> CGFloat {
         return 0.5
@@ -206,7 +100,7 @@ class MainMenuFloatingPanelLayout: FloatingPanelLayout {
 public class MainMenuFloatingPanelBehavior: FloatingPanelBehavior {
 
     public func addAnimator(_ fpc: FloatingPanelController, to: FloatingPanelPosition) -> UIViewPropertyAnimator {
-        return UIViewPropertyAnimator(duration: 0.1, curve: .easeInOut)
+        return UIViewPropertyAnimator(duration: 0.3, curve: .easeInOut)
     }
 
     public func removeAnimator(_ fpc: FloatingPanelController, from: FloatingPanelPosition) -> UIViewPropertyAnimator {

+ 61 - 0
iOSClient/Main/MainMenu/Menu.storyboard

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina6_1" orientation="portrait" appearance="light"/>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--Main Menu Table View Controller-->
+        <scene sceneID="ibU-BJ-tlj">
+            <objects>
+                <tableViewController storyboardIdentifier="MainMenuTableViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="dbT-V0-aXb" customClass="MainMenuTableViewController" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="60" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="pvY-CD-sI6">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
+                        <prototypes>
+                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="menuActionCell" rowHeight="60" id="MT1-Lu-9SA">
+                                <rect key="frame" x="0.0" y="28" width="414" height="60"/>
+                                <autoresizingMask key="autoresizingMask"/>
+                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="MT1-Lu-9SA" id="tmT-MO-Dwy">
+                                    <rect key="frame" x="0.0" y="0.0" width="414" height="60"/>
+                                    <autoresizingMask key="autoresizingMask"/>
+                                    <subviews>
+                                        <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="1" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="RV0-3K-eSN">
+                                            <rect key="frame" x="16" y="16" width="28" height="28"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="28" id="7je-2C-oH0"/>
+                                                <constraint firstAttribute="width" constant="28" id="gxY-bI-V0v"/>
+                                            </constraints>
+                                        </imageView>
+                                        <label opaque="NO" userInteractionEnabled="NO" tag="2" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A8f-xF-j3i">
+                                            <rect key="frame" x="60" y="19.5" width="326" height="21"/>
+                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                            <nil key="textColor"/>
+                                            <nil key="highlightedColor"/>
+                                        </label>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstItem="A8f-xF-j3i" firstAttribute="leading" secondItem="RV0-3K-eSN" secondAttribute="trailing" constant="16" id="ADH-SJ-JNh"/>
+                                        <constraint firstItem="RV0-3K-eSN" firstAttribute="leading" secondItem="tmT-MO-Dwy" secondAttribute="leading" constant="16" id="QQt-st-4hA"/>
+                                        <constraint firstItem="RV0-3K-eSN" firstAttribute="centerY" secondItem="tmT-MO-Dwy" secondAttribute="centerY" id="R6O-om-tEz"/>
+                                        <constraint firstAttribute="trailingMargin" secondItem="A8f-xF-j3i" secondAttribute="trailing" constant="8" id="fia-KH-ier"/>
+                                        <constraint firstItem="A8f-xF-j3i" firstAttribute="centerY" secondItem="tmT-MO-Dwy" secondAttribute="centerY" id="kPV-bd-AAL"/>
+                                    </constraints>
+                                </tableViewCellContentView>
+                            </tableViewCell>
+                        </prototypes>
+                        <connections>
+                            <outlet property="dataSource" destination="dbT-V0-aXb" id="sZc-Dc-wQl"/>
+                            <outlet property="delegate" destination="dbT-V0-aXb" id="nv8-45-MsJ"/>
+                        </connections>
+                    </tableView>
+                </tableViewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="C45-Hv-vwv" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="-630" y="-129"/>
+        </scene>
+    </scenes>
+</document>

+ 22 - 5
iOSClient/Main/MainMenu/MenuAction.swift

@@ -9,14 +9,31 @@
 import Foundation
 
 class MenuAction {
-    
+
     let title: String
     let icon: UIImage
-    let value: Int
-    
-    init(title: String, value: Int, icon: UIImage) {
+    let selectable: Bool
+    var onTitle: String?
+    var onIcon: UIImage?
+    var selected: Bool = false
+    var isOn: Bool = false
+    var action: ((_ menuAction: MenuAction) -> Void)?
+
+    init(title: String, icon: UIImage, action: ((_ menuAction: MenuAction) -> Void)?) {
+        self.title = title
+        self.icon = icon
+        self.action = action
+        self.selectable = false
+    }
+
+    init(title: String, icon: UIImage, onTitle: String? = nil, onIcon: UIImage? = nil, selected: Bool, on: Bool, action: ((_ menuAction: MenuAction) -> Void)?) {
         self.title = title
         self.icon = icon
-        self.value = value
+        self.onTitle = onTitle ?? title
+        self.onIcon = onIcon ?? icon
+        self.action = action
+        self.selected = selected
+        self.isOn = on
+        self.selectable = true
     }
 }