瀏覽代碼

Merge pull request #898 from deltachat/fix_outdated_settings

Fix outdated settings
bjoern 5 年之前
父節點
當前提交
036ca544cf

+ 2 - 13
deltachat-ios/Controller/EditGroupViewController.swift

@@ -116,24 +116,13 @@ class EditGroupViewController: UITableViewController, MediaPickerDelegate {
         changeGroupImage = nil
         deleteGroupImage = true
         doneButton.isEnabled = true
-        updateAvatarRow(image: nil)
+        avatarSelectionCell.setAvatar(image: nil)
     }
 
     func onImageSelected(image: UIImage) {
         changeGroupImage = image
         deleteGroupImage = false
         doneButton.isEnabled = true
-        updateAvatarRow(image: changeGroupImage)
-    }
-
-    func updateAvatarRow(image: UIImage?) {
-        avatarSelectionCell = AvatarSelectionCell(image: image)
-        avatarSelectionCell.hintLabel.text = String.localized("group_avatar")
-        avatarSelectionCell.onAvatarTapped = onAvatarTapped
-
-        self.tableView.beginUpdates()
-        let indexPath = IndexPath(row: rowAvatar, section: 0)
-        self.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
-        self.tableView.endUpdates()
+        avatarSelectionCell.setAvatar(image: changeGroupImage)
     }
 }

+ 5 - 18
deltachat-ios/Controller/EditSettingsController.swift

@@ -3,8 +3,6 @@ import DcCore
 
 class EditSettingsController: UITableViewController, MediaPickerDelegate {
     private let dcContext: DcContext
-    private var displayNameBackup: String?
-    private var statusCellBackup: String?
 
     private let section1 = 0
     private let section1Name = 0
@@ -42,7 +40,7 @@ class EditSettingsController: UITableViewController, MediaPickerDelegate {
     }()
 
     private lazy var avatarSelectionCell: AvatarSelectionCell = {
-        return createPictureAndNameCell()
+        return AvatarSelectionCell(image: dcContext.getSelfAvatarImage())
     }()
 
     private lazy var nameCell: TextFieldCell = {
@@ -134,7 +132,7 @@ class EditSettingsController: UITableViewController, MediaPickerDelegate {
 
     private func deleteProfileIconPressed(_ action: UIAlertAction) {
         dcContext.selfavatar = nil
-        updateAvatarAndNameCell()
+        updateAvatarCell()
     }
 
     private func onAvatarTapped() {
@@ -151,22 +149,11 @@ class EditSettingsController: UITableViewController, MediaPickerDelegate {
 
     func onImageSelected(image: UIImage) {
         AvatarHelper.saveSelfAvatarImage(dcContext: dcContext, image: image)
-        updateAvatarAndNameCell()
+        updateAvatarCell()
     }
 
-    private func updateAvatarAndNameCell() {
-        self.avatarSelectionCell = createPictureAndNameCell()
-        self.avatarSelectionCell.onAvatarTapped = onAvatarTapped
-
-        self.tableView.beginUpdates()
-        let indexPath = IndexPath(row: section1Avatar, section: section1)
-        self.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
-        self.tableView.endUpdates()
-    }
-
-    private func createPictureAndNameCell() -> AvatarSelectionCell {
-        let cell = AvatarSelectionCell(image: dcContext.getSelfAvatarImage())
-        return cell
+    private func updateAvatarCell() {
+        self.avatarSelectionCell.setAvatar(image: dcContext.getSelfAvatarImage())
     }
 
 }

+ 2 - 13
deltachat-ios/Controller/NewGroupController.swift

@@ -307,24 +307,13 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
     private func deleteGroupAvatarPressed(_ action: UIAlertAction) {
         changeGroupImage = nil
         deleteGroupImage = true
-        updateAvatarRow(image: nil)
+        avatarSelectionCell.setAvatar(image: nil)
     }
 
     func onImageSelected(image: UIImage) {
         changeGroupImage = image
         deleteGroupImage = false
-        updateAvatarRow(image: changeGroupImage)
-    }
-
-    func updateAvatarRow(image: UIImage?) {
-        avatarSelectionCell = AvatarSelectionCell(image: image)
-        avatarSelectionCell.hintLabel.text = String.localized("group_avatar")
-        avatarSelectionCell.onAvatarTapped = onAvatarTapped
-
-        self.tableView.beginUpdates()
-        let indexPath = IndexPath(row: sectionGroupDetailsRowAvatar, section: sectionGroupDetails)
-        self.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
-        self.tableView.endUpdates()
+        avatarSelectionCell.setAvatar(image: changeGroupImage)
     }
 
     func updateGroupContactIdsOnQRCodeInvite() {

+ 0 - 4
deltachat-ios/Controller/ProfileInfoViewController.swift

@@ -78,10 +78,6 @@ class ProfileInfoViewController: UITableViewController {
         if let avatarImage = dcContext.getSelfAvatarImage() {
             avatarCell.setAvatar(image: avatarImage)
         }
-        self.tableView.beginUpdates()
-        let indexPath = IndexPath(row: 1, section: 0)
-        self.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
-        self.tableView.endUpdates()
     }
 
     // MARK: - actions

+ 1 - 0
deltachat-ios/Controller/WelcomeViewController.swift

@@ -21,6 +21,7 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
                 [weak self] in
                 if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
                     appDelegate.appCoordinator.presentTabBarController()
+                    appDelegate.appCoordinator.popTabsToRootViewControllers()
                 }
             }
             self.navigationController?.pushViewController(accountSetupController, animated: true)

+ 6 - 0
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -116,4 +116,10 @@ class AppCoordinator {
         showTab(index: chatsTab)
         window.makeKeyAndVisible()
     }
+
+    func popTabsToRootViewControllers() {
+        qrNavController.popToRootViewController(animated: false)
+        chatsNavController.popToRootViewController(animated: false)
+        settingsNavController.popToRootViewController(animated: false)
+    }
 }

+ 1 - 1
deltachat-ios/View/AvatarSelectionCell.swift

@@ -88,7 +88,7 @@ class AvatarSelectionCell: UITableViewCell {
             badge.setImage(image)
             avatarSet = true
         } else {
-            badge = InitialsBadge(image: defaultImage, size: badgeSize)
+            badge.setImage(defaultImage)
             badge.backgroundColor = DcColors.grayTextColor
             avatarSet = false
         }