marinofaggiana 4 vuotta sitten
vanhempi
commit
ede2f454dc

+ 0 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -276,7 +276,6 @@
 		F7BAADCB1ED5A87C00B7EAD4 /* NCManageDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB51ED5A87C00B7EAD4 /* NCManageDatabase.swift */; };
 		F7BAADCC1ED5A87C00B7EAD4 /* NCManageDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB51ED5A87C00B7EAD4 /* NCManageDatabase.swift */; };
 		F7BF1B431D51E893000854F6 /* CCLogin.m in Sources */ = {isa = PBXBuildFile; fileRef = F7BF1B401D51E893000854F6 /* CCLogin.m */; };
-		F7C174DD25E509EE004078E4 /* NCChangeUserMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C174DC25E509EE004078E4 /* NCChangeUserMenu.swift */; };
 		F7C1EEA525053A9C00866ACC /* NCDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C1EEA425053A9C00866ACC /* NCDataSource.swift */; };
 		F7C40BEF219994ED0004137E /* KTVCocoaHTTPServer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7C40BEE219994ED0004137E /* KTVCocoaHTTPServer.framework */; };
 		F7C40BF1219994F20004137E /* KTVHTTPCache.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7C40BF0219994F20004137E /* KTVHTTPCache.framework */; };
@@ -644,7 +643,6 @@
 		F7BF1B401D51E893000854F6 /* CCLogin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCLogin.m; sourceTree = "<group>"; };
 		F7C0F46E1C8880540059EC54 /* ShareViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = ShareViewController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
 		F7C0F46F1C8880540059EC54 /* ShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ShareViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
-		F7C174DC25E509EE004078E4 /* NCChangeUserMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCChangeUserMenu.swift; sourceTree = "<group>"; };
 		F7C1EEA425053A9C00866ACC /* NCDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCDataSource.swift; sourceTree = "<group>"; };
 		F7C40BE221998C050004137E /* PDFGenerator.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PDFGenerator.framework; path = Carthage/Build/iOS/PDFGenerator.framework; sourceTree = "<group>"; };
 		F7C40BE421998D5A0004137E /* MGSwipeTableCell.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MGSwipeTableCell.framework; path = Carthage/Build/iOS/MGSwipeTableCell.framework; sourceTree = "<group>"; };
@@ -800,7 +798,6 @@
 			isa = PBXGroup;
 			children = (
 				3781B9AF23DB2B7E006B4B1D /* AppDelegate+Menu.swift */,
-				F7C174DC25E509EE004078E4 /* NCChangeUserMenu.swift */,
 				F77A697C250A0FBC00FF1708 /* NCCollectionViewCommon+Menu.swift */,
 				F7CBC31B24F78E79004D3812 /* NCSortMenu.swift */,
 				F710D2012405826100A6033D /* NCViewer+Menu.swift */,
@@ -2113,7 +2110,6 @@
 				F7725A60251F33BB00D125E0 /* NCFiles.swift in Sources */,
 				F704B5E52430AA8000632F5F /* NCCreateFormUploadConflict.swift in Sources */,
 				F765608F23BF813600765969 /* NCContentPresenter.swift in Sources */,
-				F7C174DD25E509EE004078E4 /* NCChangeUserMenu.swift in Sources */,
 				F70CEF5623E9C7E50007035B /* UIColor+Extensions.swift in Sources */,
 				F75AC2431F1F62450073EC19 /* NCManageAutoUploadFileName.swift in Sources */,
 				F7C7B489245EBA4100D93E60 /* NCViewerQuickLook.swift in Sources */,

+ 58 - 0
iOSClient/Login/NCLoginWeb.swift

@@ -24,6 +24,7 @@
 import Foundation
 import WebKit
 import NCCommunication
+import FloatingPanel
 
 class NCLoginWeb: UIViewController {
     
@@ -38,6 +39,8 @@ class NCLoginWeb: UIViewController {
     @objc var loginFlowV2Endpoint = ""
     @objc var loginFlowV2Login = ""
     
+    // MARK: - Life Cycle
+    
     override func viewDidLoad() {
         super.viewDidLoad()
         
@@ -117,6 +120,61 @@ class NCLoginWeb: UIViewController {
     
     @objc func changeUser(sender: UIBarButtonItem) {
         
+        let mainMenuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateViewController(withIdentifier: "NCMainMenuTableViewController") as! NCMainMenuTableViewController
+        mainMenuViewController.actions = self.initUsersMenu()
+
+        let menuPanelController = NCMenuPanelController()
+        menuPanelController.parentPresenter = self
+        menuPanelController.delegate = mainMenuViewController
+        menuPanelController.set(contentViewController: mainMenuViewController)
+        menuPanelController.track(scrollView: mainMenuViewController.tableView)
+
+        self.present(menuPanelController, animated: true, completion: nil)
+    }
+    
+    // MARK: -
+    
+    private func initUsersMenu() -> [NCMenuAction] {
+        
+        var actions = [NCMenuAction]()
+        let accounts = NCManageDatabase.shared.getAllAccount()
+        var avatar = UIImage(named: "avatarCredentials")!.image(color: NCBrandColor.shared.icon, size: 50)
+        
+        for account in accounts {
+            
+            var fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(account.user, urlBase: account.urlBase) + "_" + account.user
+            fileNamePath = fileNamePath + ".png"
+            if var userImage = UIImage(contentsOfFile: fileNamePath) {
+                userImage = userImage.resizeImage(size: CGSize(width: 50, height: 50), isAspectRation: true)!
+                let userImageView = UIImageView(image: userImage)
+                userImageView.avatar(roundness: 2, borderWidth: 1, borderColor: NCBrandColor.shared.avatarBorder, backgroundColor: .clear)
+                UIGraphicsBeginImageContext(userImageView.bounds.size)
+                userImageView.layer.render(in: UIGraphicsGetCurrentContext()!)
+                if let newAvatar = UIGraphicsGetImageFromCurrentImageContext() {
+                    avatar = newAvatar
+                }
+                UIGraphicsEndImageContext()
+            }
+            
+            actions.append(
+                NCMenuAction(
+                    title: account.account,
+                    icon: avatar,
+                    onTitle: account.account,
+                    onIcon: avatar,
+                    selected: account.active == true,
+                    on: account.active == true,
+                    action: { menuAction in
+                        self.dismiss(animated: true) {
+                            self.appDelegate.settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account))
+                            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                        }
+                    }
+                )
+            )
+        }
+       
+        return actions
     }
 }
 

+ 0 - 82
iOSClient/Main/Menu/NCChangeUserMenu.swift

@@ -1,82 +0,0 @@
-//
-//  NCChangeUserMenu.swift
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 23/02/2021.
-//  Copyright © 2020 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-import FloatingPanel
-import NCCommunication
-
-class NCChangeUserMenu: NSObject {
-    
-    @objc func toggleMenu(viewController: UIViewController) {
-        
-        let mainMenuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateViewController(withIdentifier: "NCMainMenuTableViewController") as! NCMainMenuTableViewController
-        mainMenuViewController.actions = self.initUsersMenu()
-
-        let menuPanelController = NCMenuPanelController()
-        menuPanelController.parentPresenter = viewController
-        menuPanelController.delegate = mainMenuViewController
-        menuPanelController.set(contentViewController: mainMenuViewController)
-        menuPanelController.track(scrollView: mainMenuViewController.tableView)
-
-        viewController.present(menuPanelController, animated: true, completion: nil)
-    }
-    
-    private func initUsersMenu() -> [NCMenuAction] {
-        
-        var actions = [NCMenuAction]()
-        let accounts = NCManageDatabase.shared.getAllAccount()
-        var avatar = UIImage(named: "avatarCredentials")!.image(color: NCBrandColor.shared.icon, size: 50)
-        
-        for account in accounts {
-            
-            var fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(account.user, urlBase: account.urlBase) + "_" + account.user
-            fileNamePath = fileNamePath + ".png"
-            if var userImage = UIImage(contentsOfFile: fileNamePath) {
-                userImage = userImage.resizeImage(size: CGSize(width: 50, height: 50), isAspectRation: true)!
-                let userImageView = UIImageView(image: userImage)
-                userImageView.avatar(roundness: 2, borderWidth: 1, borderColor: NCBrandColor.shared.avatarBorder, backgroundColor: .clear)
-                UIGraphicsBeginImageContext(userImageView.bounds.size)
-                userImageView.layer.render(in: UIGraphicsGetCurrentContext()!)
-                if let newAvatar = UIGraphicsGetImageFromCurrentImageContext() {
-                    avatar = newAvatar
-                }
-                UIGraphicsEndImageContext()
-            }
-            
-            actions.append(
-                NCMenuAction(
-                    title: account.account,
-                    icon: avatar,
-                    onTitle: account.account,
-                    onIcon: avatar,
-                    selected: account.active == true,
-                    on: account.active == true,
-                    action: { menuAction in
-                        
-                    }
-                )
-            )
-        }
-       
-        return actions
-    }
-}