Skip to content

Commit

Permalink
Merge branch 'converstion-quota-dropbox-view' into converstion-quota-…
Browse files Browse the repository at this point in the history
…dropbox-view-dashboard
  • Loading branch information
adrien-coye committed Feb 13, 2025
2 parents 5633fcb + e7da516 commit 791a863
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 32 deletions.
6 changes: 0 additions & 6 deletions kDrive/AppRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public struct AppRouter: AppNavigable {
restoreMainUIStackIfPossible(driveFileManager: driveFileManager, restoration: restoration)

showLaunchFloatingPanel()
askToUpSaleIfQuotaReached()

Task {
await askForReview()
Expand Down Expand Up @@ -514,11 +513,6 @@ public struct AppRouter: AppNavigable {
}
}

@MainActor public func askToUpSaleIfQuotaReached() {
// TODO: Check quota
presentUpSaleSheet()
}

@MainActor public func presentUpSaleSheet() {
guard let window,
let rootViewController = window.rootViewController else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ extension FileActionsFloatingPanelViewController {
}

private func convertToDropboxAction() {
if !file.capabilities.canBecomeDropbox {
guard file.capabilities.canBecomeDropbox else {
let driveFloatingPanelController = DropBoxFloatingPanelViewController.instantiatePanel()
let floatingPanelViewController = driveFloatingPanelController
.contentViewController as? DropBoxFloatingPanelViewController
Expand All @@ -295,15 +295,22 @@ extension FileActionsFloatingPanelViewController {
}
}
present(driveFloatingPanelController, animated: true)
} else {
let viewController = ManageDropBoxViewController.instantiate(
driveFileManager: driveFileManager,
convertingFolder: true,
folder: file
)
presentingParent?.navigationController?.pushViewController(viewController, animated: true)
dismiss(animated: true)
return
}

if packId == .myKSuite, driveFileManager.drive.dropboxQuotaExceeded {
router.presentUpSaleSheet()
return
}

let viewController = ManageDropBoxViewController.instantiate(
driveFileManager: driveFileManager,
convertingFolder: true,
folder: file
)

presentingParent?.navigationController?.pushViewController(viewController, animated: true)
dismiss(animated: true)
}

private func manageDropboxAction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,13 @@ final class FileActionsFloatingPanelViewController: UICollectionViewController {
case .actions:
let cell = collectionView.dequeueReusableCell(type: FloatingPanelActionCollectionViewCell.self, for: indexPath)
let action = actions[indexPath.item]
cell.configure(with: action, file: file, showProgress: downloadAction == action, currentPackId: packId)
cell.configure(
with: action,
file: file,
showProgress: downloadAction == action,
driveFileManager: driveFileManager,
currentPackId: packId
)
return cell
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,13 @@ final class MultipleSelectionFloatingPanelViewController: UICollectionViewContro
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(type: FloatingPanelActionCollectionViewCell.self, for: indexPath)
let action = actions[indexPath.item]
cell.configure(with: action, files: files, showProgress: downloadInProgress, archiveId: currentArchiveId)
cell.configure(
with: action,
files: files,
driveFileManager: driveFileManager,
showProgress: downloadInProgress,
archiveId: currentArchiveId
)
return cell
}

Expand Down
1 change: 0 additions & 1 deletion kDrive/UI/Controller/LoginDelegateHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public final class LoginDelegateHandler: InfomaniakLoginDelegate {
UserDefaults.shared.numberOfConnections = 1
_ = router.showMainViewController(driveFileManager: driveFileManager, selectedIndex: nil)
deeplinkService.processDeeplinksPostAuthentication()
router.askToUpSaleIfQuotaReached()
}

private func didCompleteLoginWithError(_ error: Error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class NewFolderTypeTableViewController: UITableViewController {
cell.titleLabel.text = KDriveResourcesStrings.Localizable.dropBoxTitle
cell.accessoryImageView.image = KDriveResourcesAsset.folderDropBox.image
cell.descriptionLabel.text = KDriveResourcesStrings.Localizable.dropBoxDescription
if packId == .myKSuite {
if packId == .myKSuite, driveFileManager.drive.dropboxQuotaExceeded {
cell.setMykSuiteChip()
}
}
Expand All @@ -114,7 +114,7 @@ class NewFolderTypeTableViewController: UITableViewController {

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if content[indexPath.row] == .dropbox {
if packId == .myKSuite {
if packId == .myKSuite, driveFileManager.drive.dropboxQuotaExceeded {
router.presentUpSaleSheet()
} else if !driveFileManager.drive.pack.capabilities.useDropbox {
let driveFloatingPanelController = DropBoxFloatingPanelViewController.instantiatePanel()
Expand All @@ -128,8 +128,9 @@ class NewFolderTypeTableViewController: UITableViewController {
}
}
present(driveFloatingPanelController, animated: true)
} else {
performSegue(withIdentifier: "toNewFolderSegue", sender: indexPath.row)
}
return
} else {
performSegue(withIdentifier: "toNewFolderSegue", sender: indexPath.row)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class FloatingPanelActionCollectionViewCell: UICollectionViewCell {

func configure(with action: FloatingPanelAction,
file: File?, showProgress: Bool,
driveFileManager: DriveFileManager,
currentPackId: DrivePackId? = nil) {
titleLabel.text = action.name
iconImageView.image = action.image
Expand All @@ -76,16 +77,23 @@ class FloatingPanelActionCollectionViewCell: UICollectionViewCell {
}

switch action {
case .upsaleColor, .convertToDropbox:
case .upsaleColor:
guard currentPackId == .myKSuite else { return }
configureChip()
case .convertToDropbox:
guard currentPackId == .myKSuite, driveFileManager.drive.dropboxQuotaExceeded else { return }
configureChip()
default:
break
}
}

func configure(with action: FloatingPanelAction, files: [File], showProgress: Bool, archiveId: String?) {
configure(with: action, file: nil, showProgress: false)
func configure(with action: FloatingPanelAction,
files: [File],
driveFileManager: DriveFileManager,
showProgress: Bool,
archiveId: String?) {
configure(with: action, file: nil, showProgress: false, driveFileManager: driveFileManager)

switch action {
case .favorite:
Expand Down
2 changes: 0 additions & 2 deletions kDriveCore/Utils/AppNavigable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ public protocol RouterActionable {
/// Ask the user to remove pictures if configured
func askUserToRemovePicturesIfNecessary() async

@MainActor func askToUpSaleIfQuotaReached()

@MainActor func presentUpSaleSheet()

func refreshCacheScanLibraryAndUpload(preload: Bool, isSwitching: Bool) async
Expand Down
2 changes: 0 additions & 2 deletions kDriveCore/Utils/InExtensionRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public struct InExtensionRouter: AppNavigable {

public func askUserToRemovePicturesIfNecessary() async {}

public func askToUpSaleIfQuotaReached() {}

public func presentUpSaleSheet() {}

public func refreshCacheScanLibraryAndUpload(preload: Bool, isSwitching: Bool) async {}
Expand Down
4 changes: 0 additions & 4 deletions kDriveTestShared/MCKRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public final class MCKRouter: AppNavigable {
logNoop()
}

public func askToUpSaleIfQuotaReached() {
logNoop()
}

public func presentUpSaleSheet() {
logNoop()
}
Expand Down

0 comments on commit 791a863

Please sign in to comment.