Skip to content

Commit

Permalink
feat: Add to my kDrive floating action.
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Dec 12, 2024
1 parent 384b52d commit abd2bae
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ extension FileActionsFloatingPanelViewController {
leaveShareAction()
case .cancelImport:
cancelImportAction()
case .addToMyDrive:
addToMyKDrive()
default:
break
}
Expand Down Expand Up @@ -520,4 +522,32 @@ extension FileActionsFloatingPanelViewController {
}
}
}

private func addToMyKDrive() {
guard accountManager.currentAccount != nil else {
let upsaleFloatingPanelController = UpsaleViewController.instantiateInFloatingPanel(rootViewController: self)
present(upsaleFloatingPanelController, animated: true, completion: nil)
return
}

guard let currentUserDriveFileManager = accountManager.currentDriveFileManager,
let publicShareProxy = driveFileManager.publicShareProxy else {
return
}

let itemId = [file.id]
let saveViewController = SaveFileViewController.instantiate(driveFileManager: currentUserDriveFileManager)
let saveNavigationViewController = SaveFileViewController
.setInNavigationController(saveViewController: saveViewController)

saveViewController.completionClosure = { [weak self] in
guard let self else { return }
self.dismiss(animated: true)
}

saveViewController.publicShareFileIds = itemId
saveViewController.publicShareProxy = publicShareProxy

present(saveNavigationViewController, animated: true, completion: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ public class FloatingPanelAction: Equatable {
image: KDriveResourcesAsset.colorBucket.image
)

static let addToMyDrive = FloatingPanelAction(
id: 22,
name: KDriveResourcesStrings.Localizable.buttonAddToKDrive,
image: KDriveResourcesAsset.drive.image
)

static var quickActions: [FloatingPanelAction] {
return [informations, sendCopy, shareAndRights, shareLink].map { $0.reset() }
}
Expand All @@ -213,7 +219,7 @@ public class FloatingPanelAction: Equatable {
}

static var publicShareActions: [FloatingPanelAction] {
return [openWith, sendCopy, download].map { $0.reset() }
return [openWith, sendCopy, download, addToMyDrive].map { $0.reset() }
}

static var publicShareFolderActions: [FloatingPanelAction] {
Expand Down
4 changes: 0 additions & 4 deletions kDrive/UI/Controller/Menu/Share/PublicShareViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ final class PublicShareViewModel: InMemoryFileListViewModel {
}

private func addToMyDrive(sender: Any?, publicShareProxy: PublicShareProxy) {
guard let currentUserDriveFileManager = accountManager.currentDriveFileManager else {
return
}

let selectedItemsIds = multipleSelectionViewModel?.selectedItems.map(\.id) ?? [] + [rootProxy.id]
let exceptItemIds = multipleSelectionViewModel?.exceptItemIds.map { $0 } ?? []

Expand Down

0 comments on commit abd2bae

Please sign in to comment.