|
@@ -27,13 +27,18 @@ import NCCommunication
|
|
|
|
|
|
class NCDetailViewController: UIViewController {
|
|
|
|
|
|
- @IBOutlet weak var viewerImageView: NCViewerImageView!
|
|
|
+ @IBOutlet weak var backgroundView: UIImageView!
|
|
|
|
|
|
@objc var metadata: tableMetadata?
|
|
|
@objc var selector: String?
|
|
|
|
|
|
private let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
|
|
|
+
|
|
|
+ let imageNames = ["image1", "image2", "image3"]
|
|
|
+ let imageTitles = ["Image 1", "Image 2", "Image 3"]
|
|
|
+ var index: Int = 0
|
|
|
+
|
|
|
required init?(coder: NSCoder) {
|
|
|
super.init(coder: coder)
|
|
|
|
|
@@ -71,7 +76,7 @@ class NCDetailViewController: UIViewController {
|
|
|
navigationController.popToRootViewController(animated: true)
|
|
|
}
|
|
|
} else {
|
|
|
- for view in viewerImageView.subviews {
|
|
|
+ for view in backgroundView.subviews {
|
|
|
view.removeFromSuperview()
|
|
|
}
|
|
|
self.navigationController?.navigationBar.topItem?.title = ""
|
|
@@ -80,12 +85,12 @@ class NCDetailViewController: UIViewController {
|
|
|
}
|
|
|
|
|
|
@objc func changeTheming() {
|
|
|
- //backgroundView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "logo"), multiplier: 2, color: NCBrandColor.sharedInstance.brand.withAlphaComponent(0.4))
|
|
|
+ backgroundView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "logo"), multiplier: 2, color: NCBrandColor.sharedInstance.brand.withAlphaComponent(0.4))
|
|
|
view.backgroundColor = NCBrandColor.sharedInstance.backgroundView
|
|
|
}
|
|
|
|
|
|
func subViewActive() -> UIView? {
|
|
|
- return viewerImageView.subviews.first
|
|
|
+ return backgroundView.subviews.first
|
|
|
}
|
|
|
|
|
|
@objc func viewFile(metadata: tableMetadata, selector: String?) {
|
|
@@ -106,31 +111,22 @@ class NCDetailViewController: UIViewController {
|
|
|
|
|
|
// IMAGE
|
|
|
if metadata.typeFile == k_metadataTypeFile_image {
|
|
|
- if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND typeFile == %@", metadata.account, metadata.serverUrl, k_metadataTypeFile_image), sorted: "fileName", ascending: true) {
|
|
|
- var assets: [NCViewerImageAsset?] = [NCViewerImageAsset]()
|
|
|
- var index = 0
|
|
|
- for metadata in metadatas {
|
|
|
- let asset = NCViewerImageAsset(metadata: metadata)
|
|
|
- assets.append(asset)
|
|
|
- if metadata.ocId == self.metadata?.ocId {
|
|
|
- viewerImageView.preselectItem(at: index)
|
|
|
- }
|
|
|
- index += 1
|
|
|
- }
|
|
|
- viewerImageView.assets = assets
|
|
|
- }
|
|
|
+// let viewerPhotoViewController = NCViewerPhotoViewController()
|
|
|
+// self.addChild(viewerPhotoViewController)
|
|
|
+// self.backgroundView.addSubview(viewerPhotoViewController.view)
|
|
|
+// viewerPhotoViewController.didMove(toParent: self)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// AUDIO VIDEO
|
|
|
if metadata.typeFile == k_metadataTypeFile_audio || metadata.typeFile == k_metadataTypeFile_video {
|
|
|
- NCViewerMedia.sharedInstance.viewMedia(metadata, view: viewerImageView)
|
|
|
+ NCViewerMedia.sharedInstance.viewMedia(metadata, view: backgroundView)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// DOCUMENT - INTERNAL VIEWER
|
|
|
if metadata.typeFile == k_metadataTypeFile_document && selector != nil && selector == selectorLoadFileInternalView {
|
|
|
- NCViewerDocumentWeb.sharedInstance.viewDocumentWebAt(metadata, view: viewerImageView)
|
|
|
+ NCViewerDocumentWeb.sharedInstance.viewDocumentWebAt(metadata, view: backgroundView)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -140,14 +136,14 @@ class NCDetailViewController: UIViewController {
|
|
|
// PDF
|
|
|
if metadata.contentType == "application/pdf" {
|
|
|
if #available(iOS 11.0, *) {
|
|
|
- let viewerPDF = NCViewerPDF.init(frame: viewerImageView.frame)
|
|
|
+ let viewerPDF = NCViewerPDF.init(frame: backgroundView.frame)
|
|
|
|
|
|
let filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
|
|
|
if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) == false {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- viewerPDF.setupPdfView(filePath: URL(fileURLWithPath: filePath), view: viewerImageView)
|
|
|
+ viewerPDF.setupPdfView(filePath: URL(fileURLWithPath: filePath), view: backgroundView)
|
|
|
}
|
|
|
|
|
|
return
|
|
@@ -159,7 +155,7 @@ class NCDetailViewController: UIViewController {
|
|
|
let editor = NCUtility.sharedInstance.isDirectEditing(metadata)!
|
|
|
if editor == k_editor_text || editor == k_editor_onlyoffice {
|
|
|
|
|
|
- NCUtility.sharedInstance.startActivityIndicator(view: viewerImageView, bottom: 0)
|
|
|
+ NCUtility.sharedInstance.startActivityIndicator(view: backgroundView, bottom: 0)
|
|
|
|
|
|
if metadata.url == "" {
|
|
|
|
|
@@ -174,8 +170,8 @@ class NCDetailViewController: UIViewController {
|
|
|
|
|
|
if errorCode == 0 && account == self.appDelegate.activeAccount && url != nil {
|
|
|
|
|
|
- let nextcloudText = NCViewerNextcloudText.init(frame: self.viewerImageView.frame, configuration: WKWebViewConfiguration())
|
|
|
- nextcloudText.viewerAt(url!, metadata: metadata, editor: editor, view: self.viewerImageView, viewController: self)
|
|
|
+ let nextcloudText = NCViewerNextcloudText.init(frame: self.backgroundView.frame, configuration: WKWebViewConfiguration())
|
|
|
+ nextcloudText.viewerAt(url!, metadata: metadata, editor: editor, view: self.backgroundView, viewController: self)
|
|
|
if editor == k_editor_text && self.splitViewController!.isCollapsed {
|
|
|
self.navigationController?.navigationItem.hidesBackButton = true
|
|
|
}
|
|
@@ -193,8 +189,8 @@ class NCDetailViewController: UIViewController {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- let nextcloudText = NCViewerNextcloudText.init(frame: viewerImageView.frame, configuration: WKWebViewConfiguration())
|
|
|
- nextcloudText.viewerAt(metadata.url, metadata: metadata, editor: editor, view: viewerImageView, viewController: self)
|
|
|
+ let nextcloudText = NCViewerNextcloudText.init(frame: backgroundView.frame, configuration: WKWebViewConfiguration())
|
|
|
+ nextcloudText.viewerAt(metadata.url, metadata: metadata, editor: editor, view: backgroundView, viewController: self)
|
|
|
if editor == k_editor_text && self.splitViewController!.isCollapsed {
|
|
|
self.navigationController?.navigationItem.hidesBackButton = true
|
|
|
}
|
|
@@ -207,7 +203,7 @@ class NCDetailViewController: UIViewController {
|
|
|
// RichDocument: Collabora
|
|
|
if NCUtility.sharedInstance.isRichDocument(metadata) && appDelegate.reachability.isReachable() {
|
|
|
|
|
|
- NCUtility.sharedInstance.startActivityIndicator(view: viewerImageView, bottom: 0)
|
|
|
+ NCUtility.sharedInstance.startActivityIndicator(view: backgroundView, bottom: 0)
|
|
|
|
|
|
if metadata.url == "" {
|
|
|
|
|
@@ -215,8 +211,8 @@ class NCDetailViewController: UIViewController {
|
|
|
|
|
|
if errorCode == 0 && account == self.appDelegate.activeAccount && url != nil {
|
|
|
|
|
|
- let richDocument = NCViewerRichdocument.init(frame: self.viewerImageView.frame, configuration: WKWebViewConfiguration())
|
|
|
- richDocument.viewRichDocumentAt(url!, metadata: metadata, view: self.viewerImageView, viewController: self)
|
|
|
+ let richDocument = NCViewerRichdocument.init(frame: self.backgroundView.frame, configuration: WKWebViewConfiguration())
|
|
|
+ richDocument.viewRichDocumentAt(url!, metadata: metadata, view: self.backgroundView, viewController: self)
|
|
|
if self.splitViewController != nil && self.splitViewController!.isCollapsed {
|
|
|
self.navigationController?.navigationItem.hidesBackButton = true
|
|
|
}
|
|
@@ -235,8 +231,8 @@ class NCDetailViewController: UIViewController {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- let richDocument = NCViewerRichdocument.init(frame: viewerImageView.frame, configuration: WKWebViewConfiguration())
|
|
|
- richDocument.viewRichDocumentAt(metadata.url, metadata: metadata, view: viewerImageView, viewController: self)
|
|
|
+ let richDocument = NCViewerRichdocument.init(frame: backgroundView.frame, configuration: WKWebViewConfiguration())
|
|
|
+ richDocument.viewRichDocumentAt(metadata.url, metadata: metadata, view: backgroundView, viewController: self)
|
|
|
if self.splitViewController != nil && self.splitViewController!.isCollapsed {
|
|
|
self.navigationController?.navigationItem.hidesBackButton = true
|
|
|
}
|
|
@@ -245,7 +241,32 @@ class NCDetailViewController: UIViewController {
|
|
|
}
|
|
|
|
|
|
// OTHER
|
|
|
- NCViewerDocumentWeb.sharedInstance.viewDocumentWebAt(metadata, view: viewerImageView)
|
|
|
+ NCViewerDocumentWeb.sharedInstance.viewDocumentWebAt(metadata, view: backgroundView)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: SwiftPhotoGalleryDataSource Methods
|
|
|
+extension NCDetailViewController: NCPhotoGalleryDataSource {
|
|
|
+
|
|
|
+ func numberOfImagesInGallery(gallery: NCPhotoGallery) -> Int {
|
|
|
+ let i = imageNames.count
|
|
|
+ return imageNames.count
|
|
|
+ }
|
|
|
+
|
|
|
+ func imageInGallery(gallery: NCPhotoGallery, forIndex: Int) -> UIImage? {
|
|
|
+ if forIndex < 0 { return nil }
|
|
|
+ let image = UIImage(named: imageNames[forIndex])
|
|
|
+ return image
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
+
|
|
|
+// MARK: SwiftPhotoGalleryDelegate Methods
|
|
|
+extension NCDetailViewController: NCPhotoGalleryDelegate {
|
|
|
+
|
|
|
+ func galleryDidTapToClose(gallery: NCPhotoGallery) {
|
|
|
+ self.index = gallery.currentPage
|
|
|
+ dismiss(animated: true, completion: nil)
|
|
|
+ }
|
|
|
}
|
|
|
+
|