Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iOSClient/Files/NCFilesNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class NCFilesNavigationController: NCMainNavigationController {
let action = UIAction(title: name, image: image, attributes: attributes, state: account.account == controller.account ? .on : .off) { _ in
Task { @MainActor in
await NCAccount().changeAccount(account.account, userProfile: nil, controller: self.controller)
self.collectionViewCommon?.setEditMode(false)
await self.collectionViewCommon?.setEditMode(false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ extension NCCollectionViewCommon: NCCollectionViewCommonSelectTabBarDelegate {

if canDeleteServer {
alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .destructive) { _ in
self.setEditMode(false)
Task {
await self.setEditMode(false)
await self.networking.setStatusWaitDelete(metadatas: metadatas, sceneIdentifier: self.controller?.sceneIdentifier)
await self.reloadDataSource()
}
Expand All @@ -42,29 +42,32 @@ extension NCCollectionViewCommon: NCCollectionViewCommonSelectTabBarDelegate {
for metadata in copyMetadatas where error == .success {
error = await self.networking.deleteCache(metadata, sceneIdentifier: self.controller?.sceneIdentifier)
}
await self.setEditMode(false)
}
self.setEditMode(false)
})

alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel) { (_: UIAlertAction) in })
self.present(alertController, animated: true, completion: nil)
}

func move() {
let metadatas = getSelectedMetadatas()
Task {
let metadatas = getSelectedMetadatas()
await setEditMode(false)

NCSelectOpen.shared.openView(items: metadatas, controller: self.controller)
}

NCSelectOpen.shared.openView(items: metadatas, controller: self.controller)
setEditMode(false)
}

func share() {
Task {
let metadatas = getSelectedMetadatas()
await setEditMode(false)
await NCCreate().createActivityViewController(
selectedMetadata: metadatas,
controller: self.controller,
sender: nil)
setEditMode(false)
}
}

Expand All @@ -80,8 +83,9 @@ extension NCCollectionViewCommon: NCCollectionViewCommonSelectTabBarDelegate {
for metadata in metadatas {
await NCNetworking.shared.setMetadataAvalableOffline(metadata, isOffline: isAnyOffline)
}
await self.setEditMode(false)
}
self.setEditMode(false)

}))
alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel))
self.present(alert, animated: true)
Expand All @@ -90,17 +94,19 @@ extension NCCollectionViewCommon: NCCollectionViewCommonSelectTabBarDelegate {
for metadata in metadatas {
await NCNetworking.shared.setMetadataAvalableOffline(metadata, isOffline: isAnyOffline)
}
await setEditMode(false)
}
setEditMode(false)
}
}

func lock(isAnyLocked: Bool) {
let metadatas = getSelectedMetadatas()
for metadata in metadatas where metadata.lock == isAnyLocked {
self.networking.lockUnlockFile(metadata, shoulLock: !isAnyLocked)
Task {
let metadatas = getSelectedMetadatas()
for metadata in metadatas where metadata.lock == isAnyLocked {
self.networking.lockUnlockFile(metadata, shoulLock: !isAnyLocked)
}
await setEditMode(false)
}
setEditMode(false)
}

func getSelectedMetadatas() -> [tableMetadata] {
Expand All @@ -112,24 +118,23 @@ extension NCCollectionViewCommon: NCCollectionViewCommonSelectTabBarDelegate {
return selectedMetadatas
}

func setEditMode(_ editMode: Bool) {
Task {
isEditMode = editMode
fileSelect.removeAll()

navigationItem.hidesBackButton = editMode
navigationController?.interactivePopGestureRecognizer?.isEnabled = !editMode
searchController(enabled: !editMode)
mainNavigationController?.hiddenPlusButton(editMode)

if editMode {
navigationItem.leftBarButtonItems = nil
} else {
await (self.navigationController as? NCMainNavigationController)?.setNavigationLeftItems()
}
await (self.navigationController as? NCMainNavigationController)?.setNavigationRightItems()
@MainActor
func setEditMode(_ editMode: Bool) async {
isEditMode = editMode
fileSelect.removeAll()

self.collectionView.reloadData()
navigationItem.hidesBackButton = editMode
navigationController?.interactivePopGestureRecognizer?.isEnabled = !editMode
searchController(enabled: !editMode)
mainNavigationController?.hiddenPlusButton(editMode)

if editMode {
navigationItem.leftBarButtonItems = nil
} else {
await (self.navigationController as? NCMainNavigationController)?.setNavigationLeftItems()
}
await (self.navigationController as? NCMainNavigationController)?.setNavigationRightItems()

self.collectionView.reloadData()
}
}
12 changes: 8 additions & 4 deletions iOSClient/Main/NCMainNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,9 @@ class NCMainNavigationController: UINavigationController, UINavigationController
collectionViewCommon.tabBarSelect?.show()

let select = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain) {
collectionViewCommon.setEditMode(false)
Task {
await collectionViewCommon.setEditMode(false)
}
}

collectionViewCommon.navigationItem.rightBarButtonItems = [select]
Expand Down Expand Up @@ -634,9 +636,11 @@ class NCMainNavigationController: UINavigationController, UINavigationController
let layoutForView = database.getLayoutForView(account: session.account, key: collectionViewCommon.layoutKey, serverUrl: collectionViewCommon.serverUrl)
let select = UIAction(title: NSLocalizedString("_select_", comment: ""),
image: utility.loadImage(named: "checkmark.circle")) { _ in
if !collectionViewCommon.dataSource.isEmpty() {
collectionViewCommon.setEditMode(true)
collectionViewCommon.collectionView.reloadData()
Task {
if !collectionViewCommon.dataSource.isEmpty() {
await collectionViewCommon.setEditMode(true)
collectionViewCommon.collectionView.reloadData()
}
}
}

Expand Down
Loading