|
@@ -24,7 +24,7 @@
|
|
|
import Foundation
|
|
|
import Sheeeeeeeeet
|
|
|
|
|
|
-class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIGestureRecognizerDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DropdownMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate, BKPasscodeViewControllerDelegate {
|
|
|
+class NCOffline: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DropdownMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate, BKPasscodeViewControllerDelegate {
|
|
|
|
|
|
@IBOutlet fileprivate weak var collectionView: UICollectionView!
|
|
|
|
|
@@ -96,7 +96,12 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
|
|
|
|
|
|
// empty Data Source
|
|
|
self.collectionView.emptyDataSetDelegate = self;
|
|
|
- self.collectionView.emptyDataSetSource = self;
|
|
|
+ self.collectionView.emptyDataSetSource = self;
|
|
|
+
|
|
|
+ // 3D Touch peek and pop
|
|
|
+ if traitCollection.forceTouchCapability == .available {
|
|
|
+ registerForPreviewing(with: self, sourceView: view)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
@@ -419,75 +424,148 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // MARK: NC API
|
|
|
+ // MARK: SEGUE
|
|
|
|
|
|
- func deleteItem(with metadata: tableMetadata, sender: Any) {
|
|
|
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
|
|
|
|
- var items = [ActionSheetItem]()
|
|
|
+ let photoDataSource: NSMutableArray = []
|
|
|
|
|
|
- guard let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == serverUrl", appDelegate.activeAccount, metadata.serverUrl)) else {
|
|
|
- return
|
|
|
+ for fileID: String in sectionDatasource.allFileID as! [String] {
|
|
|
+ let metadata = sectionDatasource.allRecordsDataSource.object(forKey: fileID) as! tableMetadata
|
|
|
+ if metadata.typeFile == k_metadataTypeFile_image {
|
|
|
+ photoDataSource.add(metadata)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- items.append(ActionSheetDangerButton(title: NSLocalizedString("_delete_", comment: "")))
|
|
|
- items.append(ActionSheetCancelButton(title: NSLocalizedString("_cancel_", comment: "")))
|
|
|
-
|
|
|
- actionSheet = ActionSheet(items: items) { sheet, item in
|
|
|
- if item is ActionSheetDangerButton {
|
|
|
- NCMainCommon.sharedInstance.deleteFile(metadatas: [metadata], e2ee: tableDirectory.e2eEncrypted, serverUrl: tableDirectory.serverUrl, folderFileID: tableDirectory.fileID) { (errorCode, message) in
|
|
|
- self.loadDatasource()
|
|
|
- }
|
|
|
+ if let segueNavigationController = segue.destination as? UINavigationController {
|
|
|
+ if let segueViewController = segueNavigationController.topViewController as? CCDetail {
|
|
|
+
|
|
|
+ segueViewController.metadataDetail = metadataPush
|
|
|
+ segueViewController.dateFilterQuery = nil
|
|
|
+ segueViewController.photoDataSource = photoDataSource
|
|
|
+ segueViewController.title = metadataPush!.fileNameView
|
|
|
}
|
|
|
- if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
|
|
|
}
|
|
|
-
|
|
|
- let headerView = NCActionSheetHeader.sharedInstance.actionSheetHeader(isDirectory: metadata.directory, iconName: metadata.iconName, fileID: metadata.fileID, fileNameView: metadata.fileNameView, text: metadata.fileNameView)
|
|
|
- actionSheet?.headerView = headerView
|
|
|
- actionSheet?.headerView?.frame.size.height = 50
|
|
|
-
|
|
|
- actionSheet?.present(in: self, from: sender as! UIButton)
|
|
|
}
|
|
|
|
|
|
- // MARK: DATASOURCE
|
|
|
- @objc func loadDatasource() {
|
|
|
+ // MARK: NAVIGATION
|
|
|
+
|
|
|
+ private func performSegueDirectoryWithControlPasscode(controlPasscode: Bool) {
|
|
|
|
|
|
- var fileIDs = [String]()
|
|
|
- sectionDatasource = CCSectionDataSourceMetadata()
|
|
|
-
|
|
|
- if serverUrl == "" {
|
|
|
+ guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadataPush!.serverUrl, addFileName: metadataPush!.fileName) else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ guard let directoryPush = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrlPush)) else {
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- if let directories = NCManageDatabase.sharedInstance.getTablesDirectory(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "serverUrl", ascending: true) {
|
|
|
- for directory: tableDirectory in directories {
|
|
|
- fileIDs.append(directory.fileID)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if let files = NCManageDatabase.sharedInstance.getTableLocalFiles(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "fileName", ascending: true) {
|
|
|
- for file: tableLocalFile in files {
|
|
|
- fileIDs.append(file.fileID)
|
|
|
- }
|
|
|
- }
|
|
|
+ if directoryPush.lock == true && CCUtility.getBlockCode() != nil && (CCUtility.getBlockCode()?.count)! > 0 && controlPasscode {
|
|
|
|
|
|
- if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND fileID IN %@", appDelegate.activeAccount, fileIDs), sorted: nil, ascending: false) {
|
|
|
-
|
|
|
- sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: datasourceGroupBy, filterFileID: nil, filterTypeFileImage: false, filterTypeFileVideo: false, sorted: datasourceSorted, ascending: datasourceAscending, activeAccount: appDelegate.activeAccount)
|
|
|
+ let viewController = CCBKPasscode.init(nibName: nil, bundle: nil)
|
|
|
+ guard let touchIDManager = BKTouchIDManager.init(keychainServiceName: k_serviceShareKeyChain) else {
|
|
|
+ return
|
|
|
}
|
|
|
+ touchIDManager.promptText = NSLocalizedString("_scan_fingerprint_", comment: "")
|
|
|
|
|
|
- } else {
|
|
|
-
|
|
|
- if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl), sorted: nil, ascending: false) {
|
|
|
-
|
|
|
- sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: datasourceGroupBy, filterFileID: nil, filterTypeFileImage: false, filterTypeFileVideo: false, sorted: datasourceSorted, ascending: datasourceAscending, activeAccount: appDelegate.activeAccount)
|
|
|
+ viewController.delegate = self
|
|
|
+ viewController.type = BKPasscodeViewControllerCheckPasscodeType
|
|
|
+ viewController.inputViewTitlePassword = true
|
|
|
+ if CCUtility.getSimplyBlockCode() {
|
|
|
+ viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle
|
|
|
+ viewController.passcodeInputView.maximumLength = 6
|
|
|
+ } else {
|
|
|
+ viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle
|
|
|
+ viewController.passcodeInputView.maximumLength = 64
|
|
|
}
|
|
|
+ viewController.touchIDManager = touchIDManager
|
|
|
+ viewController.title = NSLocalizedString("_folder_blocked_", comment: "")
|
|
|
+ viewController.navigationItem.leftBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: UIBarButtonItem.SystemItem.cancel, target: self, action: #selector(passcodeViewCloseButtonPressed(_:)))
|
|
|
+ viewController.navigationItem.leftBarButtonItem?.tintColor = UIColor.black
|
|
|
+
|
|
|
+ let navigationController = UINavigationController.init(rootViewController: viewController)
|
|
|
+ self.present(navigationController, animated: true, completion: nil)
|
|
|
+
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- self.refreshControl.endRefreshing()
|
|
|
+ let ncOffline:NCOffline = UIStoryboard(name: "NCOffline", bundle: nil).instantiateInitialViewController() as! NCOffline
|
|
|
|
|
|
- collectionView.reloadData()
|
|
|
+ ncOffline.serverUrl = serverUrlPush
|
|
|
+ ncOffline.titleCurrentFolder = metadataPush!.fileNameView
|
|
|
+
|
|
|
+ self.navigationController?.pushViewController(ncOffline, animated: true)
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - 3D Touch peek and pop
|
|
|
+
|
|
|
+extension NCOffline: UIViewControllerPreviewingDelegate {
|
|
|
|
|
|
- // MARK: COLLECTIONVIEW METHODS
|
|
|
+ func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
|
|
|
+
|
|
|
+ guard let point = collectionView?.convert(location, from: collectionView?.superview) else { return nil }
|
|
|
+ guard let indexPath = collectionView?.indexPathForItem(at: point) else { return nil }
|
|
|
+ guard let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(indexPath, sectionDataSource: sectionDatasource) else { return nil }
|
|
|
+ guard let viewController = UIStoryboard(name: "CCPeekPop", bundle: nil).instantiateViewController(withIdentifier: "PeekPopImagePreview") as? CCPeekPop else { return nil }
|
|
|
+
|
|
|
+ viewController.metadata = metadata
|
|
|
+
|
|
|
+ if typeLayout == k_layout_grid {
|
|
|
+ guard let cell = collectionView?.cellForItem(at: indexPath) as? NCGridCell else { return nil }
|
|
|
+ previewingContext.sourceRect = cell.frame
|
|
|
+ viewController.imageFile = cell.imageItem.image
|
|
|
+ } else {
|
|
|
+ guard let cell = collectionView?.cellForItem(at: indexPath) as? NCListCell else { return nil }
|
|
|
+ previewingContext.sourceRect = cell.frame
|
|
|
+ viewController.imageFile = cell.imageItem.image
|
|
|
+ }
|
|
|
+
|
|
|
+ return viewController
|
|
|
+ }
|
|
|
|
|
|
+ func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
|
|
|
+
|
|
|
+ guard let indexPath = collectionView?.indexPathForItem(at: previewingContext.sourceRect.origin) else { return }
|
|
|
+
|
|
|
+ collectionView(collectionView, didSelectItemAt: indexPath)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - Collection View
|
|
|
+
|
|
|
+extension NCOffline: UICollectionViewDelegate {
|
|
|
+
|
|
|
+ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
+
|
|
|
+ guard let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(indexPath, sectionDataSource: sectionDatasource) else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ metadataPush = metadata
|
|
|
+
|
|
|
+ if isEditMode {
|
|
|
+ if let index = selectFileID.index(of: metadata.fileID) {
|
|
|
+ selectFileID.remove(at: index)
|
|
|
+ } else {
|
|
|
+ selectFileID.append(metadata.fileID)
|
|
|
+ }
|
|
|
+ collectionView.reloadItems(at: [indexPath])
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if metadata.directory {
|
|
|
+
|
|
|
+ performSegueDirectoryWithControlPasscode(controlPasscode: true)
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension NCOffline: UICollectionViewDataSource {
|
|
|
+
|
|
|
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
|
|
|
|
|
|
if (indexPath.section == 0) {
|
|
@@ -515,9 +593,9 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
|
|
|
header.setTitleLabel(sectionDatasource: sectionDatasource, section: indexPath.section)
|
|
|
header.labelSectionHeightConstraint.constant = sectionHeaderHeight
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return header
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
|
|
|
let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
|
|
@@ -528,7 +606,7 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
-
|
|
|
+
|
|
|
if kind == UICollectionView.elementKindSectionHeader {
|
|
|
|
|
|
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
|
|
@@ -542,33 +620,12 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
|
|
|
let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
|
|
|
|
|
|
footer.setTitleLabel(sectionDatasource: sectionDatasource)
|
|
|
-
|
|
|
+
|
|
|
return footer
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
|
|
- if section == 0 {
|
|
|
- if datasourceGroupBy == "none" {
|
|
|
- return CGSize(width: collectionView.frame.width, height: headerMenuHeight)
|
|
|
- } else {
|
|
|
- return CGSize(width: collectionView.frame.width, height: headerMenuHeight + sectionHeaderHeight)
|
|
|
- }
|
|
|
- } else {
|
|
|
- return CGSize(width: collectionView.frame.width, height: sectionHeaderHeight)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
|
|
|
- let sections = sectionDatasource.sectionArrayRow.allKeys.count
|
|
|
- if (section == sections - 1) {
|
|
|
- return CGSize(width: collectionView.frame.width, height: footerHeight)
|
|
|
- } else {
|
|
|
- return CGSize(width: collectionView.frame.width, height: 0)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
func numberOfSections(in collectionView: UICollectionView) -> Int {
|
|
|
let sections = sectionDatasource.sectionArrayRow.allKeys.count
|
|
|
return sections
|
|
@@ -583,7 +640,7 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
|
|
|
let cell: UICollectionViewCell
|
|
|
-
|
|
|
+
|
|
|
guard let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(indexPath, sectionDataSource: sectionDatasource) else {
|
|
|
return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
|
|
|
}
|
|
@@ -598,104 +655,97 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
|
|
|
|
|
|
return cell
|
|
|
}
|
|
|
-
|
|
|
- func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
-
|
|
|
- guard let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(indexPath, sectionDataSource: sectionDatasource) else {
|
|
|
- return
|
|
|
- }
|
|
|
- metadataPush = metadata
|
|
|
-
|
|
|
- if isEditMode {
|
|
|
- if let index = selectFileID.index(of: metadata.fileID) {
|
|
|
- selectFileID.remove(at: index)
|
|
|
+}
|
|
|
+
|
|
|
+extension NCOffline: UICollectionViewDelegateFlowLayout {
|
|
|
+
|
|
|
+ func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
|
|
+ if section == 0 {
|
|
|
+ if datasourceGroupBy == "none" {
|
|
|
+ return CGSize(width: collectionView.frame.width, height: headerMenuHeight)
|
|
|
} else {
|
|
|
- selectFileID.append(metadata.fileID)
|
|
|
+ return CGSize(width: collectionView.frame.width, height: headerMenuHeight + sectionHeaderHeight)
|
|
|
}
|
|
|
- collectionView.reloadItems(at: [indexPath])
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if metadata.directory {
|
|
|
-
|
|
|
- performSegueDirectoryWithControlPasscode(controlPasscode: true)
|
|
|
-
|
|
|
} else {
|
|
|
-
|
|
|
-
|
|
|
- performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
+ return CGSize(width: collectionView.frame.width, height: sectionHeaderHeight)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // MARK: SEGUE
|
|
|
-
|
|
|
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
|
+ func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
|
|
|
+ let sections = sectionDatasource.sectionArrayRow.allKeys.count
|
|
|
+ if (section == sections - 1) {
|
|
|
+ return CGSize(width: collectionView.frame.width, height: footerHeight)
|
|
|
+ } else {
|
|
|
+ return CGSize(width: collectionView.frame.width, height: 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - NC API & Algorithm
|
|
|
+
|
|
|
+extension NCOffline {
|
|
|
+
|
|
|
+ @objc func loadDatasource() {
|
|
|
|
|
|
- let photoDataSource: NSMutableArray = []
|
|
|
+ var fileIDs = [String]()
|
|
|
+ sectionDatasource = CCSectionDataSourceMetadata()
|
|
|
|
|
|
- for fileID: String in sectionDatasource.allFileID as! [String] {
|
|
|
- let metadata = sectionDatasource.allRecordsDataSource.object(forKey: fileID) as! tableMetadata
|
|
|
- if metadata.typeFile == k_metadataTypeFile_image {
|
|
|
- photoDataSource.add(metadata)
|
|
|
+ if serverUrl == "" {
|
|
|
+
|
|
|
+ if let directories = NCManageDatabase.sharedInstance.getTablesDirectory(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "serverUrl", ascending: true) {
|
|
|
+ for directory: tableDirectory in directories {
|
|
|
+ fileIDs.append(directory.fileID)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if let segueNavigationController = segue.destination as? UINavigationController {
|
|
|
- if let segueViewController = segueNavigationController.topViewController as? CCDetail {
|
|
|
|
|
|
- segueViewController.metadataDetail = metadataPush
|
|
|
- segueViewController.dateFilterQuery = nil
|
|
|
- segueViewController.photoDataSource = photoDataSource
|
|
|
- segueViewController.title = metadataPush!.fileNameView
|
|
|
+ if let files = NCManageDatabase.sharedInstance.getTableLocalFiles(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "fileName", ascending: true) {
|
|
|
+ for file: tableLocalFile in files {
|
|
|
+ fileIDs.append(file.fileID)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND fileID IN %@", appDelegate.activeAccount, fileIDs), sorted: nil, ascending: false) {
|
|
|
+
|
|
|
+ sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: datasourceGroupBy, filterFileID: nil, filterTypeFileImage: false, filterTypeFileVideo: false, sorted: datasourceSorted, ascending: datasourceAscending, activeAccount: appDelegate.activeAccount)
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl), sorted: nil, ascending: false) {
|
|
|
+
|
|
|
+ sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: datasourceGroupBy, filterFileID: nil, filterTypeFileImage: false, filterTypeFileVideo: false, sorted: datasourceSorted, ascending: datasourceAscending, activeAccount: appDelegate.activeAccount)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ self.refreshControl.endRefreshing()
|
|
|
+
|
|
|
+ collectionView.reloadData()
|
|
|
}
|
|
|
|
|
|
- // MARK: NAVIGATION
|
|
|
-
|
|
|
- private func performSegueDirectoryWithControlPasscode(controlPasscode: Bool) {
|
|
|
+ func deleteItem(with metadata: tableMetadata, sender: Any) {
|
|
|
|
|
|
- guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadataPush!.serverUrl, addFileName: metadataPush!.fileName) else {
|
|
|
- return
|
|
|
- }
|
|
|
- guard let directoryPush = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrlPush)) else {
|
|
|
+ var items = [ActionSheetItem]()
|
|
|
+
|
|
|
+ guard let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == serverUrl", appDelegate.activeAccount, metadata.serverUrl)) else {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if directoryPush.lock == true && CCUtility.getBlockCode() != nil && (CCUtility.getBlockCode()?.count)! > 0 && controlPasscode {
|
|
|
-
|
|
|
- let viewController = CCBKPasscode.init(nibName: nil, bundle: nil)
|
|
|
- guard let touchIDManager = BKTouchIDManager.init(keychainServiceName: k_serviceShareKeyChain) else {
|
|
|
- return
|
|
|
- }
|
|
|
- touchIDManager.promptText = NSLocalizedString("_scan_fingerprint_", comment: "")
|
|
|
-
|
|
|
- viewController.delegate = self
|
|
|
- viewController.type = BKPasscodeViewControllerCheckPasscodeType
|
|
|
- viewController.inputViewTitlePassword = true
|
|
|
- if CCUtility.getSimplyBlockCode() {
|
|
|
- viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle
|
|
|
- viewController.passcodeInputView.maximumLength = 6
|
|
|
- } else {
|
|
|
- viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle
|
|
|
- viewController.passcodeInputView.maximumLength = 64
|
|
|
+ items.append(ActionSheetDangerButton(title: NSLocalizedString("_delete_", comment: "")))
|
|
|
+ items.append(ActionSheetCancelButton(title: NSLocalizedString("_cancel_", comment: "")))
|
|
|
+
|
|
|
+ actionSheet = ActionSheet(items: items) { sheet, item in
|
|
|
+ if item is ActionSheetDangerButton {
|
|
|
+ NCMainCommon.sharedInstance.deleteFile(metadatas: [metadata], e2ee: tableDirectory.e2eEncrypted, serverUrl: tableDirectory.serverUrl, folderFileID: tableDirectory.fileID) { (errorCode, message) in
|
|
|
+ self.loadDatasource()
|
|
|
+ }
|
|
|
}
|
|
|
- viewController.touchIDManager = touchIDManager
|
|
|
- viewController.title = NSLocalizedString("_folder_blocked_", comment: "")
|
|
|
- viewController.navigationItem.leftBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: UIBarButtonItem.SystemItem.cancel, target: self, action: #selector(passcodeViewCloseButtonPressed(_:)))
|
|
|
- viewController.navigationItem.leftBarButtonItem?.tintColor = UIColor.black
|
|
|
-
|
|
|
- let navigationController = UINavigationController.init(rootViewController: viewController)
|
|
|
- self.present(navigationController, animated: true, completion: nil)
|
|
|
-
|
|
|
- return
|
|
|
+ if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
|
|
|
}
|
|
|
|
|
|
- let ncOffline:NCOffline = UIStoryboard(name: "NCOffline", bundle: nil).instantiateInitialViewController() as! NCOffline
|
|
|
-
|
|
|
- ncOffline.serverUrl = serverUrlPush
|
|
|
- ncOffline.titleCurrentFolder = metadataPush!.fileNameView
|
|
|
+ let headerView = NCActionSheetHeader.sharedInstance.actionSheetHeader(isDirectory: metadata.directory, iconName: metadata.iconName, fileID: metadata.fileID, fileNameView: metadata.fileNameView, text: metadata.fileNameView)
|
|
|
+ actionSheet?.headerView = headerView
|
|
|
+ actionSheet?.headerView?.frame.size.height = 50
|
|
|
|
|
|
- self.navigationController?.pushViewController(ncOffline, animated: true)
|
|
|
+ actionSheet?.present(in: self, from: sender as! UIButton)
|
|
|
}
|
|
|
}
|