Browse Source

user status

marinofaggiana 3 years ago
parent
commit
9a6f64bef2

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

@@ -214,6 +214,7 @@
 "_clear_status_message_after_"  = "Clear status message after";
 
 /* User status */
+"_select_option_"           = "Select option";
 "_dont_clear_"              = "Don't clear";
 "_30_minutes_"              = "30 minutes";
 "_an_hour_"                 = "an hour";

+ 44 - 0
iOSClient/UserStatus/NCUserStatus.swift

@@ -25,6 +25,7 @@
 import UIKit
 import Foundation
 import NCCommunication
+import DropDown
 
 @available(iOS 13.0, *)
 class NCUserStatus: UIViewController {
@@ -133,6 +134,9 @@ class NCUserStatus: UIViewController {
         clearStatusMessageAfterText.layer.borderColor = UIColor.lightGray.cgColor
         clearStatusMessageAfterText.text = NSLocalizedString("_dont_clear_", comment: "")
         clearStatusMessageAfterText.textColor = .lightGray
+        let tap = UITapGestureRecognizer(target: self, action: #selector(self.actionClearStatusMessageAfterText(sender:)))
+        clearStatusMessageAfterText.isUserInteractionEnabled = true
+        clearStatusMessageAfterText.addGestureRecognizer(tap)
         
         clearStatusMessageButton.layer.cornerRadius = 15
         clearStatusMessageButton.layer.masksToBounds = true
@@ -229,6 +233,46 @@ class NCUserStatus: UIViewController {
         self.invisibleButton.layer.borderColor = self.borderColorButton
     }
     
+    @objc func actionClearStatusMessageAfterText(sender:UITapGestureRecognizer) {
+
+        let dropDown = DropDown()
+        let appearance = DropDown.appearance()
+        let clearStatusMessageAfterTextBackup = clearStatusMessageAfterText.text
+            
+        appearance.backgroundColor = NCBrandColor.shared.systemBackground
+        appearance.cornerRadius = 5
+        appearance.shadowColor = UIColor(white: 0.5, alpha: 1)
+        appearance.shadowOpacity = 0.9
+        appearance.shadowRadius = 25
+        appearance.animationduration = 0.25
+        appearance.textColor = .darkGray
+        appearance.setupMaskedCorners([.layerMaxXMaxYCorner, .layerMinXMaxYCorner])
+        
+        dropDown.dataSource.append(NSLocalizedString("_dont_clear_", comment: ""))
+        dropDown.dataSource.append(NSLocalizedString("_30_minutes_", comment: ""))
+        dropDown.dataSource.append(NSLocalizedString("_1_hour_", comment: ""))
+        dropDown.dataSource.append(NSLocalizedString("_4_hours_", comment: ""))
+        dropDown.dataSource.append(NSLocalizedString("day", comment: ""))
+        dropDown.dataSource.append(NSLocalizedString("_this_week_", comment: ""))
+
+        dropDown.anchorView = clearStatusMessageAfterText
+        dropDown.topOffset = CGPoint(x: 0, y: -clearStatusMessageAfterText.bounds.height)
+        dropDown.width = clearStatusMessageAfterText.bounds.width
+        dropDown.direction = .top
+        
+        dropDown.selectionAction = { [weak self] (index, item) in
+            print("")
+        }
+        
+        dropDown.cancelAction = { [unowned self] in
+            clearStatusMessageAfterText.text = clearStatusMessageAfterTextBackup
+        }
+        
+        clearStatusMessageAfterText.text = " " + NSLocalizedString("_select_option_", comment: "")
+        
+        dropDown.show()
+    }
+    
     @IBAction func actionClearStatusMessage(_ sender: UIButton) {
         
     }