diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 3afb2a00..95ab8054 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -35,10 +35,11 @@ open class Notification: View { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- + /// Type of Notification. public enum Style: String, CaseIterable { case info, success, warning, error - func styleIconName() -> Icon.Name { + func iconName() -> Icon.Name { switch self { case .info: return .infoBold @@ -52,6 +53,7 @@ open class Notification: View { } } + /// Orientation of Notification. public enum Layout: String, CaseIterable { case vertical, horizontal } @@ -80,26 +82,6 @@ open class Notification: View { $0.spacing = VDSLayout.Spacing.space2X.value } - private var edgeSpacing: CGFloat { - return UIDevice.isIPad ? VDSLayout.Spacing.space5X.value : VDSLayout.Spacing.space4X.value - } - - private var minViewHeight: CGFloat { - return UIDevice.isIPad ? VDSLayout.Spacing.space16X.value : VDSLayout.Spacing.space12X.value - } - - private var minContentHeight: CGFloat { - return UIDevice.isIPad ? VDSLayout.Spacing.space5X.value : VDSLayout.Spacing.space4X.value - } - - private var minViewWidth: CGFloat { - return 288 - } - - private var maxViewWidth: CGFloat { - return 1232 - } - internal var onCloseSubscriber: AnyCancellable? private var maxWidthConstraint: NSLayoutConstraint? @@ -181,9 +163,11 @@ open class Notification: View { open var hideCloseButton: Bool = false { didSet{setNeedsUpdate()}} /// Add this attribute determine your type of Notification. - open var type: Style = .info { didSet{setNeedsUpdate()}} + open var style: Style = .info { didSet{setNeedsUpdate()}} var _layout: Layout = .vertical + + /// Determines the orientation of buttons and text in the Notification. open var layout: Layout { set { if !UIDevice.isIPad, newValue == .horizontal { return } @@ -198,7 +182,7 @@ open class Notification: View { // MARK: - Configuration //-------------------------------------------------- private var backgroundColorConfiguration: AnyColorable = { - let config = KeyedColorConfiguration(keyPath: \.type) + let config = KeyedColorConfiguration(keyPath: \.style) config.setSurfaceColors(VDSColor.feedbackInformationBackgroundOnlight, VDSColor.feedbackInformationBackgroundOndark, forKey: .info) config.setSurfaceColors(VDSColor.feedbackWarningBackgroundOnlight, VDSColor.feedbackWarningBackgroundOndark, forKey: .warning) config.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forKey: .success) @@ -211,6 +195,26 @@ open class Notification: View { $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: true) } + private var edgeSpacing: CGFloat { + return UIDevice.isIPad ? VDSLayout.Spacing.space5X.value : VDSLayout.Spacing.space4X.value + } + + private var minViewHeight: CGFloat { + return UIDevice.isIPad ? VDSLayout.Spacing.space16X.value : VDSLayout.Spacing.space12X.value + } + + private var minContentHeight: CGFloat { + return UIDevice.isIPad ? VDSLayout.Spacing.space5X.value : VDSLayout.Spacing.space4X.value + } + + private var minViewWidth: CGFloat { + return 288 + } + + private var maxViewWidth: CGFloat { + return 1232 + } + //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- @@ -257,7 +261,7 @@ open class Notification: View { primaryButtonModel = nil secondaryButtonModel = nil - type = .info + style = .info typeIcon.size = UIDevice.isIPad ? .medium : .small typeIcon.name = .infoBold @@ -288,7 +292,7 @@ open class Notification: View { //-------------------------------------------------- private func updateIcons() { let iconColor = surface == .dark ? VDSColor.paletteWhite : VDSColor.paletteBlack - typeIcon.name = type.styleIconName() + typeIcon.name = style.iconName() typeIcon.color = iconColor closeButton.color = iconColor closeButton.isHidden = hideCloseButton diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index d77927ae..0e64e27a 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -76,7 +76,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate { }.eraseToAnyColorable() /// Representing the type of input. - open var type: FieldType = .text { didSet { setNeedsUpdate() }} + open var fieldType: FieldType = .text { didSet { setNeedsUpdate() }} var _showError: Bool = false /// Whether not to show the error. @@ -159,7 +159,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate { successLabel.textPosition = .left successLabel.textStyle = .bodySmall - type = .text + fieldType = .text showSuccess = false successText = nil helperTextPlacement = .bottom @@ -198,12 +198,12 @@ open class InputField: EntryFieldBase, UITextFieldDelegate { } //set the width constraints - if let width, width > type.width { + if let width, width > fieldType.width { widthConstraint?.constant = width widthConstraint?.isActive = true minWidthConstraint?.isActive = false } else { - minWidthConstraint?.constant = type.width + minWidthConstraint?.constant = fieldType.width widthConstraint?.isActive = false minWidthConstraint?.isActive = true }