@@ -251,24 +251,72 @@ extension MessageView {
251
251
*/
252
252
public func configureTheme( _ theme: Theme , iconStyle: IconStyle = . default) {
253
253
let iconImage = iconStyle. image ( theme: theme)
254
+ let backgroundColor : UIColor
255
+ let foregroundColor : UIColor
256
+ let defaultBackgroundColor : UIColor
257
+ let defaultForegroundColor : UIColor
254
258
switch theme {
255
259
case . info:
256
- let backgroundColor = UIColor ( red: 225.0 / 255.0 , green: 225.0 / 255.0 , blue: 225.0 / 255.0 , alpha: 1.0 )
257
- let foregroundColor = UIColor . darkText
258
- configureTheme ( backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: iconImage)
260
+ defaultBackgroundColor = UIColor ( red: 225.0 / 255.0 , green: 225.0 / 255.0 , blue: 225.0 / 255.0 , alpha: 1.0 )
261
+ defaultForegroundColor = UIColor . darkText
259
262
case . success:
260
- let backgroundColor = UIColor ( red: 97.0 / 255.0 , green: 161.0 / 255.0 , blue: 23.0 / 255.0 , alpha: 1.0 )
261
- let foregroundColor = UIColor . white
262
- configureTheme ( backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: iconImage)
263
+ defaultBackgroundColor = UIColor ( red: 97.0 / 255.0 , green: 161.0 / 255.0 , blue: 23.0 / 255.0 , alpha: 1.0 )
264
+ defaultForegroundColor = UIColor . white
263
265
case . warning:
264
- let backgroundColor = UIColor ( red: 238.0 / 255.0 , green: 189.0 / 255.0 , blue: 34.0 / 255.0 , alpha: 1.0 )
265
- let foregroundColor = UIColor . white
266
- configureTheme ( backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: iconImage)
266
+ defaultBackgroundColor = UIColor ( red: 246.0 / 255.0 , green: 197.0 / 255.0 , blue: 44.0 / 255.0 , alpha: 1.0 )
267
+ defaultForegroundColor = UIColor . white
267
268
case . error:
268
- let backgroundColor = UIColor ( red: 249.0 / 255.0 , green: 66.0 / 255.0 , blue: 47.0 / 255.0 , alpha: 1.0 )
269
- let foregroundColor = UIColor . white
270
- configureTheme ( backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: iconImage)
269
+ defaultBackgroundColor = UIColor ( red: 249.0 / 255.0 , green: 66.0 / 255.0 , blue: 47.0 / 255.0 , alpha: 1.0 )
270
+ defaultForegroundColor = UIColor . white
271
271
}
272
+ if #available( iOS 13 . 0 , * ) {
273
+ switch theme {
274
+ case . info:
275
+ backgroundColor = UIColor {
276
+ switch $0. userInterfaceStyle {
277
+ case . dark, . unspecified: return UIColor ( red: 125 / 255.0 , green: 125 / 255.0 , blue: 125 / 255.0 , alpha: 1.0 )
278
+ case . light: fallthrough
279
+ @unknown default :
280
+ return defaultBackgroundColor
281
+ }
282
+ }
283
+ foregroundColor = . label
284
+ case . success:
285
+ backgroundColor = UIColor {
286
+ switch $0. userInterfaceStyle {
287
+ case . dark, . unspecified: return UIColor ( red: 55 / 255.0 , green: 122 / 255.0 , blue: 0 / 255.0 , alpha: 1.0 )
288
+ case . light: fallthrough
289
+ @unknown default :
290
+ return defaultBackgroundColor
291
+ }
292
+ }
293
+ foregroundColor = . white
294
+ case . warning:
295
+ backgroundColor = UIColor {
296
+ switch $0. userInterfaceStyle {
297
+ case . dark, . unspecified: return UIColor ( red: 239 / 255.0 , green: 184 / 255.0 , blue: 10 / 255.0 , alpha: 1.0 )
298
+ case . light: fallthrough
299
+ @unknown default :
300
+ return defaultBackgroundColor
301
+ }
302
+ }
303
+ foregroundColor = . white
304
+ case . error:
305
+ backgroundColor = UIColor {
306
+ switch $0. userInterfaceStyle {
307
+ case . dark, . unspecified: return UIColor ( red: 195 / 255.0 , green: 12 / 255.0 , blue: 12 / 255.0 , alpha: 1.0 )
308
+ case . light: fallthrough
309
+ @unknown default :
310
+ return defaultBackgroundColor
311
+ }
312
+ }
313
+ foregroundColor = . white
314
+ }
315
+ } else {
316
+ backgroundColor = defaultBackgroundColor
317
+ foregroundColor = defaultForegroundColor
318
+ }
319
+ configureTheme ( backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: iconImage)
272
320
}
273
321
274
322
/**
0 commit comments