Skip to content

Commit 6fee157

Browse files
authored
Merge pull request #337 from AgoraIO/light-dark-mode
Dark Mode Fix
2 parents 95fca06 + eeec895 commit 6fee157

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

iOS/APIExample/APIExample/Common/NetworkManager/ToastView.swift

+30-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ class ToastView: UIView {
2121
private lazy var label: UILabel = {
2222
let label = UILabel()
2323
label.text = ""
24-
label.textColor = .white
24+
if #available(iOS 13.0, *) {
25+
label.textColor = .label
26+
} else {
27+
label.textColor = .white
28+
}
2529
label.font = .systemFont(ofSize: 14)
2630
label.numberOfLines = 0
2731
label.preferredMaxLayoutWidth = UIScreen.main.bounds.width - 60
@@ -66,9 +70,13 @@ class ToastView: UIView {
6670
static func showWait(text: String, view: UIView? = nil) {
6771
DispatchQueue.main.async {
6872
self.currentToastView?.removeFromSuperview()
73+
var textColor: UIColor = .white
74+
if #available(iOS 13.0, *) {
75+
textColor = .label
76+
}
6977
let toastView = show(text: text,
7078
tagImage: nil,
71-
textColor: .white,
79+
textColor: textColor,
7280
font: nil,
7381
postion: .center,
7482
view: view)
@@ -92,8 +100,12 @@ class ToastView: UIView {
92100

93101
static func show(text: String, duration: CGFloat = 2.5, view: UIView? = nil) {
94102
DispatchQueue.main.async {
103+
var textColor: UIColor = .white
104+
if #available(iOS 13.0, *) {
105+
textColor = .label
106+
}
95107
let toastView = show(text: text, tagImage: nil,
96-
textColor: .white, font: nil,
108+
textColor: textColor, font: nil,
97109
postion: .center,
98110
view: view)
99111
showAnimation(toastView: toastView, duration: duration)
@@ -102,8 +114,12 @@ class ToastView: UIView {
102114

103115
static func show(text: String, postion: ToastViewPostion = .center) {
104116
DispatchQueue.main.async {
117+
var textColor: UIColor = .white
118+
if #available(iOS 13.0, *) {
119+
textColor = .label
120+
}
105121
let toastView = show(text: text, tagImage: nil,
106-
textColor: .white, font: nil,
122+
textColor: textColor, font: nil,
107123
postion: postion,
108124
view: nil)
109125
showAnimation(toastView: toastView)
@@ -115,8 +131,12 @@ class ToastView: UIView {
115131
duration: CGFloat = 2.5,
116132
view: UIView? = nil) {
117133
DispatchQueue.main.async {
134+
var textColor: UIColor = .white
135+
if #available(iOS 13.0, *) {
136+
textColor = .label
137+
}
118138
let toastView = show(text: text, tagImage: nil,
119-
textColor: .white, font: nil,
139+
textColor: textColor, font: nil,
120140
postion: postion,
121141
view: view)
122142
showAnimation(toastView: toastView, duration: duration)
@@ -125,8 +145,12 @@ class ToastView: UIView {
125145

126146
static func show(text: String, tagImage: UIImage? = nil, postion: ToastViewPostion = .center, view: UIView? = nil) {
127147
DispatchQueue.main.async {
148+
var textColor: UIColor = .white
149+
if #available(iOS 13.0, *) {
150+
textColor = .label
151+
}
128152
let toastView = show(text: text, tagImage: tagImage,
129-
textColor: .white, font: nil,
153+
textColor: textColor, font: nil,
130154
postion: postion,
131155
view: view)
132156

iOS/APIExample/APIExample/Examples/Advanced/SpatialAudio/SpatialAudio.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class SpatialAudioActionSheet: UIView {
322322
}()
323323
private lazy var attenuationLabel: UILabel = {
324324
let label = UILabel()
325-
label.text = "Attenuatuin".localized
325+
label.text = "Attenuation".localized
326326
return label
327327
}()
328328
private lazy var muteSwitch: UISwitch = {
@@ -356,7 +356,11 @@ class SpatialAudioActionSheet: UIView {
356356
}
357357

358358
private func setupUI() {
359-
backgroundColor = .white
359+
if #available(iOS 13.0, *) {
360+
backgroundColor = .tertiarySystemBackground
361+
} else {
362+
backgroundColor = .white
363+
}
360364
addSubview(muteLabel)
361365
addSubview(voiceBlurLabel)
362366
addSubview(airborneLabel)

0 commit comments

Comments
 (0)