瀏覽代碼

adjusted colors according to type, cell now either updates or animates

nayooti 5 年之前
父節點
當前提交
14508c6efb
共有 2 個文件被更改,包括 14 次插入11 次删除
  1. 11 8
      deltachat-ios/Controller/AccountSetupController.swift
  2. 3 3
      deltachat-ios/View/ProviderInfoCell.swift

+ 11 - 8
deltachat-ios/Controller/AccountSetupController.swift

@@ -572,22 +572,24 @@ class AccountSetupController: UITableViewController {
 
     func updateProviderInfo() {
         provider = dcContext.getProviderFromEmail(addr: emailCell.getText() ?? "")
-        if
-            let hint = provider?.beforeLoginHint,
+        if let hint = provider?.beforeLoginHint,
             let status = provider?.status,
             let statusType = ProviderInfoStatus(rawValue: status),
             !hint.isEmpty {
-            showProviderInfo(with: hint, hintType: statusType)
-        } else {
+            providerInfoCell.updateInfo(hint: hint, hintType: statusType)
+            if !providerInfoShowing {
+                showProviderInfo()
+            }
+        } else if providerInfoShowing {
             hideProviderInfo()
         }
     }
 
-    func showProviderInfo(with hint: String, hintType: ProviderInfoStatus) {
-        providerInfoCell.updateInfo(hint: hint, hintType: hintType)
-        basicSectionCells.append(providerInfoCell)
+    func showProviderInfo() {
+        basicSectionCells = [emailCell, passwordCell, providerInfoCell]
         let providerInfoCellIndexPath = IndexPath(row: 2, section: 0)
-        tableView.insertRows(at: [providerInfoCellIndexPath], with: .automatic)
+        tableView.insertRows(at: [providerInfoCellIndexPath], with: .fade)
+        providerInfoShowing = true
     }
 
     func hideProviderInfo() {
@@ -595,6 +597,7 @@ class AccountSetupController: UITableViewController {
         basicSectionCells = [emailCell, passwordCell]
         let providerInfoCellIndexPath = IndexPath(row: 2, section: 0)
         tableView.deleteRows(at: [providerInfoCellIndexPath], with: .automatic)
+        providerInfoShowing = false
     }
     
     private func login(emailAddress: String, password: String, skipAdvanceSetup: Bool = false) {

+ 3 - 3
deltachat-ios/View/ProviderInfoCell.swift

@@ -9,8 +9,8 @@
 import UIKit
 
 enum ProviderInfoStatus: Int {
-     case preparation = 2
-     case broken = 1
+    case preparation = 2
+    case broken = 3
  }
 
 class ProviderInfoCell: UITableViewCell {
@@ -89,7 +89,7 @@ class ProviderInfoCell: UITableViewCell {
             hintLabel.textColor = textColor
             infoButton.setTitleColor(textColor, for: .normal)
         case .broken:
-            hintBackgroundView.backgroundColor = SystemColor.red.uiColor.withAlphaComponent(0.5)
+            hintBackgroundView.backgroundColor = SystemColor.red.uiColor
             let textColor = UIColor.white
             hintLabel.textColor = textColor
             infoButton.setTitleColor(textColor, for: .normal)