notification background color changes

This commit is contained in:
Sumanth Nadigadda 2023-03-16 23:38:55 +05:30
parent e9b05fcda1
commit fd512cc38c

View File

@ -86,12 +86,12 @@ public class Notification: View {
//--------------------------------------------------
// MARK: - Configuration
//--------------------------------------------------
private var backgroundColorConfiguration: StateColorConfiguration<NotificationStyle> = {
let config = StateColorConfiguration<NotificationStyle>()
config.setSurfaceColors(VDSColor.feedbackInformationBackgroundOnlight, VDSColor.feedbackInformationBackgroundOndark, forState: .info)
config.setSurfaceColors(VDSColor.feedbackWarningBackgroundOnlight, VDSColor.feedbackWarningBackgroundOndark, forState: .warning)
config.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forState: .success)
config.setSurfaceColors(VDSColor.feedbackErrorBackgroundOnlight, VDSColor.feedbackErrorBackgroundOndark, forState: .error)
private var backgroundColorConfiguration: KeyedColorConfiguration<NotificationStyle, Notification> = {
let config = KeyedColorConfiguration<NotificationStyle, Notification>(keyName: "type")
config.setSurfaceColors(VDSColor.feedbackInformationBackgroundOnlight, VDSColor.feedbackInformationBackgroundOndark, forKey: .info)
config.setSurfaceColors(VDSColor.feedbackWarningBackgroundOnlight, VDSColor.feedbackWarningBackgroundOndark, forKey: .warning)
config.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forKey: .success)
config.setSurfaceColors(VDSColor.feedbackErrorBackgroundOnlight, VDSColor.feedbackErrorBackgroundOndark, forKey: .error)
return config
}()
@ -145,6 +145,10 @@ public class Notification: View {
open override func reset() {
super.reset()
type = .info
typeIcon.name = .infoBold
closeButton.name = .close
}
//--------------------------------------------------
@ -153,7 +157,7 @@ public class Notification: View {
open override func updateView() {
updateTextColorConfig()
backgroundColor = backgroundColorConfiguration.getColor(surface, forState: type)
backgroundColor = backgroundColorConfiguration.getColor(self)
typeIcon.name = type.styleIconName()
typeIcon.color = surface == .dark ? Icon.Color.white : Icon.Color.black
closeButton.color = surface == .dark ? Icon.Color.white : Icon.Color.black