Răsfoiți Sursa

Merge pull request #250 from deltachat/tweak_contact_request_title

tweak contact request title (#229)
björn petersen 5 ani în urmă
părinte
comite
c01ccfdd1c

+ 14 - 16
deltachat-ios/Controller/ChatViewController.swift

@@ -33,6 +33,7 @@ class ChatViewController: MessagesViewController {
     }()
 
     var disableWriting = false
+    var showCustomNavBar = true
     var previewView: UIView?
     var previewController: PreviewController?
 
@@ -43,15 +44,10 @@ class ChatViewController: MessagesViewController {
         return messageInputBar
     }
 
-    private var titleView = ChatTitleView()
-
-    init(dcContext: DcContext, chatId: Int, title: String? = nil) {
+    init(dcContext: DcContext, chatId: Int) {
         self.dcContext = dcContext
         self.chatId = chatId
         super.init(nibName: nil, bundle: nil)
-        if let title = title {
-            titleView.updateTitleView(title: title, subtitle: nil)
-        }
         hidesBottomBarWhenPushed = true
     }
 
@@ -62,8 +58,6 @@ class ChatViewController: MessagesViewController {
     override func viewDidLoad() {
         messagesCollectionView.register(CustomMessageCell.self)
         super.viewDidLoad()
-        navigationItem.titleView = titleView
-
         view.backgroundColor = DcColors.chatBackgroundColor
         if !DcConfig.configured {
             // TODO: display message about nothing being configured
@@ -87,15 +81,19 @@ class ChatViewController: MessagesViewController {
         navigationController?.navigationBar.addGestureRecognizer(navBarTap)
 
         let chat = DcChat(id: chatId)
-        titleView.updateTitleView(title: chat.name, subtitle: chat.subtitle)
-
-        let badge: InitialsBadge
-        if let image = chat.profileImage {
-            badge =  InitialsBadge(image: image, size: 28)
-        } else {
-            badge =  InitialsBadge(name: chat.name, color: chat.color, size: 28)
+        if showCustomNavBar {
+            let titleView =  ChatTitleView()
+            titleView.updateTitleView(title: chat.name, subtitle: chat.subtitle)
+            navigationItem.titleView = titleView
+
+            let badge: InitialsBadge
+            if let image = chat.profileImage {
+                badge =  InitialsBadge(image: image, size: 28)
+            } else {
+                badge =  InitialsBadge(name: chat.name, color: chat.color, size: 28)
+            }
+            navigationItem.rightBarButtonItem = UIBarButtonItem(customView: badge)
         }
-        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: badge)
 
         configureMessageMenu()
 

+ 10 - 4
deltachat-ios/Controller/MailboxViewController.swift

@@ -1,9 +1,12 @@
 import UIKit
 
 class MailboxViewController: ChatViewController {
-    override init(dcContext: DcContext, chatId: Int, title: String? = nil) {
-        super.init(dcContext: dcContext, chatId: chatId, title: title)
+
+    override init(dcContext: DcContext, chatId: Int) {
+        super.init(dcContext: dcContext, chatId: chatId)
         hidesBottomBarWhenPushed = false
+        disableWriting = true
+        showCustomNavBar = false
     }
 
     required init?(coder _: NSCoder) {
@@ -12,7 +15,10 @@ class MailboxViewController: ChatViewController {
 
     override func viewDidLoad() {
         super.viewDidLoad()
-
-        // Do any additional setup after loading the view.
+        navigationItem.title = String.localized("menu_deaddrop")
+        if #available(iOS 11.0, *) {
+            navigationController?.navigationBar.prefersLargeTitles = true
+        }
     }
+
 }

+ 1 - 2
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -30,8 +30,7 @@ class AppCoordinator: NSObject, Coordinator {
     // MARK: viewControllers
 
     private lazy var mailboxController: UIViewController = {
-        let controller = MailboxViewController(dcContext: dcContext, chatId: Int(DC_CHAT_ID_DEADDROP), title: String.localized("menu_deaddrop"))
-        controller.disableWriting = true
+        let controller = MailboxViewController(dcContext: dcContext, chatId: Int(DC_CHAT_ID_DEADDROP))
         let nav = DcNavigationController(rootViewController: controller)
         let settingsImage = UIImage(named: "message")
         nav.tabBarItem = UITabBarItem(title: String.localized("menu_deaddrop"), image: settingsImage, tag: mailboxTab)