Эх сурвалжийг харах

#2221

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 жил өмнө
parent
commit
1090a3dc7b

+ 9 - 27
iOSClient/Account Request/NCTalkAccounts.storyboard

@@ -48,44 +48,26 @@
                                             <rect key="frame" x="0.0" y="0.0" width="280" height="60"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
-                                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="10" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="4cH-oC-YBd" userLabel="Avatar">
-                                                    <rect key="frame" x="0.0" y="15" width="30" height="30"/>
-                                                    <constraints>
-                                                        <constraint firstAttribute="height" constant="30" id="Efd-BU-u61"/>
-                                                        <constraint firstAttribute="width" constant="30" id="qFy-Tu-ov6"/>
-                                                    </constraints>
-                                                </imageView>
-                                                <label opaque="NO" userInteractionEnabled="NO" tag="20" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pWI-iZ-BTy" userLabel="User">
-                                                    <rect key="frame" x="40" y="20.333333333333336" width="220" height="19.333333333333336"/>
-                                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
+                                                <label opaque="NO" userInteractionEnabled="NO" tag="10" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pWI-iZ-BTy" userLabel="User">
+                                                    <rect key="frame" x="10" y="21.666666666666668" width="260" height="17.000000000000004"/>
+                                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
-                                                <label opaque="NO" userInteractionEnabled="NO" tag="30" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sWT-NJ-ihR" userLabel="Url">
-                                                    <rect key="frame" x="40" y="40.666666666666664" width="220" height="16"/>
+                                                <label opaque="NO" userInteractionEnabled="NO" tag="20" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sWT-NJ-ihR" userLabel="Url">
+                                                    <rect key="frame" x="10" y="39.666666666666664" width="260" height="16"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="13"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
-                                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="40" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="x47-dQ-alI" userLabel="Active">
-                                                    <rect key="frame" x="265" y="22.666666666666668" width="15" height="15.000000000000004"/>
-                                                    <constraints>
-                                                        <constraint firstAttribute="height" constant="15" id="SXt-LG-c5N"/>
-                                                        <constraint firstAttribute="width" constant="15" id="vdZ-4R-gY5"/>
-                                                    </constraints>
-                                                </imageView>
                                             </subviews>
                                             <constraints>
-                                                <constraint firstItem="4cH-oC-YBd" firstAttribute="leading" secondItem="IkA-cK-iZV" secondAttribute="leading" id="3cz-yE-yoQ"/>
-                                                <constraint firstAttribute="trailing" secondItem="x47-dQ-alI" secondAttribute="trailing" id="Dna-rj-LLQ"/>
-                                                <constraint firstItem="x47-dQ-alI" firstAttribute="centerY" secondItem="IkA-cK-iZV" secondAttribute="centerY" id="Ghs-sZ-Bzf"/>
-                                                <constraint firstItem="sWT-NJ-ihR" firstAttribute="leading" secondItem="4cH-oC-YBd" secondAttribute="trailing" constant="10" id="MxV-Du-vUw"/>
-                                                <constraint firstItem="4cH-oC-YBd" firstAttribute="centerY" secondItem="IkA-cK-iZV" secondAttribute="centerY" id="WuT-iT-3xk"/>
+                                                <constraint firstItem="sWT-NJ-ihR" firstAttribute="leading" secondItem="IkA-cK-iZV" secondAttribute="leading" constant="10" id="ECI-2F-iyI"/>
                                                 <constraint firstItem="sWT-NJ-ihR" firstAttribute="top" secondItem="pWI-iZ-BTy" secondAttribute="bottom" constant="1" id="ZVm-u7-JGI"/>
-                                                <constraint firstItem="x47-dQ-alI" firstAttribute="leading" secondItem="pWI-iZ-BTy" secondAttribute="trailing" constant="5" id="e8E-uH-gvt"/>
+                                                <constraint firstItem="pWI-iZ-BTy" firstAttribute="leading" secondItem="IkA-cK-iZV" secondAttribute="leading" constant="10" id="auF-fg-pYj"/>
+                                                <constraint firstAttribute="trailing" secondItem="pWI-iZ-BTy" secondAttribute="trailing" constant="10" id="dE9-ok-ZJi"/>
+                                                <constraint firstAttribute="trailing" secondItem="sWT-NJ-ihR" secondAttribute="trailing" constant="10" id="g6m-x4-DDa"/>
                                                 <constraint firstItem="pWI-iZ-BTy" firstAttribute="centerY" secondItem="IkA-cK-iZV" secondAttribute="centerY" id="jUS-89-RRO"/>
-                                                <constraint firstItem="x47-dQ-alI" firstAttribute="leading" secondItem="sWT-NJ-ihR" secondAttribute="trailing" constant="5" id="lIk-Sj-EgC"/>
-                                                <constraint firstItem="pWI-iZ-BTy" firstAttribute="leading" secondItem="4cH-oC-YBd" secondAttribute="trailing" constant="10" id="mlI-8s-1Ae"/>
                                             </constraints>
                                         </tableViewCellContentView>
                                         <color key="backgroundColor" systemColor="secondarySystemGroupedBackgroundColor"/>

+ 10 - 49
iOSClient/Account Request/NCTalkAccounts.swift

@@ -25,12 +25,12 @@ import UIKit
 import NextcloudKit
 
 public protocol NCTalkAccountsDelegate: AnyObject {
-    func accountRequestChangeAccount(serverUrl: String, user: String)
+    func selected(url: String, user: String)
 }
 
 // optional func
 public extension NCTalkAccountsDelegate {
-    func accountRequestChangeAccount(serverUrl: String, user: String) {}
+    func selected(url: String, user: String) {}
 }
 
 class NCTalkAccounts: UIViewController {
@@ -55,12 +55,12 @@ class NCTalkAccounts: UIViewController {
     override func viewDidLoad() {
         super.viewDidLoad()
 
-        titleLabel.text = NSLocalizedString("_account_select_", comment: "")
+        titleLabel.text = NSLocalizedString("_account_select_to_add_", comment: "")
 
         closeButton.setImage(NCUtility.shared.loadImage(named: "xmark", color: .label), for: .normal)
 
         tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 1))
-        tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
+        //tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
 
         view.backgroundColor = .secondarySystemBackground
         tableView.backgroundColor = .secondarySystemBackground
@@ -85,9 +85,8 @@ class NCTalkAccounts: UIViewController {
         super.viewDidAppear(animated)
 
         let visibleCells = tableView.visibleCells
-        var numAccounts = accounts.count
 
-        if visibleCells.count == numAccounts {
+        if visibleCells.count == accounts.count {
             tableView.isScrollEnabled = false
         }
     }
@@ -162,26 +161,11 @@ extension NCTalkAccounts: UITableViewDelegate {
 
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
 
-
-
-        /*
-        if indexPath.row == accounts.count {
-
-            dismiss(animated: true)
-            delegate?.accountRequestAddAccount()
-
-        } else {
-
-            let account = accounts[indexPath.row]
-            if account.account != activeAccount?.account {
-                dismiss(animated: true) {
-                    self.delegate?.accountRequestChangeAccount(account: account.account)
-                }
-            } else {
-                dismiss(animated: true)
+        if let account = accounts[indexPath.row].first {
+            dismiss(animated: true) {
+                self.delegate?.selected(url: account.key, user: account.value)
             }
         }
-        */
     }
 }
 
@@ -196,10 +180,8 @@ extension NCTalkAccounts: UITableViewDataSource {
         let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
         cell.backgroundColor = tableView.backgroundColor
 
-        let avatarImage = cell.viewWithTag(10) as? UIImageView
-        let userLabel = cell.viewWithTag(20) as? UILabel
-        let urlLabel = cell.viewWithTag(30) as? UILabel
-        let activeImage = cell.viewWithTag(40) as? UIImageView
+        let userLabel = cell.viewWithTag(10) as? UILabel
+        let urlLabel = cell.viewWithTag(20) as? UILabel
 
         userLabel?.text = ""
         urlLabel?.text = ""
@@ -209,27 +191,6 @@ extension NCTalkAccounts: UITableViewDataSource {
             urlLabel?.text = (URL(string: account.key)?.host ?? "")
         }
 
-        /*
-        let serverUrl = account.keys
-        let user = account.values
-
-        urlLabel?.text = serverUrl
-
-
-        if account.alias.isEmpty {
-            userLabel?.text = account.user.uppercased()
-            urlLabel?.text = (URL(string: account.urlBase)?.host ?? "")
-        } else {
-            userLabel?.text = account.alias.uppercased()
-        }
-
-        if account.active {
-            activeImage?.image = NCUtility.shared.loadImage(named: "checkmark").image(color: .systemBlue, size: 30)
-        } else {
-            activeImage?.image = nil
-        }
-        */
-
         return cell
     }
 }

+ 12 - 5
iOSClient/Login/NCLogin.swift

@@ -130,7 +130,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         appDelegate.timerErrorNetworking?.invalidate()
 
         // test
-        //createTalkAccount()
+        createTalkAccount()
 
         if let talkAccounts = readTalkAccounts(), let image = UIImage(named: "talk"), let backgroundColor =  NCBrandColor.shared.brandElement.lighter(by: 10) {
             NCContentPresenter.shared.alertAction(image: image, backgroundColor: backgroundColor, textColor: textColor, title: "Talk is intalled", description: "Hei I have fount talk user, ...", textCancelButton: "cancel", textOkButton: "ok", attributes: EKAttributes.topFloat) { identifier in
@@ -139,8 +139,8 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
 
                         vc.accounts = talkAccounts
                         vc.enableTimerProgress = false
-                        vc.dismissDidEnterBackground = true
-                        //vcAccountRequest.delegate = self
+                        vc.dismissDidEnterBackground = false
+                        vc.delegate = self
 
                         let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)
                         let numberCell = talkAccounts.count
@@ -149,7 +149,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                         let popup = NCPopupViewController(contentController: vc, popupWidth: 300, popupHeight: height+20)
                         popup.backgroundAlpha = 0.8
 
-                        self.appDelegate.window?.rootViewController?.present(popup, animated: true)
+                        self.present(popup, animated: true)
                     }
                 }
             }
@@ -230,7 +230,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
 
     // MARK: - Login
 
-    func isUrlValid(url: String) {
+    func isUrlValid(url: String, user: String? = nil) {
 
         loginButton.isEnabled = false
 
@@ -442,3 +442,10 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         return NCUtility.shared.createAccountsFile(at: url, accounts: accounts)
     }
 }
+
+extension NCLogin: NCTalkAccountsDelegate {
+
+    func selected(url: String, user: String) {
+        isUrlValid(url: url, user: user)
+    }
+}

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

@@ -197,6 +197,7 @@
 "_privacy_legal_"           = "Privacy and Legal Policy";
 "_source_code_"             = "Get source code";
 "_account_select_"          = "Select the account";
+"_account_select_to_add_"   = "Select the account to add";
 "_host_insert_"             = "Insert the host name, for example:";
 "_certificate_not_found_"   = "File %@ in documents directory not found.";
 "_copy_failed_"             = "Copy failed";