Skip to content

Commit

Permalink
chore: Merge branch 'feature-externalLinks' into externalLinks-famous…
Browse files Browse the repository at this point in the history
…LastFivePercent

refactor: More changes than usual for a merge as this brings back the multiple selection branch
  • Loading branch information
adrien-coye committed Jan 7, 2025
2 parents 2c1fbf4 + 7df9df3 commit 5604594
Show file tree
Hide file tree
Showing 25 changed files with 720 additions and 445 deletions.
4 changes: 2 additions & 2 deletions Tuist/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Infomaniak/ios-login",
"state" : {
"revision" : "b12bf4fbbfe0edf10d2516503e97a9f212d1cd5b",
"version" : "7.0.1"
"revision" : "b7791f1321c86a9aa0e52eb79acb5c6318a3810a",
"version" : "7.1.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Tuist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
.package(url: "https://github.com/Alamofire/Alamofire", .upToNextMajor(from: "5.2.2")),
.package(url: "https://github.com/Infomaniak/ios-core", .upToNextMajor(from: "13.0.0")),
.package(url: "https://github.com/Infomaniak/ios-core-ui", .upToNextMajor(from: "16.0.0")),
.package(url: "https://github.com/Infomaniak/ios-login", .upToNextMajor(from: "7.0.1")),
.package(url: "https://github.com/Infomaniak/ios-login", .upToNextMajor(from: "7.1.0")),
.package(url: "https://github.com/Infomaniak/ios-dependency-injection", .upToNextMajor(from: "2.0.0")),
.package(url: "https://github.com/Infomaniak/swift-concurrency", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/Infomaniak/ios-version-checker", .upToNextMajor(from: "8.0.0")),
Expand Down
30 changes: 15 additions & 15 deletions kDrive/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
Task {
try! await Task.sleep(nanoseconds: 5_000_000_000)

// @InjectService var router: AppNavigable
// //let upsaleViewController = UpsaleViewController()
// let noDriveViewController = NoDriveUpsaleViewController()
// let floatingPanel = UpsaleFloatingPanelController(upsaleViewController: noDriveViewController)
// router.topMostViewController?.present(floatingPanel, animated: true, completion: nil)

/* Temp code to test out the feature. TODO: Remove later
// a public share expired
let somePublicShare =
URL(string: "https://kdrive.infomaniak.com/app/share/140946/81de098a-3156-4ae6-93df-be7f9ae78ddd")
// a public share password protected
// let somePublicShare = URL(string:
// "https://kdrive.infomaniak.com/app/share/140946/34844cea-db8d-4d87-b66f-e944e9759a2e")

await UniversalLinksHelper.handleURL(somePublicShare!)
/* TODO: Remove later
@InjectService var router: AppNavigable
let upsaleViewController = UpsaleViewController()
let noDriveViewController = NoDriveUpsaleViewController()
let floatingPanel = UpsaleFloatingPanelController(upsaleViewController: noDriveViewController)
router.topMostViewController?.present(floatingPanel, animated: true, completion: nil)
*/

/* TODO: Remove later
// a public share expired
let somePublicShareExpired =
URL(string: "https://kdrive.infomaniak.com/app/share/140946/81de098a-3156-4ae6-93df-be7f9ae78ddd")
// a public share password protected
let somePublicShareProtected =
URL(string: "https://kdrive.infomaniak.com/app/share/140946/34844cea-db8d-4d87-b66f-e944e9759a2e")
*/

// a valid public share
Expand Down
14 changes: 13 additions & 1 deletion kDrive/AppRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,23 @@ public struct AppRouter: AppNavigable {
}

rootViewController.dismiss(animated: false) {
let configuration = FileListViewModel.Configuration(selectAllSupported: true,
rootTitle: nil,
emptyViewType: .emptyFolder,
supportsDrop: false,
leftBarButtons: [.cancel],
rightBarButtons: [.downloadAll],
matomoViewPath: [
MatomoUtils.Views.menu.displayName,
"publicShare"
])

let viewModel = PublicShareViewModel(publicShareProxy: publicShareProxy,
sortType: .nameAZ,
driveFileManager: driveFileManager,
currentDirectory: frozenRootFolder,
apiFetcher: apiFetcher)
apiFetcher: apiFetcher,
configuration: configuration)
let viewController = FileListViewController(viewModel: viewModel)
viewModel.onDismissViewController = { [weak viewController] in
viewController?.dismiss(animated: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV
}

func setupFooterIfNeeded() {
guard driveFileManager.isPublicShare else {
return
}
guard driveFileManager.isPublicShare else { return }

view.addSubview(addToKDriveButton)
view.bringSubviewToFront(addToKDriveButton)
Expand Down Expand Up @@ -485,7 +483,7 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV
floatingPanelViewController.set(contentViewController: trashFloatingPanelTableViewController)
(floatingPanelViewController as? AdaptiveDriveFloatingPanelController)?
.trackAndObserve(scrollView: trashFloatingPanelTableViewController.tableView)
case .multipleSelection:
case .multipleSelection(let downloadOnly):
let allItemsSelected: Bool
let exceptFileIds: [Int]?
let selectedFiles: [File]
Expand All @@ -511,6 +509,10 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV
presentingParent: self
)

if downloadOnly {
selectViewController.actions = [.download]
}

floatingPanelViewController = AdaptiveDriveFloatingPanelController()
floatingPanelViewController.set(contentViewController: selectViewController)
(floatingPanelViewController as? AdaptiveDriveFloatingPanelController)?
Expand Down Expand Up @@ -656,6 +658,7 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV

func toggleMultipleSelection(_ on: Bool) {
if on {
addToKDriveButton.isHidden = true
navigationItem.title = nil
headerView?.selectView.isHidden = false
headerView?.selectView.setActions(viewModel.multipleSelectionViewModel?.multipleSelectionActions ?? [])
Expand All @@ -665,6 +668,7 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV
generator.prepare()
generator.impactOccurred()
} else {
addToKDriveButton.isHidden = false
headerView?.selectView.isHidden = true
collectionView.allowsMultipleSelection = false
navigationController?.navigationBar.prefersLargeTitles = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum FileListBarButtonType {
enum FileListQuickActionType {
case file
case trash
case multipleSelection
case multipleSelection(onlyDownload: Bool)
}

enum ControllerPresentationType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,48 @@ import kDriveCore
import kDriveResources

struct MultipleSelectionAction: Equatable {
let id: Int
private let id: MultipleSelectionActionId
let name: String
let icon: KDriveResourcesImages
var enabled = true

private enum MultipleSelectionActionId: Equatable {
case move
case delete
case more
case deletePermanently
case download
}

static func == (lhs: MultipleSelectionAction, rhs: MultipleSelectionAction) -> Bool {
return lhs.id == rhs.id
}

static let move = MultipleSelectionAction(
id: 0,
id: .move,
name: KDriveResourcesStrings.Localizable.buttonMove,
icon: KDriveResourcesAsset.folderSelect
)
static let delete = MultipleSelectionAction(
id: 1,
id: .delete,
name: KDriveResourcesStrings.Localizable.buttonDelete,
icon: KDriveResourcesAsset.delete
)
static let more = MultipleSelectionAction(
id: 2,
id: .more,
name: KDriveResourcesStrings.Localizable.buttonMenu,
icon: KDriveResourcesAsset.menu
)
static let deletePermanently = MultipleSelectionAction(
id: 3,
id: .deletePermanently,
name: KDriveResourcesStrings.Localizable.buttonDelete,
icon: KDriveResourcesAsset.delete
)
static let download = MultipleSelectionAction(
id: .download,
name: KDriveResourcesStrings.Localizable.buttonDownload,
icon: KDriveResourcesAsset.menu
)
}

@MainActor
Expand All @@ -67,6 +80,8 @@ class MultipleSelectionFileListViewModel {
leftBarButtons = [.cancel]
if configuration.selectAllSupported {
rightBarButtons = [.selectAll]
} else {
rightBarButtons = []
}
} else {
leftBarButtons = nil
Expand Down Expand Up @@ -108,14 +123,13 @@ class MultipleSelectionFileListViewModel {
isMultipleSelectionEnabled = false
selectedCount = 0

self.driveFileManager = driveFileManager

if driveFileManager.isPublicShare {
multipleSelectionActions = []
multipleSelectionActions = [.more]
} else {
multipleSelectionActions = [.move, .delete, .more]
}

self.driveFileManager = driveFileManager
self.currentDirectory = currentDirectory
self.configuration = configuration
}
Expand Down Expand Up @@ -168,7 +182,9 @@ class MultipleSelectionFileListViewModel {
}
onPresentViewController?(.modal, alert, true)
case .more:
onPresentQuickActionPanel?(Array(selectedItems), .multipleSelection)
onPresentQuickActionPanel?(Array(selectedItems), .multipleSelection(onlyDownload: false))
case .download:
onPresentQuickActionPanel?(Array(selectedItems), .multipleSelection(onlyDownload: true))
default:
break
}
Expand Down Expand Up @@ -208,7 +224,16 @@ class MultipleSelectionFileListViewModel {
onSelectAll?()
Task { [proxyCurrentDirectory = currentDirectory.proxify()] in
do {
let directoryCount = try await driveFileManager.apiFetcher.count(of: proxyCurrentDirectory)
let directoryCount: FileCount
if let publicShareProxy = driveFileManager.publicShareProxy {
directoryCount = try await PublicShareApiFetcher()
.countPublicShare(drive: publicShareProxy.proxyDrive,
linkUuid: publicShareProxy.shareLinkUid,
fileId: publicShareProxy.fileId)
} else {
directoryCount = try await driveFileManager.apiFetcher.count(of: proxyCurrentDirectory)
}

selectedCount = directoryCount.count
rightBarButtons = [.deselectAll]
} catch {
Expand Down
13 changes: 12 additions & 1 deletion kDrive/UI/Controller/Files/FilePresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,22 @@ final class FilePresenter {
if driveFileManager.drive.sharedWithMe {
viewModel = SharedWithMeViewModel(driveFileManager: driveFileManager, currentDirectory: file)
} else if let publicShareProxy = driveFileManager.publicShareProxy {
let configuration = FileListViewModel.Configuration(selectAllSupported: true,
rootTitle: nil,
emptyViewType: .emptyFolder,
supportsDrop: false,
rightBarButtons: [.downloadAll],
matomoViewPath: [
MatomoUtils.Views.menu.displayName,
"publicShare"
])

viewModel = PublicShareViewModel(publicShareProxy: publicShareProxy,
sortType: .nameAZ,
driveFileManager: driveFileManager,
currentDirectory: file,
apiFetcher: PublicShareApiFetcher())
apiFetcher: PublicShareApiFetcher(),
configuration: configuration)
} else if file.isTrashed || file.deletedAt != nil {
viewModel = TrashListViewModel(driveFileManager: driveFileManager, currentDirectory: file)
} else {
Expand Down
4 changes: 4 additions & 0 deletions kDrive/UI/Controller/Files/FloatingPanelAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ public class FloatingPanelAction: Equatable {
return [download].map { $0.reset() }
}

static var multipleSelectionPublicShareActions: [FloatingPanelAction] {
return [download].map { $0.reset() }
}

static var quickActions: [FloatingPanelAction] {
return [informations, sendCopy, shareAndRights, shareLink].map { $0.reset() }
}
Expand Down
Loading

0 comments on commit 5604594

Please sign in to comment.