Ver código fonte

Fix files lock NCMenu & l18n

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 anos atrás
pai
commit
627b227d0e

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

@@ -77,7 +77,7 @@ extension NCCollectionViewCommon {
             let lockTime = DateFormatter.localizedString(from: metadata.lockTime ?? Date(), dateStyle: .short, timeStyle: .short)
             actions.append(
                 NCMenuAction(
-                    title: String(format: NSLocalizedString("_file_locked_by_at_", comment: ""), lockOwnerName, lockTime),
+                    title: String(format: NSLocalizedString("_locked_by_at_", comment: ""), lockOwnerName, lockTime),
                     icon: NCUtility.shared.loadUserImage(
                         for: metadata.lockOwner,
                            displayName: lockOwnerName,

+ 2 - 2
iOSClient/Menu/NCMenu+FloatingPanel.swift

@@ -38,7 +38,7 @@ class NCMenuFloatingPanelLayout: FloatingPanelLayout {
 
     let topInset: CGFloat
 
-    init(numberOfActions: Int) {
+    init(actionsHeight: CGFloat) {
         // sometimes UIScreen.main.bounds.size.height is not updated correctly
         // this ensures we use the correct height value
         // can't use `layoutFor size` since menu is dieplayed on top of the whole screen not just the VC
@@ -46,7 +46,7 @@ class NCMenuFloatingPanelLayout: FloatingPanelLayout {
         ? min(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height)
         : max(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height)
         let bottomInset = UIApplication.shared.keyWindow?.rootViewController?.view.safeAreaInsets.bottom ?? 0
-        let panelHeight = CGFloat(numberOfActions * 60) + bottomInset
+        let panelHeight = CGFloat(actionsHeight) + bottomInset
 
         topInset = max(48, screenHeight - panelHeight)
     }

+ 7 - 3
iOSClient/Menu/NCMenu.swift

@@ -28,6 +28,10 @@
 import UIKit
 import FloatingPanel
 
+extension Array where Element == NCMenuAction {
+    var listHeight: CGFloat { reduce(0, { $0 + $1.rowHeight }) }
+}
+
 class NCMenu: UITableViewController {
 
     var actions = [NCMenuAction]()
@@ -94,17 +98,17 @@ class NCMenu: UITableViewController {
     // MARK: - Tabel View Layout
 
     override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
-        actions[indexPath.row].title == NCMenuAction.seperatorIdentifier ? 3 : 60
+        actions[indexPath.row].rowHeight
     }
 }
 extension NCMenu: FloatingPanelControllerDelegate {
 
     func floatingPanel(_ fpc: FloatingPanelController, layoutFor size: CGSize) -> FloatingPanelLayout {
-        return NCMenuFloatingPanelLayout(numberOfActions: self.actions.count)
+        return NCMenuFloatingPanelLayout(actionsHeight: self.actions.listHeight)
     }
 
     func floatingPanel(_ fpc: FloatingPanelController, layoutFor newCollection: UITraitCollection) -> FloatingPanelLayout {
-        return NCMenuFloatingPanelLayout(numberOfActions: self.actions.count)
+        return NCMenuFloatingPanelLayout(actionsHeight: self.actions.listHeight)
     }
 
     func floatingPanel(_ fpc: FloatingPanelController, animatorForDismissingWith velocity: CGVector) -> UIViewPropertyAnimator {

+ 1 - 0
iOSClient/Menu/NCMenuAction.swift

@@ -18,6 +18,7 @@ class NCMenuAction {
     var selected: Bool = false
     var isOn: Bool = false
     var action: ((_ menuAction: NCMenuAction) -> Void)?
+    var rowHeight: CGFloat { self.title == NCMenuAction.seperatorIdentifier ? 3 : 60 }
 
     init(title: String, icon: UIImage, action: ((_ menuAction: NCMenuAction) -> Void)?) {
         self.title = title

+ 1 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -152,7 +152,7 @@
 "_unlock_file_"                     = "Unock file";
 "_lock_selected_files_"             = "Lock files";
 "_unlock_selected_files_"           = "Unock files";
-"_file_locked_by_at_"                  = "File locked by %@ at %@";
+"_locked_by_at_"                    = "Locked by %@ at %@";
 
 /* Remove a file from a list, don't delete it entirely */
 "_remove_file_"             = "Remove file";