|
@@ -37,7 +37,7 @@ class NCSharePaging: UIViewController {
|
|
|
private var sharingEnabled = true
|
|
|
|
|
|
@objc var metadata = tableMetadata()
|
|
|
- @objc var indexPage: Int = 0
|
|
|
+ var indexPage = NCGlobal.NCSharePagingIndex.activity
|
|
|
|
|
|
// MARK: - View Life Cycle
|
|
|
|
|
@@ -62,18 +62,14 @@ class NCSharePaging: UIViewController {
|
|
|
if activity == nil {
|
|
|
activityEnabled = false
|
|
|
}
|
|
|
- if indexPage == NCGlobal.shared.indexPageComments && !commentsEnabled {
|
|
|
- indexPage = NCGlobal.shared.indexPageActivity
|
|
|
+// if indexPage == NCGlobal.shared.indexPageComments && !commentsEnabled {
|
|
|
+// indexPage = NCGlobal.shared.indexPageActivity
|
|
|
+// }
|
|
|
+ if indexPage == .sharing && !sharingEnabled {
|
|
|
+ indexPage = .activity
|
|
|
}
|
|
|
- if indexPage == NCGlobal.shared.indexPageSharing && !sharingEnabled {
|
|
|
- indexPage = NCGlobal.shared.indexPageActivity
|
|
|
- }
|
|
|
- if indexPage == NCGlobal.shared.indexPageActivity && !activityEnabled {
|
|
|
- if sharingEnabled {
|
|
|
- indexPage = NCGlobal.shared.indexPageSharing
|
|
|
- } else if commentsEnabled {
|
|
|
- indexPage = NCGlobal.shared.indexPageComments
|
|
|
- }
|
|
|
+ if indexPage == .activity && !activityEnabled && sharingEnabled {
|
|
|
+ indexPage = .sharing
|
|
|
}
|
|
|
|
|
|
// *** MUST BE THE FIRST ONE ***
|
|
@@ -112,8 +108,8 @@ class NCSharePaging: UIViewController {
|
|
|
|
|
|
pagingViewController.dataSource = self
|
|
|
pagingViewController.delegate = self
|
|
|
- pagingViewController.select(index: indexPage)
|
|
|
- let pagingIndexItem = self.pagingViewController(pagingViewController, pagingItemAt: indexPage) as! PagingIndexItem
|
|
|
+ pagingViewController.select(index: indexPage.rawValue)
|
|
|
+ let pagingIndexItem = self.pagingViewController(pagingViewController, pagingItemAt: indexPage.rawValue) as! PagingIndexItem
|
|
|
self.title = pagingIndexItem.title
|
|
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
|
|
@@ -127,7 +123,9 @@ class NCSharePaging: UIViewController {
|
|
|
self.dismiss(animated: false, completion: nil)
|
|
|
}
|
|
|
|
|
|
- pagingViewController.menuItemSize = .fixed(width: self.view.bounds.width/3, height: 40)
|
|
|
+ pagingViewController.menuItemSize = .fixed(
|
|
|
+ width: self.view.bounds.width / CGFloat(NCGlobal.NCSharePagingIndex.allCases.count),
|
|
|
+ height: 40)
|
|
|
}
|
|
|
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
@@ -155,13 +153,16 @@ extension NCSharePaging: PagingViewControllerDelegate {
|
|
|
|
|
|
func pagingViewController(_ pagingViewController: PagingViewController, willScrollToItem pagingItem: PagingItem, startingViewController: UIViewController, destinationViewController: UIViewController) {
|
|
|
|
|
|
- guard let item = pagingItem as? PagingIndexItem else { return }
|
|
|
+ guard
|
|
|
+ let item = pagingItem as? PagingIndexItem,
|
|
|
+ let itemIndex = NCGlobal.NCSharePagingIndex(rawValue: item.index)
|
|
|
+ else { return }
|
|
|
|
|
|
- if item.index == NCGlobal.shared.indexPageActivity && !activityEnabled {
|
|
|
- pagingViewController.contentInteraction = .none
|
|
|
- } else if item.index == NCGlobal.shared.indexPageComments && !commentsEnabled {
|
|
|
+ if itemIndex == .activity && !activityEnabled {
|
|
|
pagingViewController.contentInteraction = .none
|
|
|
- } else if item.index == NCGlobal.shared.indexPageSharing && !sharingEnabled {
|
|
|
+// } else if item.index == NCGlobal.shared.indexPageComments && !commentsEnabled {
|
|
|
+// pagingViewController.contentInteraction = .none
|
|
|
+ } else if itemIndex == .sharing && !sharingEnabled {
|
|
|
pagingViewController.contentInteraction = .none
|
|
|
} else {
|
|
|
self.title = item.title
|
|
@@ -178,20 +179,22 @@ extension NCSharePaging: PagingViewControllerDataSource {
|
|
|
let height = pagingViewController.options.menuHeight + NCSharePagingView.HeaderHeight
|
|
|
let topSafeArea = UIApplication.shared.keyWindow?.safeAreaInsets.top ?? 0
|
|
|
|
|
|
- switch index {
|
|
|
- case NCGlobal.shared.indexPageActivity:
|
|
|
+ switch NCGlobal.NCSharePagingIndex(rawValue: index) {
|
|
|
+ case .activity:
|
|
|
let viewController = UIStoryboard(name: "NCActivity", bundle: nil).instantiateInitialViewController() as! NCActivity
|
|
|
viewController.insets = UIEdgeInsets(top: height - topSafeArea, left: 0, bottom: 0, right: 0)
|
|
|
+ viewController.height = height
|
|
|
viewController.didSelectItemEnable = false
|
|
|
- viewController.filterFileId = metadata.fileId
|
|
|
- viewController.objectType = "files"
|
|
|
- return viewController
|
|
|
- case NCGlobal.shared.indexPageComments:
|
|
|
- let viewController = UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "comments") as! NCShareComments
|
|
|
+// viewController.filterFileId = metadata.fileId
|
|
|
viewController.metadata = metadata
|
|
|
- viewController.height = height
|
|
|
+ viewController.objectType = "files"
|
|
|
return viewController
|
|
|
- case NCGlobal.shared.indexPageSharing:
|
|
|
+// case NCGlobal.shared.indexPageComments:
|
|
|
+// let viewController = UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "comments") as! NCShareComments
|
|
|
+// viewController.metadata = metadata
|
|
|
+// viewController.height = height
|
|
|
+// return viewController
|
|
|
+ case .sharing:
|
|
|
let viewController = UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "sharing") as! NCShare
|
|
|
viewController.sharingEnabled = sharingEnabled
|
|
|
viewController.metadata = metadata
|
|
@@ -204,12 +207,12 @@ extension NCSharePaging: PagingViewControllerDataSource {
|
|
|
|
|
|
func pagingViewController(_: PagingViewController, pagingItemAt index: Int) -> PagingItem {
|
|
|
|
|
|
- switch index {
|
|
|
- case NCGlobal.shared.indexPageActivity:
|
|
|
+ switch NCGlobal.NCSharePagingIndex(rawValue: index) {
|
|
|
+ case .activity:
|
|
|
return PagingIndexItem(index: index, title: NSLocalizedString("_activity_", comment: ""))
|
|
|
- case NCGlobal.shared.indexPageComments:
|
|
|
- return PagingIndexItem(index: index, title: NSLocalizedString("_comments_", comment: ""))
|
|
|
- case NCGlobal.shared.indexPageSharing:
|
|
|
+// case NCGlobal.shared.indexPageComments:
|
|
|
+// return PagingIndexItem(index: index, title: NSLocalizedString("_comments_", comment: ""))
|
|
|
+ case .sharing:
|
|
|
return PagingIndexItem(index: index, title: NSLocalizedString("_sharing_", comment: ""))
|
|
|
default:
|
|
|
return PagingIndexItem(index: index, title: "")
|
|
@@ -217,7 +220,7 @@ extension NCSharePaging: PagingViewControllerDataSource {
|
|
|
}
|
|
|
|
|
|
func numberOfViewControllers(in pagingViewController: PagingViewController) -> Int {
|
|
|
- return 3
|
|
|
+ return 2
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -242,13 +245,11 @@ class NCShareHeaderViewController: PagingViewController {
|
|
|
}
|
|
|
|
|
|
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
- if indexPath.item == NCGlobal.shared.indexPageActivity && !activityEnabled {
|
|
|
+ if NCGlobal.NCSharePagingIndex(rawValue: indexPath.item) == .activity && !activityEnabled {
|
|
|
return
|
|
|
- }
|
|
|
- if indexPath.item == NCGlobal.shared.indexPageComments && !commentsEnabled {
|
|
|
- return
|
|
|
- }
|
|
|
- if indexPath.item == NCGlobal.shared.indexPageSharing && !sharingEnabled {
|
|
|
+// } else if indexPath.item == NCGlobal.shared.indexPageComments && !commentsEnabled {
|
|
|
+// return
|
|
|
+ } else if NCGlobal.NCSharePagingIndex(rawValue: indexPath.item) == .sharing && !sharingEnabled {
|
|
|
return
|
|
|
}
|
|
|
super.collectionView(collectionView, didSelectItemAt: indexPath)
|