12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import UIKit
- import FloatingPanel
- extension NCLoginWeb {
- func toggleMenu() {
-
- var actions = [NCMenuAction]()
-
- let accounts = NCManageDatabase.shared.getAllAccount()
- var avatar = NCUtility.shared.loadImage(named: "person.crop.circle")
-
- for account in accounts {
-
- let title = account.user + " " + (URL(string: account.urlBase)?.host ?? "")
- avatar = NCUtility.shared.loadUserImage(
- for: account.user,
- displayName: account.displayName,
- userBaseUrl: account)
- actions.append(
- NCMenuAction(
- title: title,
- icon: avatar,
- onTitle: title,
- onIcon: avatar,
- selected: account.active == true,
- on: account.active == true,
- action: { menuAction in
- if self.appDelegate.account != account.account {
- NCManageDatabase.shared.setAccountActive(account.account)
- 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.notificationCenterInitialize)
- }
- }
- }
- )
- )
- }
- actions.append(
- NCMenuAction(
- title: NSLocalizedString("_delete_active_account_", comment: ""),
- icon: NCUtility.shared.loadImage(named: "trash", color: NCBrandColor.shared.gray),
- onTitle: NSLocalizedString("_delete_active_account_", comment: ""),
- onIcon: avatar,
- selected: false,
- on: false,
- action: { menuAction in
- self.appDelegate.deleteAccount(self.appDelegate.account, wipe: false)
- self.dismiss(animated: true) {
- let accounts = NCManageDatabase.shared.getAllAccount()
- if accounts.count > 0 {
- self.appDelegate.changeAccount(accounts.first!.account)
- } else {
- self.appDelegate.openLogin(viewController: nil, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
- }
- }
- }
- )
- )
- presentMenu(with: actions)
- }
- }
|