Adding logic to hide close button
This commit is contained in:
parent
c8c63d5cd4
commit
fc02175c5d
@ -18,7 +18,7 @@ public class Notification: View {
|
||||
// MARK: - Enums
|
||||
//--------------------------------------------------
|
||||
|
||||
public enum NotificationStyle: String, CaseIterable {
|
||||
public enum Style: String, CaseIterable {
|
||||
case info, success, warning, error
|
||||
|
||||
func styleIconName() -> Icon.Name {
|
||||
@ -136,7 +136,9 @@ public class Notification: View {
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
open var type: NotificationStyle = .info { didSet{didChange()}}
|
||||
open var hideCloseButton: Bool = false { didSet{didChange()}}
|
||||
|
||||
open var type: Style = .info { didSet{didChange()}}
|
||||
|
||||
var _layout: Layout = .vertical
|
||||
open var layout: Layout {
|
||||
@ -153,7 +155,7 @@ public class Notification: View {
|
||||
// MARK: - Configuration
|
||||
//--------------------------------------------------
|
||||
private var backgroundColorConfiguration: AnyColorable = {
|
||||
let config = KeyedColorConfiguration<Notification, NotificationStyle>(keyPath: \.type)
|
||||
let config = KeyedColorConfiguration<Notification, Style>(keyPath: \.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)
|
||||
@ -219,6 +221,7 @@ public class Notification: View {
|
||||
typeIcon.name = .infoBold
|
||||
closeButton.name = .close
|
||||
layout = .vertical
|
||||
hideCloseButton = false
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -236,6 +239,7 @@ public class Notification: View {
|
||||
typeIcon.name = type.styleIconName()
|
||||
typeIcon.color = iconColor
|
||||
closeButton.color = iconColor
|
||||
closeButton.isHidden = hideCloseButton
|
||||
}
|
||||
|
||||
private func updateLabels() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user