Ver código fonte

Merge pull request #876 from deltachat/tweak-flow

to go chat on mute/disappearing changes
cyBerta 5 anos atrás
pai
commit
863d48401d

+ 2 - 0
deltachat-ios/Controller/ContactDetailViewController.swift

@@ -248,6 +248,7 @@ class ContactDetailViewController: UITableViewController {
             if viewModel.chatIsMuted {
                 self.viewModel.context.setChatMuteDuration(chatId: self.viewModel.chatId, duration: 0)
                 muteChatCell.actionTitle = String.localized("menu_mute")
+                self.navigationController?.popViewController(animated: true)
             } else {
                 showMuteAlert()
             }
@@ -314,6 +315,7 @@ class ContactDetailViewController: UITableViewController {
         let action = UIAlertAction(title: String.localized(key), style: .default, handler: { _ in
             self.viewModel.context.setChatMuteDuration(chatId: self.viewModel.chatId, duration: duration)
             self.muteChatCell.actionTitle = String.localized("menu_unmute")
+            self.navigationController?.popViewController(animated: true)
         })
         alert.addAction(action)
     }

+ 2 - 0
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -428,6 +428,7 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
                 if chat.isMuted {
                     dcContext.setChatMuteDuration(chatId: chatId, duration: 0)
                     muteChatCell.actionTitle = String.localized("menu_mute")
+                    navigationController?.popViewController(animated: true)
                 } else {
                     showMuteAlert()
                 }
@@ -541,6 +542,7 @@ extension GroupChatDetailViewController {
         let action = UIAlertAction(title: String.localized(key), style: .default, handler: { _ in
             self.dcContext.setChatMuteDuration(chatId: self.chatId, duration: duration)
             self.muteChatCell.actionTitle = String.localized("menu_unmute")
+            self.navigationController?.popViewController(animated: true)
         })
         alert.addAction(action)
     }

+ 4 - 1
deltachat-ios/Controller/SettingsEphemeralMessageController.swift

@@ -76,7 +76,10 @@ class SettingsEphemeralMessageController: UITableViewController {
 
     @objc private func okButtonPressed() {
         dcContext.setChatEphemeralTimer(chatId: chatId, duration: options[currentIndex])
-        navigationController?.popViewController(animated: true)
+
+        // pop two view controllers:
+        // go directly back to the chatview where also the confirmation message will be shown
+        navigationController?.popViewControllers(viewsToPop: 2, animated: true)
     }
 
 

+ 10 - 0
deltachat-ios/Extensions/Extensions.swift

@@ -81,3 +81,13 @@ extension UIFont {
         return metrics.scaledFont(for: font)
     }
 }
+
+extension UINavigationController {
+    // pop up to viewsToPop viewControllers from the stack
+    func popViewControllers(viewsToPop: Int, animated: Bool) {
+        if viewControllers.count >= 2 && viewsToPop >= 1 {
+            let vc = viewControllers[max(0, viewControllers.count - viewsToPop - 1)]
+            popToViewController(vc, animated: animated)
+        }
+    }
+}