|
@@ -81,13 +81,11 @@ class NCViewerImagePageContainer: UIViewController, UIGestureRecognizerDelegate
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(downloadedFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_downloadedFile), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(triggerProgressTask(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_progressTask), object:nil)
|
|
|
- /*
|
|
|
- NotificationCenter.default.addObserver(self, selector: #selector(uploadedFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_uploadedFile), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(deleteFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_deleteFile), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(renameFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_renameFile), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(moveFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_moveFile), object: nil)
|
|
|
|
|
|
-
|
|
|
+ /*
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(saveLivePhoto(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_menuSaveLivePhoto), object: nil)
|
|
|
*/
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(viewUnload), name: NSNotification.Name(rawValue: k_notificationCenter_menuDetailClose), object: nil)
|
|
@@ -148,6 +146,44 @@ class NCViewerImagePageContainer: UIViewController, UIGestureRecognizerDelegate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @objc func deleteFile(_ notification: NSNotification) {
|
|
|
+ if self.view?.window == nil { return }
|
|
|
+
|
|
|
+ if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
+ if let metadata = userInfo["metadata"] as? tableMetadata {
|
|
|
+ let metadatas = self.metadatas.filter { $0.ocId != metadata.ocId }
|
|
|
+ if self.metadatas.count == metadatas.count { return }
|
|
|
+ self.metadatas = metadatas
|
|
|
+
|
|
|
+ if metadata.ocId == currentViewerImageZoom?.metadata.ocId {
|
|
|
+ if !shiftCurrentPage() {
|
|
|
+ self.viewUnload()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func renameFile(_ notification: NSNotification) {
|
|
|
+ if self.view?.window == nil { return }
|
|
|
+
|
|
|
+ if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
+ if let metadata = userInfo["metadata"] as? tableMetadata {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func moveFile(_ notification: NSNotification) {
|
|
|
+ if self.view?.window == nil { return }
|
|
|
+
|
|
|
+ if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
+ if let metadata = userInfo["metadata"] as? tableMetadata, let metadataNew = userInfo["metadataNew"] as? tableMetadata {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@objc func changeTheming() {
|
|
|
|
|
|
if currentMode == .normal {
|
|
@@ -338,6 +374,30 @@ class NCViewerImagePageContainer: UIViewController, UIGestureRecognizerDelegate
|
|
|
|
|
|
extension NCViewerImagePageContainer: UIPageViewControllerDelegate, UIPageViewControllerDataSource {
|
|
|
|
|
|
+ func shiftCurrentPage() -> Bool {
|
|
|
+ if metadatas.count == 0 { return false }
|
|
|
+
|
|
|
+ var direction: UIPageViewController.NavigationDirection = .forward
|
|
|
+ var index = currentIndex
|
|
|
+ if index == metadatas.count {
|
|
|
+ index -= 1
|
|
|
+ direction = .reverse
|
|
|
+ }
|
|
|
+
|
|
|
+ let viewerImageZoom = UIStoryboard(name: "NCViewerImage", bundle: nil).instantiateViewController(withIdentifier: "NCViewerImageZoom") as! NCViewerImageZoom
|
|
|
+
|
|
|
+ viewerImageZoom.index = index
|
|
|
+ viewerImageZoom.image = getImageMetadata(metadatas[index])
|
|
|
+ viewerImageZoom.metadata = metadatas[index]
|
|
|
+ viewerImageZoom.delegate = self
|
|
|
+
|
|
|
+ singleTapGestureRecognizer.require(toFail: viewerImageZoom.doubleTapGestureRecognizer)
|
|
|
+
|
|
|
+ pageViewController.setViewControllers([viewerImageZoom], direction: direction, animated: true, completion: nil)
|
|
|
+
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
|
|
|
if currentIndex == 0 { return nil }
|
|
|
|
|
@@ -354,7 +414,7 @@ extension NCViewerImagePageContainer: UIPageViewControllerDelegate, UIPageViewCo
|
|
|
}
|
|
|
|
|
|
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
|
|
|
- if currentIndex == (self.metadatas.count - 1) { return nil }
|
|
|
+ if currentIndex == metadatas.count - 1 { return nil }
|
|
|
|
|
|
let viewerImageZoom = UIStoryboard(name: "NCViewerImage", bundle: nil).instantiateViewController(withIdentifier: "NCViewerImageZoom") as! NCViewerImageZoom
|
|
|
|