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

#2221

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

+ 28 - 38
iOSClient/Account Request/NCTalkAccounts.swift

@@ -25,14 +25,12 @@ import UIKit
 import NextcloudKit
 
 public protocol NCTalkAccountsDelegate: AnyObject {
-    func accountRequestAddAccount()
-    func accountRequestChangeAccount(account: String)
+    func accountRequestChangeAccount(serverUrl: String, user: String)
 }
 
 // optional func
 public extension NCTalkAccountsDelegate {
-    func accountRequestAddAccount() {}
-    func accountRequestChangeAccount(account: String) {}
+    func accountRequestChangeAccount(serverUrl: String, user: String) {}
 }
 
 class NCTalkAccounts: UIViewController {
@@ -42,12 +40,10 @@ class NCTalkAccounts: UIViewController {
     @IBOutlet weak var tableView: UITableView!
     @IBOutlet weak var progressView: UIProgressView!
 
-    public var accounts: [tableAccount] = []
-    public var activeAccount: tableAccount?
+    public var accounts: [[String: String]] = [[:]]
     public let heightCell: CGFloat = 60
     public var enableTimerProgress: Bool = true
-    public var enableAddAccount: Bool = false
-    public var dismissDidEnterBackground: Bool = false
+    public var dismissDidEnterBackground: Bool = true
     public weak var delegate: NCTalkAccountsDelegate?
 
     private var timer: Timer?
@@ -90,7 +86,6 @@ class NCTalkAccounts: UIViewController {
 
         let visibleCells = tableView.visibleCells
         var numAccounts = accounts.count
-        if enableAddAccount { numAccounts += 1 }
 
         if visibleCells.count == numAccounts {
             tableView.isScrollEnabled = false
@@ -167,6 +162,9 @@ extension NCTalkAccounts: UITableViewDelegate {
 
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
 
+
+
+        /*
         if indexPath.row == accounts.count {
 
             dismiss(animated: true)
@@ -183,17 +181,14 @@ extension NCTalkAccounts: UITableViewDelegate {
                 dismiss(animated: true)
             }
         }
+        */
     }
 }
 
 extension NCTalkAccounts: UITableViewDataSource {
 
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        if enableAddAccount {
-            return accounts.count + 1
-        } else {
-            return accounts.count
-        }
+        return accounts.count
     }
 
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@@ -209,36 +204,31 @@ extension NCTalkAccounts: UITableViewDataSource {
         userLabel?.text = ""
         urlLabel?.text = ""
 
-        if indexPath.row == accounts.count {
-
-            avatarImage?.image = NCUtility.shared.loadImage(named: "plus").image(color: .systemBlue, size: 15)
-            avatarImage?.contentMode = .center
-            userLabel?.text = NSLocalizedString("_add_account_", comment: "")
-            userLabel?.textColor = .systemBlue
-            userLabel?.font = UIFont.systemFont(ofSize: 15)
+        if let account = accounts[indexPath.row].first {
+            userLabel?.text = account.value.uppercased()
+            urlLabel?.text = (URL(string: account.key)?.host ?? "")
+        }
 
-        } else {
+        /*
+        let serverUrl = account.keys
+        let user = account.values
 
-            let account = accounts[indexPath.row]
+        urlLabel?.text = serverUrl
 
-            avatarImage?.image = NCUtility.shared.loadUserImage(
-                for: account.user,
-                   displayName: account.displayName,
-                   userBaseUrl: account)
 
-            if account.alias.isEmpty {
-                userLabel?.text = account.user.uppercased()
-                urlLabel?.text = (URL(string: account.urlBase)?.host ?? "")
-            } else {
-                userLabel?.text = account.alias.uppercased()
-            }
+        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
-            }
+        if account.active {
+            activeImage?.image = NCUtility.shared.loadImage(named: "checkmark").image(color: .systemBlue, size: 30)
+        } else {
+            activeImage?.image = nil
         }
+        */
 
         return cell
     }

+ 12 - 0
iOSClient/Images.xcassets/talk.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "talk.png",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
iOSClient/Images.xcassets/talk.imageset/talk.png


+ 20 - 3
iOSClient/Login/NCLogin.swift

@@ -130,11 +130,28 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         appDelegate.timerErrorNetworking?.invalidate()
 
         // test
-        createTalkAccount()
+        //createTalkAccount()
 
-        if let talkAccounts = readTalkAccounts(), let image = UIImage(named: "iconSuccess"), let backgroundColor =  NCBrandColor.shared.brandElement.lighter(by: 10) {
+        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
-                print(identifier)
+                if identifier == "ok" {
+                    if let vc = UIStoryboard(name: "NCTalkAccounts", bundle: nil).instantiateInitialViewController() as? NCTalkAccounts {
+
+                        vc.accounts = talkAccounts
+                        vc.enableTimerProgress = false
+                        vc.dismissDidEnterBackground = true
+                        //vcAccountRequest.delegate = self
+
+                        let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)
+                        let numberCell = talkAccounts.count
+                        let height = min(CGFloat(numberCell * Int(vc.heightCell) + 45), screenHeighMax)
+
+                        let popup = NCPopupViewController(contentController: vc, popupWidth: 300, popupHeight: height+20)
+                        popup.backgroundAlpha = 0.8
+
+                        self.appDelegate.window?.rootViewController?.present(popup, animated: true)
+                    }
+                }
             }
         }
     }