From 391cfea97da1139e3d9098557d991635278a9ad2 Mon Sep 17 00:00:00 2001 From: Iana Date: Tue, 5 Nov 2024 12:33:53 +0200 Subject: [PATCH] [trello.com/c/sI4VXuJa] Restyle notification view: update text colors --- .../NotificationViewController.swift | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/MessageNotificationContentExtension/NotificationViewController.swift b/MessageNotificationContentExtension/NotificationViewController.swift index 07e7cf269..5193f224d 100644 --- a/MessageNotificationContentExtension/NotificationViewController.swift +++ b/MessageNotificationContentExtension/NotificationViewController.swift @@ -41,6 +41,8 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi senderAddressLabel.text = "" messageLabel.text = "" dateLabel.text = "" + + updateTextColors() } func didReceive(_ notification: UNNotification) { @@ -81,12 +83,14 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi message = raw } else { guard let passphrase: String = keychainStore.get(passphraseStoreKey), - let keys = nativeCore.createKeypairFor(passphrase: passphrase), - let chat = transaction.asset.chat, - let raw = nativeCore.decodeMessage(rawMessage: chat.message, - rawNonce: chat.ownMessage, - senderPublicKey: transaction.senderPublicKey, - privateKey: keys.privateKey) else { + let keys = nativeCore.createKeypairFor(passphrase: passphrase), + let chat = transaction.asset.chat, + let raw = nativeCore.decodeMessage( + rawMessage: chat.message, + rawNonce: chat.ownMessage, + senderPublicKey: transaction.senderPublicKey, + privateKey: keys.privateKey + ) else { showError() return } @@ -158,6 +162,20 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi } // MARK: - UI + private func updateTextColors() { + if self.traitCollection.userInterfaceStyle == .dark { + senderNameLabel.textColor = .white + senderAddressLabel.textColor = .white + messageLabel.textColor = .white + dateLabel.textColor = .white + } else { + senderNameLabel.textColor = .black + senderAddressLabel.textColor = .black + messageLabel.textColor = .black + dateLabel.textColor = .black + } + } + private func showError(with message: String? = nil) { let warningView = NotificationWarningView()