refactored type
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
87c202d23b
commit
27af806281
@ -35,10 +35,11 @@ open class Notification: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Enums
|
// MARK: - Enums
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
/// Type of Notification.
|
||||||
public enum Style: String, CaseIterable {
|
public enum Style: String, CaseIterable {
|
||||||
case info, success, warning, error
|
case info, success, warning, error
|
||||||
|
|
||||||
func styleIconName() -> Icon.Name {
|
func iconName() -> Icon.Name {
|
||||||
switch self {
|
switch self {
|
||||||
case .info:
|
case .info:
|
||||||
return .infoBold
|
return .infoBold
|
||||||
@ -52,6 +53,7 @@ open class Notification: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Orientation of Notification.
|
||||||
public enum Layout: String, CaseIterable {
|
public enum Layout: String, CaseIterable {
|
||||||
case vertical, horizontal
|
case vertical, horizontal
|
||||||
}
|
}
|
||||||
@ -80,26 +82,6 @@ open class Notification: View {
|
|||||||
$0.spacing = VDSLayout.Spacing.space2X.value
|
$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?
|
internal var onCloseSubscriber: AnyCancellable?
|
||||||
|
|
||||||
private var maxWidthConstraint: NSLayoutConstraint?
|
private var maxWidthConstraint: NSLayoutConstraint?
|
||||||
@ -181,9 +163,11 @@ open class Notification: View {
|
|||||||
open var hideCloseButton: Bool = false { didSet{setNeedsUpdate()}}
|
open var hideCloseButton: Bool = false { didSet{setNeedsUpdate()}}
|
||||||
|
|
||||||
/// Add this attribute determine your type of Notification.
|
/// 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
|
var _layout: Layout = .vertical
|
||||||
|
|
||||||
|
/// Determines the orientation of buttons and text in the Notification.
|
||||||
open var layout: Layout {
|
open var layout: Layout {
|
||||||
set {
|
set {
|
||||||
if !UIDevice.isIPad, newValue == .horizontal { return }
|
if !UIDevice.isIPad, newValue == .horizontal { return }
|
||||||
@ -198,7 +182,7 @@ open class Notification: View {
|
|||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var backgroundColorConfiguration: AnyColorable = {
|
private var backgroundColorConfiguration: AnyColorable = {
|
||||||
let config = KeyedColorConfiguration<Notification, Style>(keyPath: \.type)
|
let config = KeyedColorConfiguration<Notification, Style>(keyPath: \.style)
|
||||||
config.setSurfaceColors(VDSColor.feedbackInformationBackgroundOnlight, VDSColor.feedbackInformationBackgroundOndark, forKey: .info)
|
config.setSurfaceColors(VDSColor.feedbackInformationBackgroundOnlight, VDSColor.feedbackInformationBackgroundOndark, forKey: .info)
|
||||||
config.setSurfaceColors(VDSColor.feedbackWarningBackgroundOnlight, VDSColor.feedbackWarningBackgroundOndark, forKey: .warning)
|
config.setSurfaceColors(VDSColor.feedbackWarningBackgroundOnlight, VDSColor.feedbackWarningBackgroundOndark, forKey: .warning)
|
||||||
config.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forKey: .success)
|
config.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forKey: .success)
|
||||||
@ -211,6 +195,26 @@ open class Notification: View {
|
|||||||
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: true)
|
$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
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -257,7 +261,7 @@ open class Notification: View {
|
|||||||
primaryButtonModel = nil
|
primaryButtonModel = nil
|
||||||
secondaryButtonModel = nil
|
secondaryButtonModel = nil
|
||||||
|
|
||||||
type = .info
|
style = .info
|
||||||
typeIcon.size = UIDevice.isIPad ? .medium : .small
|
typeIcon.size = UIDevice.isIPad ? .medium : .small
|
||||||
typeIcon.name = .infoBold
|
typeIcon.name = .infoBold
|
||||||
|
|
||||||
@ -288,7 +292,7 @@ open class Notification: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private func updateIcons() {
|
private func updateIcons() {
|
||||||
let iconColor = surface == .dark ? VDSColor.paletteWhite : VDSColor.paletteBlack
|
let iconColor = surface == .dark ? VDSColor.paletteWhite : VDSColor.paletteBlack
|
||||||
typeIcon.name = type.styleIconName()
|
typeIcon.name = style.iconName()
|
||||||
typeIcon.color = iconColor
|
typeIcon.color = iconColor
|
||||||
closeButton.color = iconColor
|
closeButton.color = iconColor
|
||||||
closeButton.isHidden = hideCloseButton
|
closeButton.isHidden = hideCloseButton
|
||||||
|
|||||||
@ -76,7 +76,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
}.eraseToAnyColorable()
|
}.eraseToAnyColorable()
|
||||||
|
|
||||||
/// Representing the type of input.
|
/// Representing the type of input.
|
||||||
open var type: FieldType = .text { didSet { setNeedsUpdate() }}
|
open var fieldType: FieldType = .text { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
var _showError: Bool = false
|
var _showError: Bool = false
|
||||||
/// Whether not to show the error.
|
/// Whether not to show the error.
|
||||||
@ -159,7 +159,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
successLabel.textPosition = .left
|
successLabel.textPosition = .left
|
||||||
successLabel.textStyle = .bodySmall
|
successLabel.textStyle = .bodySmall
|
||||||
|
|
||||||
type = .text
|
fieldType = .text
|
||||||
showSuccess = false
|
showSuccess = false
|
||||||
successText = nil
|
successText = nil
|
||||||
helperTextPlacement = .bottom
|
helperTextPlacement = .bottom
|
||||||
@ -198,12 +198,12 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set the width constraints
|
//set the width constraints
|
||||||
if let width, width > type.width {
|
if let width, width > fieldType.width {
|
||||||
widthConstraint?.constant = width
|
widthConstraint?.constant = width
|
||||||
widthConstraint?.isActive = true
|
widthConstraint?.isActive = true
|
||||||
minWidthConstraint?.isActive = false
|
minWidthConstraint?.isActive = false
|
||||||
} else {
|
} else {
|
||||||
minWidthConstraint?.constant = type.width
|
minWidthConstraint?.constant = fieldType.width
|
||||||
widthConstraint?.isActive = false
|
widthConstraint?.isActive = false
|
||||||
minWidthConstraint?.isActive = true
|
minWidthConstraint?.isActive = true
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user