Browse Source

move comments UI into activities

(cherry picked from commit ffb107c5076cd818aecbf7bd44907313c87074f2)
Henrik Storch 3 years ago
parent
commit
df1cd02d53

+ 0 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -1791,7 +1791,6 @@
 						ProvisioningStyle = Automatic;
 					};
 					F77B0DEB1D118A16002130FE = {
-						DevelopmentTeam = 6JLRKY9ZV7;
 						LastSwiftMigration = 1020;
 						ProvisioningStyle = Automatic;
 						SystemCapabilities = {

+ 55 - 6
iOSClient/Activity/NCActivity.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="nhT-TJ-YvX">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="nhT-TJ-YvX">
     <device id="retina5_9" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -17,11 +17,11 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="20" sectionFooterHeight="1" translatesAutoresizingMaskIntoConstraints="NO" id="X49-xg-JXO">
-                                <rect key="frame" x="0.0" y="0.0" width="375" height="778"/>
+                                <rect key="frame" x="0.0" y="100" width="375" height="678"/>
                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <prototypes>
                                     <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="tableCell" rowHeight="120" id="ggj-aE-fnh" customClass="activityTableViewCell" customModule="Nextcloud" customModuleProvider="target">
-                                        <rect key="frame" x="0.0" y="24.333333969116211" width="375" height="120"/>
+                                        <rect key="frame" x="0.0" y="44.666666030883789" width="375" height="120"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="ggj-aE-fnh" id="i35-U4-bEk">
                                             <rect key="frame" x="0.0" y="0.0" width="375" height="120"/>
@@ -113,17 +113,66 @@
                                     <outlet property="prefetchDataSource" destination="nhT-TJ-YvX" id="317-AD-uQe"/>
                                 </connections>
                             </tableView>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sG1-7f-3rF">
+                                <rect key="frame" x="0.0" y="0.0" width="375" height="100"/>
+                                <subviews>
+                                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="hVn-Fn-7td">
+                                        <rect key="frame" x="10" y="10" width="40" height="40"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="40" id="eRU-q6-wZT"/>
+                                            <constraint firstAttribute="width" constant="40" id="nee-e2-atl"/>
+                                        </constraints>
+                                    </imageView>
+                                    <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="249" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" clearButtonMode="always" translatesAutoresizingMaskIntoConstraints="NO" id="Wz7-gw-foA">
+                                        <rect key="frame" x="60" y="60" width="305" height="30"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="30" id="4ni-Qx-ber"/>
+                                        </constraints>
+                                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                        <textInputTraits key="textInputTraits"/>
+                                        <connections>
+                                            <action selector="newCommentFieldDidEndOnExitWithTextField:" destination="nhT-TJ-YvX" eventType="editingDidEndOnExit" id="vPB-Eu-qkb"/>
+                                        </connections>
+                                    </textField>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="user" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YRy-AS-CMk">
+                                        <rect key="frame" x="60" y="21.666666666666668" width="305" height="17.000000000000004"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                        <color key="textColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
+                                </subviews>
+                                <constraints>
+                                    <constraint firstItem="YRy-AS-CMk" firstAttribute="centerY" secondItem="hVn-Fn-7td" secondAttribute="centerY" id="CBB-vi-6Z1"/>
+                                    <constraint firstAttribute="trailing" secondItem="Wz7-gw-foA" secondAttribute="trailing" constant="10" id="CuV-5o-sFz"/>
+                                    <constraint firstItem="hVn-Fn-7td" firstAttribute="leading" secondItem="sG1-7f-3rF" secondAttribute="leading" constant="10" id="NWH-NK-FjI"/>
+                                    <constraint firstAttribute="height" constant="100" id="SfP-Sr-vbR"/>
+                                    <constraint firstItem="Wz7-gw-foA" firstAttribute="leading" secondItem="hVn-Fn-7td" secondAttribute="trailing" constant="10" id="baP-t5-Kut"/>
+                                    <constraint firstItem="Wz7-gw-foA" firstAttribute="top" secondItem="hVn-Fn-7td" secondAttribute="bottom" constant="10" id="bsh-yh-NR2"/>
+                                    <constraint firstItem="YRy-AS-CMk" firstAttribute="leading" secondItem="hVn-Fn-7td" secondAttribute="trailing" constant="10" id="chn-JO-eYr"/>
+                                    <constraint firstAttribute="bottom" secondItem="Wz7-gw-foA" secondAttribute="bottom" constant="10" id="e8b-hy-WHK"/>
+                                    <constraint firstAttribute="trailing" secondItem="YRy-AS-CMk" secondAttribute="trailing" constant="10" id="uaN-5Y-k6V"/>
+                                    <constraint firstItem="hVn-Fn-7td" firstAttribute="top" secondItem="sG1-7f-3rF" secondAttribute="top" constant="10" id="yLz-68-e22"/>
+                                </constraints>
+                            </view>
                         </subviews>
                         <viewLayoutGuide key="safeArea" id="USa-eR-a1s"/>
                         <constraints>
-                            <constraint firstItem="USa-eR-a1s" firstAttribute="trailing" secondItem="X49-xg-JXO" secondAttribute="trailing" id="5we-Fh-GVu"/>
-                            <constraint firstItem="X49-xg-JXO" firstAttribute="top" secondItem="vOO-VC-ekK" secondAttribute="top" id="SfR-9z-HeQ"/>
+                            <constraint firstItem="sG1-7f-3rF" firstAttribute="top" secondItem="vOO-VC-ekK" secondAttribute="top" id="0Wu-9f-jFf"/>
+                            <constraint firstItem="X49-xg-JXO" firstAttribute="trailing" secondItem="USa-eR-a1s" secondAttribute="trailing" id="5we-Fh-GVu"/>
                             <constraint firstItem="USa-eR-a1s" firstAttribute="bottom" secondItem="X49-xg-JXO" secondAttribute="bottom" id="aHq-g4-dUG"/>
+                            <constraint firstItem="X49-xg-JXO" firstAttribute="top" secondItem="sG1-7f-3rF" secondAttribute="bottom" id="eeu-9y-t1U"/>
+                            <constraint firstItem="sG1-7f-3rF" firstAttribute="trailing" secondItem="vOO-VC-ekK" secondAttribute="trailing" id="htz-S1-01v"/>
+                            <constraint firstItem="sG1-7f-3rF" firstAttribute="leading" secondItem="vOO-VC-ekK" secondAttribute="leading" id="lLm-NY-aXQ"/>
                             <constraint firstItem="X49-xg-JXO" firstAttribute="leading" secondItem="USa-eR-a1s" secondAttribute="leading" id="pfF-ag-f7x"/>
                         </constraints>
                     </view>
                     <connections>
+                        <outlet property="commentView" destination="sG1-7f-3rF" id="Nip-au-Ilu"/>
+                        <outlet property="imageItem" destination="hVn-Fn-7td" id="tqx-nV-WfA"/>
+                        <outlet property="labelUser" destination="YRy-AS-CMk" id="ijz-je-fBV"/>
+                        <outlet property="newCommentField" destination="Wz7-gw-foA" id="PDr-8b-iQY"/>
                         <outlet property="tableView" destination="X49-xg-JXO" id="GUb-8b-mIS"/>
+                        <outlet property="viewContainerConstraint" destination="0Wu-9f-jFf" id="TGF-fh-T7Y"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="UOE-pW-DRy" userLabel="First Responder" sceneMemberID="firstResponder"/>

+ 84 - 18
iOSClient/Activity/NCActivity.swift

@@ -29,6 +29,15 @@ class NCActivity: UIViewController, NCEmptyDataSetDelegate {
     
     @IBOutlet weak var tableView: UITableView!
 
+
+    @IBOutlet weak var commentView: UIView!
+    @IBOutlet weak var imageItem: UIImageView!
+    @IBOutlet weak var labelUser: UILabel!
+    @IBOutlet weak var newCommentField: UITextField!
+    @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint!
+    var height: CGFloat = 0
+    var metadata: tableMetadata?
+
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
     var emptyDataSet: NCEmptyDataSet?
@@ -38,7 +47,7 @@ class NCActivity: UIViewController, NCEmptyDataSetDelegate {
     var sectionDate: [Date] = []
     var insets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
     var didSelectItemEnable: Bool = true
-    var filterFileId: String?
+//    var filterFileId: String?
     var objectType: String?
     
     var canFetchActivity = true
@@ -65,6 +74,34 @@ class NCActivity: UIViewController, NCEmptyDataSetDelegate {
         NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         
         changeTheming()
+        
+        setupComments()
+    }
+    
+    func setupComments() {
+        newCommentField.placeholder = NSLocalizedString("_new_comment_", comment: "")
+        viewContainerConstraint.constant = height
+
+        // Display Name user & Quota
+        guard let activeAccount = NCManageDatabase.shared.getActiveAccount(), height > 0 else {
+            commentView.isHidden = true
+            return
+        }
+        
+        let fileName = String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + appDelegate.user + ".png"
+        let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+        if let image = UIImage(contentsOfFile: fileNameLocalPath) {
+            imageItem.image = image
+        } else {
+            imageItem.image = UIImage(named: "avatar")
+        }
+        
+        if activeAccount.displayName.isEmpty {
+            labelUser.text = activeAccount.user
+        } else {
+            labelUser.text = activeAccount.displayName
+        }
+        labelUser.textColor = NCBrandColor.shared.label
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -107,6 +144,23 @@ class NCActivity: UIViewController, NCEmptyDataSetDelegate {
         view.emptyTitle.text = NSLocalizedString("_no_activity_", comment: "")
         view.emptyDescription.text = ""
     }
+    
+    @IBAction func newCommentFieldDidEndOnExit(textField: UITextField) {
+        guard
+            let message = textField.text,
+            !message.isEmpty,
+            let metadata = self.metadata else { return }
+
+        NCCommunication.shared.putComments(fileId: metadata.fileId, message: message) { (account, errorCode, errorDescription) in
+            if errorCode == 0 {
+                self.newCommentField.text = ""
+                //TODO:...
+//                self.reloadData()
+            } else {
+                NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
+            }
+        }
+    }
 }
 
 class activityTableViewCell: UITableViewCell, NCCellProtocol {
@@ -567,7 +621,9 @@ extension NCActivity {
         
         sectionDate.removeAll()
         
-        let activities = NCManageDatabase.shared.getActivity(predicate: NSPredicate(format: "account == %@", appDelegate.account), filterFileId: filterFileId)
+        let activities = NCManageDatabase.shared.getActivity(
+            predicate: NSPredicate(format: "account == %@", appDelegate.account),
+            filterFileId: metadata?.fileId)
         allActivities = activities.all
         filterActivities = activities.filter
         for tableActivity in filterActivities {
@@ -589,7 +645,12 @@ extension NCActivity {
             return Calendar.current.date(byAdding: components, to: startDate)!
         }()
         
-        let activities = NCManageDatabase.shared.getActivity(predicate: NSPredicate(format: "account == %@ && date BETWEEN %@", appDelegate.account, [startDate, endDate]), filterFileId: filterFileId)
+        let activities = NCManageDatabase.shared.getActivity(
+            predicate: NSPredicate(
+                format: "account == %@ && date BETWEEN %@",
+                appDelegate.account,
+                [startDate, endDate]),
+            filterFileId: metadata?.fileId)
         return activities.filter
     }
     
@@ -604,21 +665,26 @@ extension NCActivity {
             NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: height + 50, style: .gray)
         }
         
-        NCCommunication.shared.getActivity(since: idActivity, limit: 200, objectId: filterFileId, objectType: objectType, previews: true) { (account, activities, errorCode, errorDescription) in
-            
-           if errorCode == 0 && account == self.appDelegate.account {
-                NCManageDatabase.shared.addActivity(activities , account: account)
-            }
-            
-            NCUtility.shared.stopActivityIndicator()
-            
-            if errorCode == NCGlobal.shared.errorNotModified {
-                self.canFetchActivity = false
-            } else {
-                self.canFetchActivity = true
+        NCCommunication.shared.getActivity(
+            since: idActivity,
+            limit: 200,
+            objectId: metadata?.fileId,
+            objectType: objectType,
+            previews: true) { (account, activities, errorCode, errorDescription) in
+                
+                if errorCode == 0 && account == self.appDelegate.account {
+                    NCManageDatabase.shared.addActivity(activities , account: account)
+                }
+                
+                NCUtility.shared.stopActivityIndicator()
+                
+                if errorCode == NCGlobal.shared.errorNotModified {
+                    self.canFetchActivity = false
+                } else {
+                    self.canFetchActivity = true
+                }
+                
+                self.loadDataSource()
             }
-            
-            self.loadDataSource()
-        }
     }
 }

+ 1 - 1
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -817,7 +817,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if isEditMode { return }
         guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) else { return }
         
-        NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: 2)
+        NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: .sharing)
     }
         
     func tapMoreGridItem(with objectId: String, namedButtonMore: String, image: UIImage?, sender: Any) {

+ 2 - 2
iOSClient/Main/NCFunctionCenter.swift

@@ -187,7 +187,7 @@ import Queuer
     
     // MARK: -
 
-    func openShare(ViewController: UIViewController, metadata: tableMetadata, indexPage: Int) {
+    func openShare(ViewController: UIViewController, metadata: tableMetadata, indexPage: NCGlobal.NCSharePagingIndex) {
         
         let shareNavigationController = UIStoryboard(name: "NCShare", bundle: nil).instantiateInitialViewController() as! UINavigationController
         let shareViewController = shareNavigationController.topViewController as! NCSharePaging
@@ -643,7 +643,7 @@ import Queuer
         }
         
         let detail = UIAction(title: NSLocalizedString("_details_", comment: ""), image: UIImage(systemName: "info")) { action in
-            self.openShare(ViewController: viewController, metadata: metadata, indexPage: 0)
+            self.openShare(ViewController: viewController, metadata: metadata, indexPage: .activity)
         }
         
         let offline = UIAction(title: titleOffline, image: UIImage(systemName: "tray.and.arrow.down")) { action in

+ 1 - 1
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -117,7 +117,7 @@ extension NCCollectionViewCommon {
                     title: NSLocalizedString("_details_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "info"),
                     action: { menuAction in
-                        NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: 0)
+                        NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: .activity)
                     }
                 )
             )

+ 1 - 1
iOSClient/Menu/NCViewer+Menu.swift

@@ -80,7 +80,7 @@ extension NCViewer {
                     title: NSLocalizedString("_details_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "info"),
                     action: { menuAction in
-                        NCFunctionCenter.shared.openShare(ViewController: viewController, metadata: metadata, indexPage: 0)
+                        NCFunctionCenter.shared.openShare(ViewController: viewController, metadata: metadata, indexPage: .activity)
                     }
                 )
             )

+ 4 - 4
iOSClient/NCGlobal.swift

@@ -141,10 +141,10 @@ class NCGlobal: NSObject {
     
     // NCSharePaging
     //
-    let indexPageActivity: Int                      = 0
-    let indexPageComments: Int                      = 1
-    let indexPageSharing: Int                       = 2
-    
+    enum NCSharePagingIndex: Int, CaseIterable {
+        case activity, /*commets, */ sharing
+    }
+
     // NCViewerProviderContextMenu
     //
     let maxAutoDownload: UInt64                     = 50000000      // 50MB

+ 1 - 1
iOSClient/RichWorkspace/NCViewerRichWorkspaceWebView.swift

@@ -85,7 +85,7 @@ class NCViewerRichWorkspaceWebView: UIViewController, WKNavigationDelegate, WKSc
             
             if message.body as? String == "share" {
                 if (metadata != nil) {
-                    NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata!, indexPage: 2)
+                    NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata!, indexPage: .sharing)
                 }
             }
             

+ 2 - 2
iOSClient/Share/NCShare.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Ts3-RO-A9l">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Ts3-RO-A9l">
     <device id="retina5_5" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>

+ 42 - 41
iOSClient/Share/NCSharePaging.swift

@@ -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)

+ 1 - 1
iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift

@@ -159,7 +159,7 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
             }
             
             if message.body as? String == "share" {
-                NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: 2)
+                NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: .sharing)
             }
             
             if message.body as? String == "loading" {

+ 1 - 1
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

@@ -181,7 +181,7 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
             }
             
             if message.body as? String == "share" {
-                NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: 2)
+                NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: .sharing)
             }
             
             if let param = message.body as? Dictionary<AnyHashable,Any> {