Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor file actions panel #409

Merged
merged 11 commits into from
Nov 22, 2021
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
8 changes: 4 additions & 4 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ let project = Project(name: "kDrive",
"kDrive/UI/View/Files/SwipableCell.swift",
"kDrive/UI/View/Files/SwipableCollectionView.swift",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelSortOptionTableViewCell.swift",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelCollectionViewCell.swift",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelQuickActionCollectionViewCell.swift",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelTableViewCell.swift",
"kDrive/UI/View/Footer view/**",
"kDrive/UI/View/Menu/SwitchUser/**",
Expand All @@ -244,7 +244,7 @@ let project = Project(name: "kDrive",
"kDrive/UI/View/Files/Search/*.xib",
"kDrive/UI/View/Files/Upload/*.xib",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelSortOptionTableViewCell.xib",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelCollectionViewCell.xib",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelQuickActionCollectionViewCell.xib",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelTableViewCell.xib",
"kDrive/UI/View/Footer view/*.xib",
"kDrive/UI/View/Menu/MenuTableViewCell.xib",
Expand Down Expand Up @@ -320,7 +320,7 @@ let project = Project(name: "kDrive",
"kDrive/UI/View/Files/SwipableCell.swift",
"kDrive/UI/View/Files/SwipableCollectionView.swift",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelSortOptionTableViewCell.swift",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelCollectionViewCell.swift",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelQuickActionCollectionViewCell.swift",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelTableViewCell.swift",
"kDrive/UI/View/Footer view/**",
"kDrive/UI/View/Menu/SwitchUser/**",
Expand All @@ -347,7 +347,7 @@ let project = Project(name: "kDrive",
"kDrive/UI/View/Files/Search/*.xib",
"kDrive/UI/View/Files/Upload/*.xib",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelSortOptionTableViewCell.xib",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelCollectionViewCell.xib",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelQuickActionCollectionViewCell.xib",
"kDrive/UI/View/Files/FloatingPanel/FloatingPanelTableViewCell.xib",
"kDrive/UI/View/Footer view/*.xib",
"kDrive/UI/View/Menu/MenuTableViewCell.xib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ class PlusButtonFloatingPanelViewController: UITableViewController, FloatingPane
}
}

init(driveFileManager: DriveFileManager, folder: File) {
self.driveFileManager = driveFileManager
self.currentDirectory = folder
super.init(nibName: nil, bundle: nil)
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()
tableView.separatorColor = .clear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import UIKit
class ManageDropBoxViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!

var driveFileManager: DriveFileManager!
var folder: File! {
private var driveFileManager: DriveFileManager!
private var folder: File! {
didSet {
setTitle()
getSettings()
}
}

var convertingFolder = false {
private var convertingFolder = false {
didSet { setTitle() }
}

Expand Down Expand Up @@ -77,8 +77,12 @@ class ManageDropBoxViewController: UIViewController, UITableViewDelegate, UITabl
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
}

class func instantiate() -> ManageDropBoxViewController {
return Storyboard.files.instantiateViewController(withIdentifier: "ManageDropBoxViewController") as! ManageDropBoxViewController
class func instantiate(driveFileManager: DriveFileManager, convertingFolder: Bool = false, folder: File) -> ManageDropBoxViewController {
let viewController = Storyboard.files.instantiateViewController(withIdentifier: "ManageDropBoxViewController") as! ManageDropBoxViewController
viewController.convertingFolder = convertingFolder
viewController.driveFileManager = driveFileManager
viewController.folder = folder
return viewController
}

@objc func keyboardWillShow(_ notification: Notification) {
Expand Down Expand Up @@ -239,6 +243,7 @@ class ManageDropBoxViewController: UIViewController, UITableViewDelegate, UITabl
driveFileManager.apiFetcher.disableDropBox(directory: folder) { _, error in
if error == nil {
self.dismissAndRefreshDataSource()
self.driveFileManager.setFileCollaborativeFolder(file: self.folder, collaborativeFolder: nil)
} else {
UIConstants.showSnackBar(message: KDriveStrings.Localizable.errorModification)
}
Expand All @@ -253,17 +258,20 @@ class ManageDropBoxViewController: UIViewController, UITableViewDelegate, UITabl

coder.encode(driveFileManager.drive.id, forKey: "DriveId")
coder.encode(folder.id, forKey: "FolderId")
coder.encode(convertingFolder, forKey: "ConvertingFolder")
}

override func decodeRestorableState(with coder: NSCoder) {
super.decodeRestorableState(with: coder)

let driveId = coder.decodeInteger(forKey: "DriveId")
let folderId = coder.decodeInteger(forKey: "FolderId")
let convertingFolder = coder.decodeBool(forKey: "ConvertingFolder")
guard let driveFileManager = AccountManager.instance.getDriveFileManager(for: driveId, userId: AccountManager.instance.currentUserId) else {
return
}
self.driveFileManager = driveFileManager
self.convertingFolder = convertingFolder
folder = driveFileManager.getCachedFile(id: folderId)
}
}
Expand Down Expand Up @@ -310,6 +318,7 @@ extension ManageDropBoxViewController: FooterButtonDelegate {
floatingPanelViewController?.copyTextField.text = dropBox.url
floatingPanelViewController?.titleLabel.text = KDriveStrings.Localizable.dropBoxResultTitle(self.folder.name)
self.present(driveFloatingPanelController, animated: true)
self.driveFileManager.setFileCollaborativeFolder(file: self.folder, collaborativeFolder: dropBox.url)
} else {
UIConstants.showSnackBar(message: KDriveStrings.Localizable.errorGeneric)
}
Expand Down
Loading