From dfe75e83ce96d2a05bd8c364861a98bf6640e5a8 Mon Sep 17 00:00:00 2001 From: Max Cobb Date: Wed, 1 Mar 2023 10:12:38 +0100 Subject: [PATCH 1/2] updated background and text labels to appear correctly in dark mode --- .../Common/NetworkManager/ToastView.swift | 36 +++++++++++++++---- .../Advanced/SpatialAudio/SpatialAudio.swift | 6 +++- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/iOS/APIExample/APIExample/Common/NetworkManager/ToastView.swift b/iOS/APIExample/APIExample/Common/NetworkManager/ToastView.swift index 7e346d8ae..e722dddf8 100644 --- a/iOS/APIExample/APIExample/Common/NetworkManager/ToastView.swift +++ b/iOS/APIExample/APIExample/Common/NetworkManager/ToastView.swift @@ -21,7 +21,11 @@ class ToastView: UIView { private lazy var label: UILabel = { let label = UILabel() label.text = "" - label.textColor = .white + if #available(iOS 13.0, *) { + label.textColor = .label + } else { + label.textColor = .white + } label.font = .systemFont(ofSize: 14) label.numberOfLines = 0 label.preferredMaxLayoutWidth = UIScreen.main.bounds.width - 60 @@ -66,9 +70,13 @@ class ToastView: UIView { static func showWait(text: String, view: UIView? = nil) { DispatchQueue.main.async { self.currentToastView?.removeFromSuperview() + var textColor: UIColor = .white + if #available(iOS 13.0, *) { + textColor = .label + } let toastView = show(text: text, tagImage: nil, - textColor: .white, + textColor: textColor, font: nil, postion: .center, view: view) @@ -92,8 +100,12 @@ class ToastView: UIView { static func show(text: String, duration: CGFloat = 2.5, view: UIView? = nil) { DispatchQueue.main.async { + var textColor: UIColor = .white + if #available(iOS 13.0, *) { + textColor = .label + } let toastView = show(text: text, tagImage: nil, - textColor: .white, font: nil, + textColor: textColor, font: nil, postion: .center, view: view) showAnimation(toastView: toastView, duration: duration) @@ -102,8 +114,12 @@ class ToastView: UIView { static func show(text: String, postion: ToastViewPostion = .center) { DispatchQueue.main.async { + var textColor: UIColor = .white + if #available(iOS 13.0, *) { + textColor = .label + } let toastView = show(text: text, tagImage: nil, - textColor: .white, font: nil, + textColor: textColor, font: nil, postion: postion, view: nil) showAnimation(toastView: toastView) @@ -115,8 +131,12 @@ class ToastView: UIView { duration: CGFloat = 2.5, view: UIView? = nil) { DispatchQueue.main.async { + var textColor: UIColor = .white + if #available(iOS 13.0, *) { + textColor = .label + } let toastView = show(text: text, tagImage: nil, - textColor: .white, font: nil, + textColor: textColor, font: nil, postion: postion, view: view) showAnimation(toastView: toastView, duration: duration) @@ -125,8 +145,12 @@ class ToastView: UIView { static func show(text: String, tagImage: UIImage? = nil, postion: ToastViewPostion = .center, view: UIView? = nil) { DispatchQueue.main.async { + var textColor: UIColor = .white + if #available(iOS 13.0, *) { + textColor = .label + } let toastView = show(text: text, tagImage: tagImage, - textColor: .white, font: nil, + textColor: textColor, font: nil, postion: postion, view: view) diff --git a/iOS/APIExample/APIExample/Examples/Advanced/SpatialAudio/SpatialAudio.swift b/iOS/APIExample/APIExample/Examples/Advanced/SpatialAudio/SpatialAudio.swift index 3ee89b800..7caebdc09 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/SpatialAudio/SpatialAudio.swift +++ b/iOS/APIExample/APIExample/Examples/Advanced/SpatialAudio/SpatialAudio.swift @@ -356,7 +356,11 @@ class SpatialAudioActionSheet: UIView { } private func setupUI() { - backgroundColor = .white + if #available(iOS 13.0, *) { + backgroundColor = .tertiarySystemBackground + } else { + backgroundColor = .white + } addSubview(muteLabel) addSubview(voiceBlurLabel) addSubview(airborneLabel) From eeec895e0f6e4b2ec7d7eb0a19cc66a740da38be Mon Sep 17 00:00:00 2001 From: Max Cobb Date: Wed, 1 Mar 2023 10:16:24 +0100 Subject: [PATCH 2/2] fix attenuation typo --- .../Examples/Advanced/SpatialAudio/SpatialAudio.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/APIExample/APIExample/Examples/Advanced/SpatialAudio/SpatialAudio.swift b/iOS/APIExample/APIExample/Examples/Advanced/SpatialAudio/SpatialAudio.swift index 7caebdc09..a370f8038 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/SpatialAudio/SpatialAudio.swift +++ b/iOS/APIExample/APIExample/Examples/Advanced/SpatialAudio/SpatialAudio.swift @@ -322,7 +322,7 @@ class SpatialAudioActionSheet: UIView { }() private lazy var attenuationLabel: UILabel = { let label = UILabel() - label.text = "Attenuatuin".localized + label.text = "Attenuation".localized return label }() private lazy var muteSwitch: UISwitch = {