|
@@ -25,11 +25,190 @@ import Foundation
|
|
|
import Parchment
|
|
|
|
|
|
class NCShare: UIViewController {
|
|
|
+
|
|
|
+ private let pagingViewController = NCShareHeaderViewController()
|
|
|
+
|
|
|
+ @objc var metadata: tableMetadata?
|
|
|
+ @objc var shareLink: String = ""
|
|
|
+ @objc var shareUserAndGroup: String = ""
|
|
|
+
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
let storyboard = UIStoryboard(name: "NCShare", bundle: nil)
|
|
|
+
|
|
|
+ let activityViewController = storyboard.instantiateViewController(withIdentifier: "activity")
|
|
|
+ let commentsViewController = storyboard.instantiateViewController(withIdentifier: "comments")
|
|
|
+ let sharingViewController = storyboard.instantiateViewController(withIdentifier: "sharing")
|
|
|
+
|
|
|
+ let pagingViewController = FixedPagingViewController(viewControllers: [
|
|
|
+ activityViewController,
|
|
|
+ commentsViewController,
|
|
|
+ sharingViewController
|
|
|
+ ])
|
|
|
+
|
|
|
+ addChild(pagingViewController)
|
|
|
+ view.addSubview(pagingViewController.view)
|
|
|
+ pagingViewController.didMove(toParent: self)
|
|
|
+
|
|
|
+ pagingViewController.selectedTextColor = .black
|
|
|
+ pagingViewController.indicatorColor = .black
|
|
|
+ pagingViewController.indicatorOptions = .visible(
|
|
|
+ height: 1,
|
|
|
+ zIndex: Int.max,
|
|
|
+ spacing: .zero,
|
|
|
+ insets: .zero
|
|
|
+ )
|
|
|
+
|
|
|
+ // Contrain the paging view to all edges.
|
|
|
+ pagingViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ NSLayoutConstraint.activate([
|
|
|
+ pagingViewController.view.topAnchor.constraint(equalTo: view.topAnchor),
|
|
|
+ pagingViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
|
|
+ pagingViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
|
|
+ pagingViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
|
|
+ ])
|
|
|
+
|
|
|
+ var image = CCGraphics.changeThemingColorImage(UIImage(named: "exit")!, width: 40, height: 40, color: UIColor.gray)
|
|
|
+ image = image?.withRenderingMode(.alwaysOriginal)
|
|
|
+ self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: image, style:.plain, target: self, action: #selector(exitTapped))
|
|
|
+
|
|
|
+ let iconFileExists = FileManager.default.fileExists(atPath: CCUtility.getDirectoryProviderStorageIconFileID(metadata?.fileID, fileNameView: metadata?.fileNameView))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ if iconFileExists {
|
|
|
+
|
|
|
+ cell.file.image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(metadata.fileID, fileNameView: metadata.fileNameView))
|
|
|
+ } else {
|
|
|
+ if metadata.iconName.count > 0 {
|
|
|
+ cell.file.image = UIImage.init(named: metadata.iconName)
|
|
|
+ } else {
|
|
|
+ cell.file.image = UIImage.init(named: "file")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ // Set our data source and delegate.
|
|
|
+ pagingViewController.dataSource = self
|
|
|
+ pagingViewController.delegate = self
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func exitTapped() {
|
|
|
+ self.dismiss(animated: true, completion: nil)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension NCShare: PagingViewControllerDataSource {
|
|
|
+
|
|
|
+ func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, viewControllerForIndex index: Int) -> UIViewController {
|
|
|
+ let viewController = TableViewController()
|
|
|
+
|
|
|
+ // Inset the table view with the height of the menu height.
|
|
|
+ let height = pagingViewController.options.menuHeight + CustomPagingView.HeaderHeight
|
|
|
+ let insets = UIEdgeInsets(top: height, left: 0, bottom: 0, right: 0)
|
|
|
+ viewController.tableView.contentInset = insets
|
|
|
+ viewController.tableView.scrollIndicatorInsets = insets
|
|
|
+ viewController.tableView.delegate = self
|
|
|
+
|
|
|
+ return viewController
|
|
|
+ }
|
|
|
+
|
|
|
+ func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, pagingItemForIndex index: Int) -> T {
|
|
|
+ return PagingIndexItem(index: index, title: "View \(index)") as! T
|
|
|
+ }
|
|
|
+
|
|
|
+ func numberOfViewControllers<T>(in: PagingViewController<T>) -> Int{
|
|
|
+ return 3
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
+extension NCShare: PagingViewControllerDelegate {
|
|
|
+
|
|
|
+ func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, didScrollToItem pagingItem: T, startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) {
|
|
|
+ guard let startingViewController = startingViewController as? TableViewController else { return }
|
|
|
+ guard let destinationViewController = destinationViewController as? TableViewController else { return }
|
|
|
+
|
|
|
+ // Set the delegate on the currently selected view so that we can
|
|
|
+ // listen to the scroll view delegate.
|
|
|
+ if transitionSuccessful {
|
|
|
+ startingViewController.tableView.delegate = nil
|
|
|
+ destinationViewController.tableView.delegate = self
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, willScrollToItem pagingItem: T, startingViewController: UIViewController, destinationViewController: UIViewController) {
|
|
|
+ guard let destinationViewController = destinationViewController as? TableViewController else { return }
|
|
|
+
|
|
|
+ // Update the content offset based on the height of the header view.
|
|
|
+ if let pagingView = pagingViewController.view as? CustomPagingView {
|
|
|
+ if let headerHeight = pagingView.headerHeightConstraint?.constant {
|
|
|
+ let offset = headerHeight + pagingViewController.options.menuHeight
|
|
|
+ destinationViewController.tableView.contentOffset = CGPoint(x: 0, y: -offset)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
+class NCShareHeaderViewController: PagingViewController<PagingIndexItem> {
|
|
|
+
|
|
|
+ public var image: UIImage?
|
|
|
+ func setx() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override func loadView() {
|
|
|
+ view = NCShareHeader(
|
|
|
+ options: options,
|
|
|
+ collectionView: collectionView,
|
|
|
+ pageView: pageViewController.view
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class NCShareHeader: PagingView {
|
|
|
+
|
|
|
+ static let HeaderHeight: CGFloat = 200
|
|
|
+ var image: UIImage?
|
|
|
+
|
|
|
+ var headerHeightConstraint: NSLayoutConstraint?
|
|
|
+
|
|
|
+ private lazy var headerView: UIImageView = {
|
|
|
+ let view = UIImageView(image: UIImage(named: "file"))
|
|
|
+ view.contentMode = .scaleAspectFill
|
|
|
+ view.clipsToBounds = true
|
|
|
+ return view
|
|
|
+ }()
|
|
|
+
|
|
|
+ override func setupConstraints() {
|
|
|
+ addSubview(headerView)
|
|
|
+
|
|
|
+ pageView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ collectionView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ headerView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+
|
|
|
+ headerHeightConstraint = headerView.heightAnchor.constraint(
|
|
|
+ equalToConstant: NCShareHeader.HeaderHeight
|
|
|
+ )
|
|
|
+ headerHeightConstraint?.isActive = true
|
|
|
+
|
|
|
+ NSLayoutConstraint.activate([
|
|
|
+ collectionView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
|
+ collectionView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
|
|
+ collectionView.heightAnchor.constraint(equalToConstant: options.menuHeight),
|
|
|
+ collectionView.topAnchor.constraint(equalTo: headerView.bottomAnchor),
|
|
|
+
|
|
|
+ headerView.topAnchor.constraint(equalTo: topAnchor),
|
|
|
+ headerView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
|
+ headerView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
|
|
+
|
|
|
+ pageView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
|
+ pageView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
|
|
+ pageView.bottomAnchor.constraint(equalTo: bottomAnchor),
|
|
|
+ pageView.topAnchor.constraint(equalTo: topAnchor)
|
|
|
+ ])
|
|
|
+ }
|
|
|
}
|