Browse Source

user status

marinofaggiana 3 years ago
parent
commit
0ab65178ba

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

@@ -213,6 +213,13 @@
 "_set_status_message_"      = "Set status message";
 "_clear_status_message_after_"  = "Clear status message after";
 
+/* User status */
+"_dont_clear_"              = "Don't clear";
+"_30_minutes_"              = "30 minutes";
+"_1_hour_"                  = "1 hour";
+"_4_hours_"                 = "4 hours";
+"today"                     = "Today";
+
 "_network_available_"       = "Network available";
 "_network_not_available_"   = "Network unavailable";
 "_file_too_big_"            = "File too large to be encrypted/decrypted";

+ 36 - 10
iOSClient/UserStatus/NCUserStatus.swift

@@ -307,23 +307,49 @@ extension NCUserStatus: UITableViewDataSource {
         let status = statusPredefinedStatuses[indexPath.row]
         
         let icon = cell.viewWithTag(10) as! UILabel
+        let message = cell.viewWithTag(20) as! UILabel
+
         icon.text = status.icon
+        var timeString = getPredefinedClearStatusText(clearAt: status.clearAt, clearAtTime: status.clearAtTime, clearAtType: status.clearAtType)
 
-        let message = cell.viewWithTag(20) as! UILabel
         if let messageText = status.message {
             
             message.text = messageText
-            
-            if var timeString = status.clearAtTime {
-                
-                timeString = " - " + timeString
-                
-                let attributedString: NSMutableAttributedString = NSMutableAttributedString(string: messageText + timeString)
-                attributedString.setColor(color: .lightGray, font: UIFont.systemFont(ofSize: 15), forText: timeString)
-                message.attributedText = attributedString
-            }
+            timeString = " - " + timeString
+
+            let attributedString: NSMutableAttributedString = NSMutableAttributedString(string: messageText + timeString)
+            attributedString.setColor(color: .lightGray, font: UIFont.systemFont(ofSize: 15), forText: timeString)
+            message.attributedText = attributedString
         }
     
         return cell
     }
+    
+    func getPredefinedClearStatusText(clearAt: NSDate?, clearAtTime: String?, clearAtType: String?) -> String {
+             
+        // Date
+        if clearAt != nil {
+            
+        }
+        
+        // Period
+        if clearAt == nil && clearAtType == "period" {
+            
+            switch clearAtTime {
+            case "3600":
+                return NSLocalizedString("_1_hour_", comment: "")
+            case "1800":
+                return NSLocalizedString("_30_minutes_", comment: "")
+            default:
+                return NSLocalizedString("_dont_clear_", comment: "")
+            }
+        }
+        
+        // End of
+        if clearAt == nil && clearAtTime != nil && clearAtType == "end-of" {
+            return NSLocalizedString(clearAtTime!, comment: "")
+        }
+        
+        return NSLocalizedString("_dont_clear_", comment: "")
+    }
 }