Browse Source

themed colors in ChatViewController

cyberta 5 years ago
parent
commit
f9aedd5e7e
1 changed files with 16 additions and 17 deletions
  1. 16 17
      deltachat-ios/Controller/ChatViewController.swift

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

@@ -63,13 +63,6 @@ class ChatViewController: MessagesViewController {
 
         messagesCollectionView.register(CustomMessageCell.self)
         super.viewDidLoad()
-
-        // TODO: support dark mode for this view, see https://github.com/deltachat/deltachat-ios/issues/163#issuecomment-533797080
-        if #available(iOS 13.0, *) {
-            overrideUserInterfaceStyle = .light
-        }
-
-        view.backgroundColor = DcColors.chatBackgroundColor
         if !DcConfig.configured {
             // TODO: display message about nothing being configured
             return
@@ -283,6 +276,7 @@ class ChatViewController: MessagesViewController {
 
         scrollsToBottomOnKeyboardBeginsEditing = true // default false
         maintainPositionOnKeyboardFrameChanged = true // default false
+        messagesCollectionView.backgroundColor = DcColors.chatBackgroundColor
         messagesCollectionView.addSubview(refreshControl)
         refreshControl.addTarget(self, action: #selector(loadMoreMessages), for: .valueChanged)
 
@@ -321,14 +315,19 @@ class ChatViewController: MessagesViewController {
         messageInputBar.isTranslucent = true
         messageInputBar.separatorLine.isHidden = true
         messageInputBar.inputTextView.tintColor = DcColors.primary
+        messageInputBar.inputTextView.textColor = DcColors.defaultTextColor
+        messageInputBar.backgroundView.backgroundColor = .black
+        messageInputBar.isTranslucent = false
+        //messageInputBar.backgroundColor = DcColors.chatBackgroundColor
 
         scrollsToBottomOnKeyboardBeginsEditing = true
 
-        messageInputBar.inputTextView.backgroundColor = UIColor(red: 245 / 255, green: 245 / 255, blue: 245 / 255, alpha: 1)
-        messageInputBar.inputTextView.placeholderTextColor = UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 1)
+        messageInputBar.inputTextView.backgroundColor = DcColors.inputFieldColor
+        messageInputBar.inputTextView.placeholderTextColor = DcColors.placeholderColor
         messageInputBar.inputTextView.textContainerInset = UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 38)
         messageInputBar.inputTextView.placeholderLabelInsets = UIEdgeInsets(top: 8, left: 20, bottom: 8, right: 38)
-        messageInputBar.inputTextView.layer.borderColor = UIColor(red: 200 / 255, green: 200 / 255, blue: 200 / 255, alpha: 1).cgColor
+        messageInputBar.inputTextView.layer.borderColor = UIColor.themeColor(light: UIColor(red: 200 / 255, green: 200 / 255, blue: 200 / 255, alpha: 1),
+                                                                             dark: UIColor(red: 55 / 255, green: 55/255, blue: 55/255, alpha: 1)).cgColor
         messageInputBar.inputTextView.layer.borderWidth = 1.0
         messageInputBar.inputTextView.layer.cornerRadius = 16.0
         messageInputBar.inputTextView.layer.masksToBounds = true
@@ -359,12 +358,12 @@ class ChatViewController: MessagesViewController {
                     $0.spacing = .fixed(0)
                     let clipperIcon = #imageLiteral(resourceName: "ic_attach_file_36pt").withRenderingMode(.alwaysTemplate)
                     $0.image = clipperIcon
-                    $0.tintColor = UIColor(white: 0.8, alpha: 1)
+                    $0.tintColor = DcColors.colorDisabled
                     $0.setSize(CGSize(width: 30, height: 30), animated: false)
                 }.onSelected {
                     $0.tintColor = DcColors.primary
                 }.onDeselected {
-                    $0.tintColor = UIColor(white: 0.8, alpha: 1)
+                    $0.tintColor = DcColors.colorDisabled
                 }.onTouchUpInside { _ in
                     self.clipperButtonPressed()
                 }
@@ -380,7 +379,7 @@ class ChatViewController: MessagesViewController {
                 })
             }.onDisabled { item in
                 UIView.animate(withDuration: 0.3, animations: {
-                    item.backgroundColor = UIColor(white: 0.9, alpha: 1)
+                    item.backgroundColor = DcColors.colorDisabled
                 })
             }
     }
@@ -510,7 +509,7 @@ extension ChatViewController: MessagesDataSource {
                 string: MessageKitDateFormatter.shared.string(from: message.sentDate),
                 attributes: [
                     NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 10),
-                    NSAttributedString.Key.foregroundColor: UIColor.darkGray,
+                    NSAttributedString.Key.foregroundColor: DcColors.grayTextColor,
                 ]
             )
         }
@@ -531,7 +530,7 @@ extension ChatViewController: MessagesDataSource {
         if isMessageForwarded(at: indexPath) {
             let forwardedString = NSMutableAttributedString(string: String.localized("forwarded_message"), attributes: [
                 .font: UIFont.systemFont(ofSize: 14),
-                .foregroundColor: UIColor.darkGray,
+                .foregroundColor: DcColors.grayTextColor,
             ])
             if attributedString == nil {
                 attributedString = forwardedString
@@ -657,7 +656,7 @@ extension ChatViewController: MessagesDataSource {
                 string: " - " + stateDescription,
                 attributes: [
                     .font: UIFont.systemFont(ofSize: 12),
-                    .foregroundColor: UIColor.darkText,
+                    .foregroundColor: DcColors.defaultTextColor,
                 ]
             ))
 
@@ -729,7 +728,7 @@ extension ChatViewController: MessagesDataSource {
 extension ChatViewController: MessagesDisplayDelegate {
     // MARK: - Text Messages
     func textColor(for _: MessageType, at _: IndexPath, in _: MessagesCollectionView) -> UIColor {
-        return .darkText
+        return DcColors.defaultTextColor
     }
 
     // MARK: - All Messages