Browse Source

Menu color

Marino Faggiana 1 year ago
parent
commit
9526ba5b39

+ 10 - 1
iOSClient/Menu/NCMenu.swift

@@ -35,10 +35,14 @@ extension Array where Element == NCMenuAction {
 class NCMenu: UITableViewController {
 
     var actions = [NCMenuAction]()
+    var menuColor = UIColor.systemBackground
+    var textColor = UIColor.label
 
-    static func makeNCMenu(with actions: [NCMenuAction]) -> NCMenu? {
+    static func makeNCMenu(with actions: [NCMenuAction], menuColor: UIColor, textColor: UIColor) -> NCMenu? {
         let menuViewController = UIStoryboard(name: "NCMenu", bundle: nil).instantiateInitialViewController() as? NCMenu
         menuViewController?.actions = actions
+        menuViewController?.menuColor = menuColor
+        menuViewController?.textColor = textColor
         return menuViewController
     }
 
@@ -48,6 +52,7 @@ class NCMenu: UITableViewController {
         super.viewDidLoad()
         tableView.estimatedRowHeight = 60
         tableView.rowHeight = UITableView.automaticDimension
+        self.view.backgroundColor = menuColor
     }
 
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
@@ -77,6 +82,7 @@ class NCMenu: UITableViewController {
         }
         let cell = tableView.dequeueReusableCell(withIdentifier: "menuActionCell", for: indexPath)
         cell.tintColor = NCBrandColor.shared.customer
+        cell.backgroundColor = menuColor
         let actionIconView = cell.viewWithTag(1) as? UIImageView
         let actionNameLabel = cell.viewWithTag(2) as? UILabel
         let actionDetailLabel = cell.viewWithTag(3) as? UILabel
@@ -86,15 +92,18 @@ class NCMenu: UITableViewController {
         }
         if let details = action.details {
             actionDetailLabel?.text = details
+            actionDetailLabel?.textColor = textColor
             actionNameLabel?.isHidden = false
         } else { actionDetailLabel?.isHidden = true }
 
         if action.isOn {
             actionIconView?.image = action.onIcon
             actionNameLabel?.text = action.onTitle
+            actionNameLabel?.textColor = textColor
         } else {
             actionIconView?.image = action.icon
             actionNameLabel?.text = action.title
+            actionNameLabel?.textColor = textColor
         }
 
         cell.accessoryType = action.selectable && action.selected ? .checkmark : .none

+ 2 - 2
iOSClient/Menu/UIViewController+Menu.swift

@@ -108,10 +108,10 @@ extension UIViewController {
         present(mail, animated: true)
     }
 
-    func presentMenu(with actions: [NCMenuAction]) {
+    func presentMenu(with actions: [NCMenuAction], menuColor: UIColor = .systemBackground, textColor: UIColor = .label) {
         guard !actions.isEmpty else { return }
         let actions = actions.sorted(by: { $0.order < $1.order })
-        guard let menuViewController = NCMenu.makeNCMenu(with: actions) else {
+        guard let menuViewController = NCMenu.makeNCMenu(with: actions, menuColor: menuColor, textColor: textColor) else {
             let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_internal_generic_error_")
             NCContentPresenter.shared.showError(error: error)
             return

+ 2 - 2
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift

@@ -334,7 +334,7 @@ extension NCPlayerToolBar {
             )
         }
 
-        viewerMediaPage?.presentMenu(with: actions)
+        viewerMediaPage?.presentMenu(with: actions, menuColor: .darkGray, textColor: .white)
     }
 
     func toggleMenuAudio(audioTracks: [Any], audioTrackIndexes: [Any]) {
@@ -365,6 +365,6 @@ extension NCPlayerToolBar {
             )
         }
 
-        viewerMediaPage?.presentMenu(with: actions)
+        viewerMediaPage?.presentMenu(with: actions, menuColor: .darkGray, textColor: .white)
     }
 }