marinofaggiana 3 лет назад
Родитель
Сommit
f78f0947fd

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -2893,7 +2893,7 @@
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			requirement = {
 				kind = revision;
-				revision = c65493b6e3177fa4cdbf313d5181c671b4772367;
+				revision = 8a28c2ee90ca3a26b9220425cbe170a9a5ed86f1;
 			};
 		};
 		F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {

+ 1 - 1
Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -105,7 +105,7 @@
         "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "state": {
           "branch": null,
-          "revision": "c65493b6e3177fa4cdbf313d5181c671b4772367",
+          "revision": "8a28c2ee90ca3a26b9220425cbe170a9a5ed86f1",
           "version": null
         }
       },

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

@@ -207,6 +207,8 @@
 
 /* User status */
 "_status_message_"          = "Status message";
+"_status_message_placehorder_"  = "Wath's your status?";
+"_online_status_"           = "Online status";
 
 "_network_available_"       = "Network available";
 "_network_not_available_"   = "Network unavailable";

+ 25 - 0
iOSClient/UserStatus/NCUserStatus.storyboard

@@ -197,19 +197,42 @@
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
+                            <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="😀" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="A55-9l-wXo" customClass="emojiTextField" customModule="Nextcloud" customModuleProvider="target">
+                                <rect key="frame" x="10" y="319" width="32" height="34"/>
+                                <color key="backgroundColor" systemColor="systemGray6Color"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="34" id="aOa-cO-Bhd"/>
+                                    <constraint firstAttribute="width" constant="32" id="lgT-iI-Zr7"/>
+                                </constraints>
+                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                <textInputTraits key="textInputTraits"/>
+                            </textField>
+                            <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="what's your status?" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="qXf-nl-3Li">
+                                <rect key="frame" x="43" y="319" width="366" height="34"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="34" id="0in-EY-eBM"/>
+                                </constraints>
+                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                <textInputTraits key="textInputTraits"/>
+                            </textField>
                         </subviews>
                         <viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
                         <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                         <constraints>
+                            <constraint firstItem="qXf-nl-3Li" firstAttribute="leading" secondItem="A55-9l-wXo" secondAttribute="trailing" constant="1" id="0Qd-uE-iPa"/>
                             <constraint firstItem="IUw-Rz-hg5" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" constant="20" id="1KK-dw-MTN"/>
                             <constraint firstItem="IUw-Rz-hg5" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" constant="10" id="42H-eC-eCC"/>
                             <constraint firstItem="DgJ-Se-BTI" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" constant="10" id="8KJ-5Z-Y8J"/>
                             <constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="Hed-Bz-0g1" secondAttribute="trailing" constant="10" id="9LY-Ad-ugS"/>
                             <constraint firstItem="ldK-hD-vsJ" firstAttribute="top" secondItem="Hed-Bz-0g1" secondAttribute="bottom" constant="40" id="K8i-hZ-ic0"/>
                             <constraint firstItem="Hed-Bz-0g1" firstAttribute="top" secondItem="ukn-PZ-9sx" secondAttribute="bottom" constant="30" id="LJ2-Qn-qbJ"/>
+                            <constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="qXf-nl-3Li" secondAttribute="trailing" constant="5" id="MLs-tH-cbf"/>
                             <constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="ukn-PZ-9sx" secondAttribute="trailing" constant="10" id="Sxc-Bi-ERz"/>
+                            <constraint firstItem="A55-9l-wXo" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" constant="10" id="TDf-oG-GcP"/>
                             <constraint firstItem="DgJ-Se-BTI" firstAttribute="top" secondItem="7YL-BS-nbc" secondAttribute="bottom" constant="30" id="Vqd-ZX-eQb"/>
                             <constraint firstItem="ldK-hD-vsJ" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" constant="5" id="XMX-Uc-FkN"/>
+                            <constraint firstItem="A55-9l-wXo" firstAttribute="top" secondItem="ldK-hD-vsJ" secondAttribute="bottom" constant="20" id="cSY-18-btJ"/>
+                            <constraint firstItem="qXf-nl-3Li" firstAttribute="top" secondItem="ldK-hD-vsJ" secondAttribute="bottom" constant="20" id="jPk-b5-RCo"/>
                             <constraint firstItem="ukn-PZ-9sx" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" constant="20" id="vBm-Uq-cEs"/>
                             <constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="ldK-hD-vsJ" secondAttribute="trailing" constant="5" id="yZf-48-jHR"/>
                         </constraints>
@@ -230,7 +253,9 @@
                         <outlet property="onlineButton" destination="7YL-BS-nbc" id="X4i-nV-iqB"/>
                         <outlet property="onlineImage" destination="wwP-hA-oHT" id="tv9-3Y-ccU"/>
                         <outlet property="onlineLabel" destination="4dG-pv-efQ" id="9Y2-mc-yZ1"/>
+                        <outlet property="statusMessageEmojiTextField" destination="A55-9l-wXo" id="yTG-lx-gBW"/>
                         <outlet property="statusMessageLabel" destination="ldK-hD-vsJ" id="edn-hK-cYI"/>
+                        <outlet property="statusMessageTextField" destination="qXf-nl-3Li" id="7QS-4i-afV"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>

+ 84 - 1
iOSClient/UserStatus/NCUserStatus.swift

@@ -26,6 +26,7 @@ import UIKit
 import Foundation
 import NCCommunication
 
+@available(iOS 13.0, *)
 class NCUserStatus: UIViewController {
     
     @IBOutlet weak var onlineButton: UIButton!
@@ -48,14 +49,20 @@ class NCUserStatus: UIViewController {
     
     @IBOutlet weak var statusMessageLabel: UILabel!
 
+    @IBOutlet weak var statusMessageEmojiTextField: emojiTextField!
+    @IBOutlet weak var statusMessageTextField: UITextField!
+
     
     // MARK: - View Life Cycle
 
     override func viewDidLoad() {
         super.viewDidLoad()
         
+        self.navigationItem.title = NSLocalizedString("_online_status_", comment: "")
+
         onlineButton.layer.cornerRadius = 10
         onlineButton.layer.masksToBounds = true
+        onlineButton.backgroundColor = NCBrandColor.shared.systemGray6
         //onlineLabel.layer.borderWidth = 0.5
         //onlineLabel.layer.borderColor = NCBrandColor.shared.brand.cgColor
         let onLine = NCUtility.shared.getUserStatus(userIcon: nil, userStatus: "online", userMessage: nil)
@@ -63,9 +70,9 @@ class NCUserStatus: UIViewController {
         onlineLabel.text = onLine.statusMessage
         onlineLabel.textColor = NCBrandColor.shared.label
        
-        
         awayButton.layer.cornerRadius = 10
         awayButton.layer.masksToBounds = true
+        awayButton.backgroundColor = NCBrandColor.shared.systemGray6
         //onlineLabel.layer.borderWidth = 0.5
         //onlineLabel.layer.borderColor = NCBrandColor.shared.brand.cgColor
         let away = NCUtility.shared.getUserStatus(userIcon: nil, userStatus: "away", userMessage: nil)
@@ -75,6 +82,7 @@ class NCUserStatus: UIViewController {
         
         dndButton.layer.cornerRadius = 10
         dndButton.layer.masksToBounds = true
+        dndButton.backgroundColor = NCBrandColor.shared.systemGray6
         //onlineLabel.layer.borderWidth = 0.5
         //onlineLabel.layer.borderColor = NCBrandColor.shared.brand.cgColor
         let dnd = NCUtility.shared.getUserStatus(userIcon: nil, userStatus: "dnd", userMessage: nil)
@@ -86,6 +94,7 @@ class NCUserStatus: UIViewController {
         
         invisibleButton.layer.cornerRadius = 10
         invisibleButton.layer.masksToBounds = true
+        invisibleButton.backgroundColor = NCBrandColor.shared.systemGray6
         //onlineLabel.layer.borderWidth = 0.5
         //onlineLabel.layer.borderColor = NCBrandColor.shared.brand.cgColor
         let offline = NCUtility.shared.getUserStatus(userIcon: nil, userStatus: "offline", userMessage: nil)
@@ -98,6 +107,80 @@ class NCUserStatus: UIViewController {
         statusMessageLabel.text = NSLocalizedString("_status_message_", comment: "")
         statusMessageLabel.textColor = NCBrandColor.shared.label
 
+        statusMessageEmojiTextField.delegate = self
+        statusMessageEmojiTextField.backgroundColor = NCBrandColor.shared.systemGray6
+        
+        statusMessageTextField.placeholder = NSLocalizedString("_status_message_placehorder_", comment: "")
+        statusMessageTextField.textColor = NCBrandColor.shared.label
+        
+        getStatus()
+    }
+    
+    func getStatus() {
+        
+        NCCommunication.shared.getUserStatus { account, clearAt, icon, message, messageId, messageIsPredefined, status, statusIsUserDefined, userId, errorCode, errorDescription in
+            print("")
+        }
+    }
+}
+
+@available(iOS 13.0, *)
+extension NCUserStatus: UITextFieldDelegate {
+    
+    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
+        
+        if textField is emojiTextField {
+        
+            if string.count == 0 {
+                textField.text = "😀"
+                return false
+            }
+            textField.text = string
+        }
+        
+        return true
+    }
+}
+
+@available(iOS 13.0, *)
+class emojiTextField: UITextField {
+
+    // required for iOS 13
+    override var textInputContextIdentifier: String? { "" } // return non-nil to show the Emoji keyboard ¯\_(ツ)_/¯
+
+    override var textInputMode: UITextInputMode? {
+        for mode in UITextInputMode.activeInputModes {
+            if mode.primaryLanguage == "emoji" {
+                return mode
+            }
+        }
+        return nil
+    }
+
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+
+        commonInit()
+    }
+
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
+
+        commonInit()
+    }
+
+    func commonInit() {
+        NotificationCenter.default.addObserver(self, selector: #selector(inputModeDidChange), name: UITextInputMode.currentInputModeDidChangeNotification, object: nil)
+    }
+
+    @objc func inputModeDidChange(_ notification: Notification) {
+        guard isFirstResponder else {
+            return
+        }
+
+        DispatchQueue.main.async { [weak self] in
+            self?.reloadInputViews()
+        }
     }
 }