浏览代码

Fix Share paging UI for landscape orientation

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 年之前
父节点
当前提交
37bfb6699f
共有 1 个文件被更改,包括 17 次插入5 次删除
  1. 17 5
      iOSClient/Share/NCSharePaging.swift

+ 17 - 5
iOSClient/Share/NCSharePaging.swift

@@ -110,6 +110,7 @@ class NCSharePaging: UIViewController {
         self.title = pagingIndexItem.title
         self.title = pagingIndexItem.title
 
 
         NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(self.orientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil)
         changeTheming()
         changeTheming()
     }
     }
 
 
@@ -131,11 +132,22 @@ class NCSharePaging: UIViewController {
         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl])
         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl])
     }
     }
 
 
+    deinit {
+       NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil)
+    }
+
     @objc func exitTapped() {
     @objc func exitTapped() {
         self.dismiss(animated: true, completion: nil)
         self.dismiss(animated: true, completion: nil)
     }
     }
 
 
-    // MARK: - NotificationCenter
+    //MARK: - NotificationCenter
+
+    @objc func orientationDidChange() {
+        print(#function, self.view.bounds.width, view.frame.width)
+        pagingViewController.menuItemSize = .fixed(
+            width: self.view.bounds.width / CGFloat(NCGlobal.NCSharePagingIndex.allCases.count),
+            height: 40)
+    }
 
 
     @objc func changeTheming() {
     @objc func changeTheming() {
         pagingViewController.indicatorColor = NCBrandColor.shared.brandElement
         pagingViewController.indicatorColor = NCBrandColor.shared.brandElement
@@ -170,8 +182,8 @@ extension NCSharePaging: PagingViewControllerDelegate {
 extension NCSharePaging: PagingViewControllerDataSource {
 extension NCSharePaging: PagingViewControllerDataSource {
 
 
     func pagingViewController(_: PagingViewController, viewControllerAt index: Int) -> UIViewController {
     func pagingViewController(_: PagingViewController, viewControllerAt index: Int) -> UIViewController {
-
-        let height = pagingViewController.options.menuHeight + NCSharePagingView.HeaderHeight
+    
+        let height = pagingViewController.options.menuHeight + NCSharePagingView.headerHeight
 
 
         switch NCGlobal.NCSharePagingIndex(rawValue: index) {
         switch NCGlobal.NCSharePagingIndex(rawValue: index) {
         case .activity:
         case .activity:
@@ -242,7 +254,7 @@ class NCShareHeaderViewController: PagingViewController {
 
 
 class NCSharePagingView: PagingView {
 class NCSharePagingView: PagingView {
     
     
-    static let HeaderHeight: CGFloat = 100
+    static let headerHeight: CGFloat = 100
     var metadata = tableMetadata()
     var metadata = tableMetadata()
 
 
     var headerHeightConstraint: NSLayoutConstraint?
     var headerHeightConstraint: NSLayoutConstraint?
@@ -293,7 +305,7 @@ class NCSharePagingView: PagingView {
         headerView.translatesAutoresizingMaskIntoConstraints = false
         headerView.translatesAutoresizingMaskIntoConstraints = false
 
 
         headerHeightConstraint = headerView.heightAnchor.constraint(
         headerHeightConstraint = headerView.heightAnchor.constraint(
-            equalToConstant: NCSharePagingView.HeaderHeight
+            equalToConstant: NCSharePagingView.headerHeight
         )
         )
         headerHeightConstraint?.isActive = true
         headerHeightConstraint?.isActive = true