diff --git a/VDS/Components/Line/Line.swift b/VDS/Components/Line/Line.swift index 484bc055..26e55907 100644 --- a/VDS/Components/Line/Line.swift +++ b/VDS/Components/Line/Line.swift @@ -41,7 +41,6 @@ open class Line: View { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - open var style: Style = .primary { didSet { setNeedsUpdate() } } open var orientation: Orientation = .horizontal { didSet { setNeedsUpdate() } } diff --git a/VDS/Components/Loader/Loader.swift b/VDS/Components/Loader/Loader.swift index 8bb3b6ae..e45e625a 100644 --- a/VDS/Components/Loader/Loader.swift +++ b/VDS/Components/Loader/Loader.swift @@ -54,7 +54,7 @@ open class Loader: View { open override var intrinsicContentSize: CGSize { .init(width: size, height: size) } //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { @@ -86,10 +86,10 @@ open class Loader: View { } //-------------------------------------------------- - // MARK: - Animation + // MARK: - Private Methods //-------------------------------------------------- private let rotationLayerName = "rotationAnimation" - func startAnimating() { + private func startAnimating() { icon.layer.remove(layerName: rotationLayerName) let rotation : CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z") rotation.toValue = NSNumber(value: Double.pi * 2) @@ -99,7 +99,7 @@ open class Loader: View { icon.layer.add(rotation, forKey: rotationLayerName) } - func stopAnimating() { + private func stopAnimating() { icon.layer.removeAnimation(forKey: rotationLayerName) } } diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 5f63dc0a..152d3077 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -32,7 +32,6 @@ open class Notification: View { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum Style: String, CaseIterable { case info, success, warning, error @@ -57,7 +56,6 @@ open class Notification: View { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- - private var mainStackView = UIStackView().with { $0.translatesAutoresizingMaskIntoConstraints = false $0.alignment = .top @@ -100,11 +98,13 @@ open class Notification: View { return fullBleed ? 1272 : 1232 } + internal var onCloseSubscriber: AnyCancellable? + private var maxWidthConstraint: NSLayoutConstraint? - open var leadingConstraint: NSLayoutConstraint? + private var leadingConstraint: NSLayoutConstraint? - open var trailingConstraint: NSLayoutConstraint? + private var trailingConstraint: NSLayoutConstraint? //-------------------------------------------------- // MARK: - Public Properties @@ -163,11 +163,7 @@ open class Notification: View { } } } - internal var onCloseSubscriber: AnyCancellable? - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - + open var hideCloseButton: Bool = false { didSet{setNeedsUpdate()}} open var type: Style = .info { didSet{setNeedsUpdate()}} @@ -203,9 +199,8 @@ open class Notification: View { } //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- - /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() @@ -276,6 +271,9 @@ open class Notification: View { setConstraints() } + //-------------------------------------------------- + // MARK: - Private Methods + //-------------------------------------------------- private func updateIcons() { let iconColor = surface == .dark ? VDSColor.paletteWhite : VDSColor.paletteBlack typeIcon.name = type.styleIconName() diff --git a/VDS/Components/RadioBox/RadioBoxGroup.swift b/VDS/Components/RadioBox/RadioBoxGroup.swift index 7b31ed47..0526a11b 100644 --- a/VDS/Components/RadioBox/RadioBoxGroup.swift +++ b/VDS/Components/RadioBox/RadioBoxGroup.swift @@ -26,6 +26,16 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase { super.init(coder: coder) } + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + private var mainStackView: UIStackView = { + return UIStackView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + $0.spacing = VDSLayout.Spacing.space3X.value + } + }() + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- @@ -67,16 +77,6 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase { setNeedsUpdate() } } - - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - private var mainStackView: UIStackView = { - return UIStackView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.spacing = VDSLayout.Spacing.space3X.value - } - }() //-------------------------------------------------- // MARK: - Overrides diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index 0c0e69c5..81b2d396 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -154,7 +154,7 @@ open class RadioBoxItem: Control, Changeable { } //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- /// Executed on initialization for this View. open override func initialSetup() { @@ -185,47 +185,7 @@ open class RadioBoxItem: Control, Changeable { selectorView.pinToSuperView() mainStackView.pinToSuperView(.init(top: 16, left: 16, bottom: 16, right: 16)) } - - func updateLabels() { - - //add the stackview to hold the 2 labels - //text label - textLabel.text = text - textLabel.surface = surface - textLabel.isEnabled = isEnabled - textLabel.attributes = textAttributes - - //subText label - if let subText { - subTextLabel.text = subText - subTextLabel.surface = surface - subTextLabel.isEnabled = isEnabled - subTextLabel.attributes = subTextAttributes - subTextLabel.isHidden = false - - } else if subTextAttributedText != nil { - subTextLabel.isHidden = false - - } else { - subTextLabel.isHidden = true - } - //subTextRight label - if let subTextRight { - subTextRightLabel.text = subTextRight - subTextRightLabel.surface = surface - subTextRightLabel.isEnabled = isEnabled - subTextRightLabel.attributes = subTextRightAttributes - subTextRightLabel.isHidden = false - - } else if subTextAttributedText != nil { - subTextRightLabel.isHidden = false - - } else { - subTextRightLabel.isHidden = true - } - } - /// Resets to default settings. open override func reset() { super.reset() @@ -281,6 +241,49 @@ open class RadioBoxItem: Control, Changeable { } } + //-------------------------------------------------- + // MARK: - Private Methods + //-------------------------------------------------- + func updateLabels() { + + //add the stackview to hold the 2 labels + //text label + textLabel.text = text + textLabel.surface = surface + textLabel.isEnabled = isEnabled + textLabel.attributes = textAttributes + + //subText label + if let subText { + subTextLabel.text = subText + subTextLabel.surface = surface + subTextLabel.isEnabled = isEnabled + subTextLabel.attributes = subTextAttributes + subTextLabel.isHidden = false + + } else if subTextAttributedText != nil { + subTextLabel.isHidden = false + + } else { + subTextLabel.isHidden = true + } + + //subTextRight label + if let subTextRight { + subTextRightLabel.text = subTextRight + subTextRightLabel.surface = surface + subTextRightLabel.isEnabled = isEnabled + subTextRightLabel.attributes = subTextRightAttributes + subTextRightLabel.isHidden = false + + } else if subTextAttributedText != nil { + subTextRightLabel.isHidden = false + + } else { + subTextRightLabel.isHidden = true + } + } + //-------------------------------------------------- // MARK: - RadioBox View Updates //-------------------------------------------------- diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index 33a1202c..91b32412 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -26,6 +26,19 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase { super.init(coder: coder) } + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + private var mainStackView: UIStackView = { + return UIStackView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + $0.alignment = .fill + $0.distribution = .fill + $0.axis = .vertical + $0.spacing = VDSLayout.Spacing.space6X.value + } + }() + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- @@ -85,19 +98,6 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase { } } - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - private var mainStackView: UIStackView = { - return UIStackView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.alignment = .fill - $0.distribution = .fill - $0.axis = .vertical - $0.spacing = VDSLayout.Spacing.space6X.value - } - }() - //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index ff8308a6..e96d65ba 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -72,7 +72,7 @@ open class RadioSwatch: Control { } //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- /// Executed on initialization for this View. open override func initialSetup() { @@ -140,21 +140,6 @@ open class RadioSwatch: Control { accessibilityLabel = text } - //-------------------------------------------------- - // MARK: - RadioBox View Updates - //-------------------------------------------------- - /// Manages the appearance of the radioSwatch. - - private var shapeLayer: CAShapeLayer? - private var gradientLayer: CAGradientLayer? - - open func getSelectorSize() -> CGSize { - return swatchSize - } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- open override func layoutSubviews() { super.layoutSubviews() // Accounts for any size changes @@ -228,6 +213,18 @@ open class RadioSwatch: Control { selectorView.layer.addSublayer(strikeThrough) } } + + //-------------------------------------------------- + // MARK: - RadioBox View Updates + //-------------------------------------------------- + /// Manages the appearance of the radioSwatch. + + private var shapeLayer: CAShapeLayer? + private var gradientLayer: CAGradientLayer? + + open func getSelectorSize() -> CGSize { + return swatchSize + } } extension UIImage { diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index 4cf0e729..17e0c23c 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -27,6 +27,31 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo super.init(coder: coder) } + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + open var label = Label() + private let cellSize: CGFloat = 48.0 + private let labelSpacing: CGFloat = 24.0 + private let labelHeight: CGFloat = 16.0 + private let lineSpacing: CGFloat = 12.0 + private let itemSpacing: CGFloat = 16.0 + + fileprivate lazy var collectionView: SelfSizingCollectionView = { + let layout = UICollectionViewFlowLayout().with { + $0.minimumLineSpacing = lineSpacing + $0.minimumInteritemSpacing = itemSpacing + } + return SelfSizingCollectionView(frame: .zero, collectionViewLayout: layout).with { + $0.backgroundColor = .clear + $0.showsHorizontalScrollIndicator = false + $0.showsVerticalScrollIndicator = false + $0.isScrollEnabled = false + $0.translatesAutoresizingMaskIntoConstraints = false + $0.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "collectionViewCell") + } + }() + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- @@ -57,31 +82,6 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo } } } - - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - open var label = Label() - private let cellSize: CGFloat = 48.0 - private let labelSpacing: CGFloat = 24.0 - private let labelHeight: CGFloat = 16.0 - private let lineSpacing: CGFloat = 12.0 - private let itemSpacing: CGFloat = 16.0 - - fileprivate lazy var collectionView: SelfSizingCollectionView = { - let layout = UICollectionViewFlowLayout().with { - $0.minimumLineSpacing = lineSpacing - $0.minimumInteritemSpacing = itemSpacing - } - return SelfSizingCollectionView(frame: .zero, collectionViewLayout: layout).with { - $0.backgroundColor = .clear - $0.showsHorizontalScrollIndicator = false - $0.showsVerticalScrollIndicator = false - $0.isScrollEnabled = false - $0.translatesAutoresizingMaskIntoConstraints = false - $0.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "collectionViewCell") - } - }() //-------------------------------------------------- // MARK: - Overrides diff --git a/VDS/Components/Tabs/Tab.swift b/VDS/Components/Tabs/Tab.swift index d0234319..7edc0487 100644 --- a/VDS/Components/Tabs/Tab.swift +++ b/VDS/Components/Tabs/Tab.swift @@ -28,7 +28,27 @@ extension Tabs { public required init?(coder: NSCoder) { super.init(coder: coder) } - + + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + /// TextStyle used on the label. + private var textStyle: TextStyle { + if size == .medium { + return .boldBodyLarge + } else { + //specs show that the font size shouldn't change however boldTitleSmall does + //change point size between iPad/iPhone. This is a "fix" so each device will + //load the correct pointSize + return UIDevice.isIPad ? .boldTitleSmall : .boldTitleMedium + } + } + + private var labelWidthConstraint: NSLayoutConstraint? + private var labelLeadingConstraint: NSLayoutConstraint? + private var labelTopConstraint: NSLayoutConstraint? + private var labelBottomConstraint: NSLayoutConstraint? + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- @@ -53,36 +73,16 @@ extension Tabs { ///Sets the Position of the Selected/Hover Border Accent for All Tabs. open var indicatorPosition: Tabs.IndicatorPosition = .bottom { didSet { setNeedsUpdate() } } - + ///If provided, it will set fixed width for this Tab. open var width: CGFloat? { didSet { setNeedsUpdate() } } - + ///The text label of the tab. open var text: String = "Tab" { didSet { setNeedsUpdate() } } ///Minimum width for the tab open var minWidth: CGFloat = 44.0 { didSet { setNeedsUpdate() } } - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - /// TextStyle used on the label. - private var textStyle: TextStyle { - if size == .medium { - return .boldBodyLarge - } else { - //specs show that the font size shouldn't change however boldTitleSmall does - //change point size between iPad/iPhone. This is a "fix" so each device will - //load the correct pointSize - return UIDevice.isIPad ? .boldTitleSmall : .boldTitleMedium - } - } - - private var labelWidthConstraint: NSLayoutConstraint? - private var labelLeadingConstraint: NSLayoutConstraint? - private var labelTopConstraint: NSLayoutConstraint? - private var labelBottomConstraint: NSLayoutConstraint? - //-------------------------------------------------- // MARK: - Configuration //-------------------------------------------------- @@ -111,7 +111,7 @@ extension Tabs { } private let layoutGuide = UILayoutGuide() - + private func updateWidth() { labelWidthConstraint?.isActive = false guard let width, width > minWidth else { return } @@ -122,13 +122,12 @@ extension Tabs { //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. - open override func setup() { + open override func setup() { super.setup() canHighlight = false - + addLayoutGuide(layoutGuide) addSubview(label) accessibilityTraits = .button @@ -136,10 +135,10 @@ extension Tabs { //pin layoutguide layoutGuide.pinToSuperView() - + //pin trailing label.pinTrailing(layoutGuide.trailingAnchor) - + //setup constraints labelWidthConstraint = layoutGuide.width(constant: 0).with { $0.isActive = false } layoutGuide.widthGreaterThanEqualTo(minWidth) @@ -153,7 +152,7 @@ extension Tabs { super.updateView() guard !text.isEmpty else { return } - + accessibilityIdentifier = "VDSTab:\(text)" //constaints @@ -161,7 +160,7 @@ extension Tabs { labelLeadingConstraint?.constant = leadingSpace labelTopConstraint?.constant = otherSpace labelBottomConstraint?.constant = -otherSpace - + //label properties label.text = text label.surface = surface @@ -181,7 +180,7 @@ extension Tabs { open override func layoutSubviews() { super.layoutSubviews() - + removeBorders() if isSelected { diff --git a/VDS/Components/Tabs/Tabs.swift b/VDS/Components/Tabs/Tabs.swift index 3c5c7814..8d3503a0 100644 --- a/VDS/Components/Tabs/Tabs.swift +++ b/VDS/Components/Tabs/Tabs.swift @@ -31,7 +31,6 @@ open class Tabs: View { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - /// Layout Axis of the Tabs public enum Orientation: String, CaseIterable{ case vertical @@ -64,11 +63,27 @@ open class Tabs: View { case large } + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + private var tabStackView = UIStackView() + private var scrollView = UIScrollView() + private var contentView = View() + private var borderlineView = View() + private let borderlineSize = 1.0 + private var borderlineColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark) + private var borderlineViewLeadingConstraint: NSLayoutConstraint? + private var borderlineViewTrailingConstraint: NSLayoutConstraint? + private var borderlineViewTopConstraint: NSLayoutConstraint? + private var borderlineViewBottomConstraint: NSLayoutConstraint? + private var borderlineViewHeightConstraint: NSLayoutConstraint? + private var borderlineViewWidthConstraint: NSLayoutConstraint? + private var contentViewWidthConstraint: NSLayoutConstraint? + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - ///An - /// callback that is called when the selectedIndex changes. Passes parameters (event, tabIndex). + /// A callback when the selectedIndex changes. Passes parameters (event, tabIndex). open var onTabChange: ((Int) -> Void)? //Determines the layout of the Tabs, defaults to horizontal @@ -106,23 +121,6 @@ open class Tabs: View { open var tabViews: [Tab] = [] - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - private var tabStackView = UIStackView() - private var scrollView = UIScrollView() - private var contentView = View() - private var borderlineView = View() - private let borderlineSize = 1.0 - private var borderlineColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark) - private var borderlineViewLeadingConstraint: NSLayoutConstraint? - private var borderlineViewTrailingConstraint: NSLayoutConstraint? - private var borderlineViewTopConstraint: NSLayoutConstraint? - private var borderlineViewBottomConstraint: NSLayoutConstraint? - private var borderlineViewHeightConstraint: NSLayoutConstraint? - private var borderlineViewWidthConstraint: NSLayoutConstraint? - private var contentViewWidthConstraint: NSLayoutConstraint? - //-------------------------------------------------- // MARK: - Configuration Properties //-------------------------------------------------- @@ -212,6 +210,11 @@ open class Tabs: View { updateBorderline() } + open override func layoutSubviews() { + super.layoutSubviews() + updateContentView() + } + //-------------------------------------------------- // MARK: - Private Methods //-------------------------------------------------- @@ -301,11 +304,6 @@ open class Tabs: View { scrollToSelectedIndex(animated: true) } - open override func layoutSubviews() { - super.layoutSubviews() - updateContentView() - } - //update layout for borderline private func updateBorderline() { //borderLine diff --git a/VDS/Components/Tabs/TabsContainer.swift b/VDS/Components/Tabs/TabsContainer.swift index 205dc2cc..06b6c3cc 100644 --- a/VDS/Components/Tabs/TabsContainer.swift +++ b/VDS/Components/Tabs/TabsContainer.swift @@ -33,6 +33,28 @@ open class TabsContainer: View { case percentage(CGFloat) case value(CGFloat) } + + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + private var contentViewWidthConstraint: NSLayoutConstraint? + + private var stackView = UIStackView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + $0.axis = .vertical + $0.alignment = .fill + $0.distribution = .fill + } + + private var contentView = UIStackView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + $0.alignment = .fill + $0.distribution = .fillProportionally + $0.axis = .vertical + $0.spacing = 10 + } + + private var tabMenuLayoutGuide = UILayoutGuide() //-------------------------------------------------- // MARK: - Public Properties @@ -118,27 +140,8 @@ open class TabsContainer: View { } //-------------------------------------------------- - // MARK: - Private Properties + // MARK: - Overrides //-------------------------------------------------- - private var contentViewWidthConstraint: NSLayoutConstraint? - - private var stackView = UIStackView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.axis = .vertical - $0.alignment = .fill - $0.distribution = .fill - } - - private var contentView = UIStackView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.alignment = .fill - $0.distribution = .fillProportionally - $0.axis = .vertical - $0.spacing = 10 - } - - private var tabMenuLayoutGuide = UILayoutGuide() - /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index 496a917b..5aac470a 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -178,7 +178,7 @@ open class EntryField: Control, Changeable { internal var widthConstraint: NSLayoutConstraint? //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { @@ -226,11 +226,7 @@ open class EntryField: Control, Changeable { errorLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable() helperLabel.textColorConfiguration = secondaryColorConfiguration.eraseToAnyColorable() } - - open func getContainer() -> UIView { - return containerView - } - + /// Resets to default settings. open override func reset() { super.reset() @@ -277,6 +273,13 @@ open class EntryField: Control, Changeable { backgroundColor = surface.color } + //-------------------------------------------------- + // MARK: - Public Methods + //-------------------------------------------------- + open func getContainer() -> UIView { + return containerView + } + open func updateTitleLabel() { //update the local vars for the label since we no diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index 9ce5b37c..a0d26046 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -47,11 +47,28 @@ open class InputField: EntryField, UITextFieldDelegate { $0.spacing = 12 } }() - + + open var textFieldTextColorConfiguration: AnyColorable = ViewColorConfiguration().with { + $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true) + $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false) + }.eraseToAnyColorable() + + internal var minWidthConstraint: NSLayoutConstraint? + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - + open var successLabel = Label().with { + $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.textPosition = .left + $0.textStyle = .bodySmall + } + + open var textField = UITextField().with { + $0.translatesAutoresizingMaskIntoConstraints = false + $0.font = TextStyle.bodyLarge.font + } + open var type: FieldType = .text { didSet { setNeedsUpdate() }} var _showError: Bool = false @@ -91,27 +108,6 @@ open class InputField: EntryField, UITextFieldDelegate { open var helperTextPlacement: HelperTextPlacement = .bottom { didSet { setNeedsUpdate() }} - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - private var successLabel = Label().with { - $0.setContentCompressionResistancePriority(.required, for: .vertical) - $0.textPosition = .left - $0.textStyle = .bodySmall - } - - private var textField = UITextField().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.font = TextStyle.bodyLarge.font - } - - open var textFieldTextColorConfiguration: AnyColorable = ViewColorConfiguration().with { - $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true) - $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false) - }.eraseToAnyColorable() - - internal var minWidthConstraint: NSLayoutConstraint? - //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index 31e11542..83b8a479 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -62,7 +62,7 @@ open class TextArea: EntryField { internal var textViewHeightConstraint: NSLayoutConstraint? //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index 9b046e9b..a61be378 100644 --- a/VDS/Components/TileContainer/TileContainer.swift +++ b/VDS/Components/TileContainer/TileContainer.swift @@ -74,6 +74,15 @@ open class TileContainer: Control { case none } + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + private var backgroundImageView = UIImageView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + $0.contentMode = .scaleAspectFill + $0.clipsToBounds = true + } + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- @@ -124,16 +133,7 @@ open class TileContainer: Control { open var showBorder: Bool = false { didSet{ setNeedsUpdate() } } open var showDropShadows: Bool = false { didSet{ setNeedsUpdate() } } - - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - private var backgroundImageView = UIImageView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.contentMode = .scaleAspectFill - $0.clipsToBounds = true - } - + //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -146,9 +146,30 @@ open class TileContainer: Control { internal var containerTrailingConstraint: NSLayoutConstraint? //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Configuration //-------------------------------------------------- + private let cornerRadius = VDSFormControls.borderradius * 2 + private var backgroundColorConfiguration = BackgroundColorConfiguration() + + private var borderColorConfiguration = SurfaceColorConfiguration().with { + $0.lightColor = VDSColor.elementsLowcontrastOnlight + $0.darkColor = VDSColor.elementsLowcontrastOndark + } + + private var imageFallbackColorConfiguration = SurfaceColorConfiguration().with { + $0.lightColor = VDSColor.backgroundPrimaryLight + $0.darkColor = VDSColor.backgroundPrimaryDark + } + + private var hightLightViewColorConfiguration = SurfaceColorConfiguration().with { + $0.lightColor = VDSColor.paletteWhite.withAlphaComponent(0.3) + $0.darkColor = VDSColor.paletteBlack.withAlphaComponent(0.3) + } + + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() @@ -248,7 +269,7 @@ open class TileContainer: Control { heightConstraint?.isActive = false } } - + //-------------------------------------------------- // MARK: - Public Methods //-------------------------------------------------- @@ -258,28 +279,6 @@ open class TileContainer: Control { view.pinToSuperView() } } - - //-------------------------------------------------- - // MARK: - Configuration - //-------------------------------------------------- - private let cornerRadius = VDSFormControls.borderradius * 2 - - private var backgroundColorConfiguration = BackgroundColorConfiguration() - - private var borderColorConfiguration = SurfaceColorConfiguration().with { - $0.lightColor = VDSColor.elementsLowcontrastOnlight - $0.darkColor = VDSColor.elementsLowcontrastOndark - } - - private var imageFallbackColorConfiguration = SurfaceColorConfiguration().with { - $0.lightColor = VDSColor.backgroundPrimaryLight - $0.darkColor = VDSColor.backgroundPrimaryDark - } - - private var hightLightViewColorConfiguration = SurfaceColorConfiguration().with { - $0.lightColor = VDSColor.paletteWhite.withAlphaComponent(0.3) - $0.darkColor = VDSColor.paletteBlack.withAlphaComponent(0.3) - } //-------------------------------------------------- // MARK: - Private Methods diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 4f068809..d132738b 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -196,9 +196,8 @@ open class Tilelet: TileContainer { internal var titleLockupTrailingConstraint: NSLayoutConstraint? //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- - /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() @@ -256,7 +255,28 @@ open class Tilelet: TileContainer { setNeedsUpdate() } - fileprivate func updateBadge() { + /// Used to make changes to the View based off a change events or from local properties. + open override func updateView() { + super.updateView() + + updateBadge() + updateTitleLockup() + updateIcons() + + layoutIfNeeded() + } + + /// Used to update any Accessibility properties. + open override func updateAccessibility() { + super.updateAccessibility() + + setAccessibilityLabel(for: [badge.label, titleLockup.eyebrowLabel, titleLockup.titleLabel, titleLockup.subTitleLabel]) + } + + //-------------------------------------------------- + // MARK: - Private Methods + //-------------------------------------------------- + private func updateBadge() { if let badgeModel { badge.text = badgeModel.text badge.fillColor = badgeModel.fillColor @@ -272,7 +292,7 @@ open class Tilelet: TileContainer { } } - fileprivate func updateTitleLockup() { + private func updateTitleLockup() { var showTitleLockup = false @@ -325,7 +345,7 @@ open class Tilelet: TileContainer { } } - fileprivate func updateIcons() { + private func updateIcons() { //icons var showIconContainerView = false if let descriptiveIconModel { @@ -365,24 +385,6 @@ open class Tilelet: TileContainer { removeFromSuperview(iconContainerView) } } - - /// Used to make changes to the View based off a change events or from local properties. - open override func updateView() { - super.updateView() - - updateBadge() - updateTitleLockup() - updateIcons() - - layoutIfNeeded() - } - - /// Used to update any Accessibility properties. - open override func updateAccessibility() { - super.updateAccessibility() - - setAccessibilityLabel(for: [badge.label, titleLockup.eyebrowLabel, titleLockup.titleLabel, titleLockup.subTitleLabel]) - } } extension TileContainer.Padding { diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index 62ce38fc..a6998925 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -252,7 +252,7 @@ open class TitleLockup: View { private var textColorPrimaryConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark).eraseToAnyColorable() //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 26990090..b44e3f4e 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -51,7 +51,7 @@ open class Toggle: Control, Changeable { private var labelConstraints: [NSLayoutConstraint] = [] //-------------------------------------------------- - // MARK: - Configuration Properties + // MARK: - Configuration //-------------------------------------------------- private let toggleContainerSize = CGSize(width: 52, height: 44) private let spacingBetween = VDSLayout.Spacing.space3X.value @@ -74,6 +74,13 @@ open class Toggle: Control, Changeable { } } + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + private var showLabel: Bool { + showText && !statusText.isEmpty + } + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- @@ -238,12 +245,8 @@ open class Toggle: Control, Changeable { } //-------------------------------------------------- - // MARK: - Labels + // MARK: - Private Methods //-------------------------------------------------- - private var showLabel: Bool { - showText && !statusText.isEmpty - } - private func updateLabel() { label.isHidden = !showLabel diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index ed94e9c8..7601b8ae 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -38,7 +38,6 @@ open class ToggleView: Control, Changeable { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- - private var toggleView = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false $0.isUserInteractionEnabled = false @@ -189,6 +188,27 @@ open class ToggleView: Control, Changeable { isOn.toggle() sendActions(for: .valueChanged) } + + open override func layoutSubviews() { + super.layoutSubviews() + + shadowLayer1.frame = knobView.bounds + shadowLayer2.frame = knobView.bounds + + let shadowColor = isEnabled ? VDSColor.paletteBlack.cgColor : VDSColor.paletteGray95.cgColor + shadowLayer1.cornerRadius = knobView.layer.cornerRadius + shadowLayer1.shadowColor = shadowColor + shadowLayer1.shadowOpacity = isEnabled ? 0.24 : 0.1 + shadowLayer1.shadowOffset = .init(width: 0, height: 1) + shadowLayer1.shadowRadius = isEnabled ? 5.0 : 10.0 + + shadowLayer2.cornerRadius = knobView.layer.cornerRadius + shadowLayer2.shadowColor = shadowColor + shadowLayer2.shadowOpacity = isEnabled ? 0.08 : 0.04 + shadowLayer2.shadowOffset = .init(width: 0, height: 2) + shadowLayer2.shadowRadius = 2.0 + + } //-------------------------------------------------- // MARK: - Private Functions @@ -231,27 +251,6 @@ open class ToggleView: Control, Changeable { }, completion: nil) } } - - open override func layoutSubviews() { - super.layoutSubviews() - - shadowLayer1.frame = knobView.bounds - shadowLayer2.frame = knobView.bounds - - let shadowColor = isEnabled ? VDSColor.paletteBlack.cgColor : VDSColor.paletteGray95.cgColor - shadowLayer1.cornerRadius = knobView.layer.cornerRadius - shadowLayer1.shadowColor = shadowColor - shadowLayer1.shadowOpacity = isEnabled ? 0.24 : 0.1 - shadowLayer1.shadowOffset = .init(width: 0, height: 1) - shadowLayer1.shadowRadius = isEnabled ? 5.0 : 10.0 - - shadowLayer2.cornerRadius = knobView.layer.cornerRadius - shadowLayer2.shadowColor = shadowColor - shadowLayer2.shadowOpacity = isEnabled ? 0.08 : 0.04 - shadowLayer2.shadowOffset = .init(width: 0, height: 2) - shadowLayer2.shadowRadius = 2.0 - - } } // MARK: AppleGuidlinesTouchable diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index 9673df4e..79d31a4f 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -105,9 +105,8 @@ open class Tooltip: Control, TooltipLaunchable { } //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- - /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() diff --git a/VDS/Components/Tooltip/TooltipAlertViewController.swift b/VDS/Components/Tooltip/TooltipAlertViewController.swift index f0a899cc..29a9aba7 100644 --- a/VDS/Components/Tooltip/TooltipAlertViewController.swift +++ b/VDS/Components/Tooltip/TooltipAlertViewController.swift @@ -64,9 +64,6 @@ open class TooltipAlertViewController: UIViewController, Surfaceable { } } - //-------------------------------------------------- - // MARK: - Lifecycle - //-------------------------------------------------- open func setup() { view.accessibilityElements = [tooltipDialog] diff --git a/VDS/Components/Tooltip/TooltipDialog.swift b/VDS/Components/Tooltip/TooltipDialog.swift index f63739b7..e53bb250 100644 --- a/VDS/Components/Tooltip/TooltipDialog.swift +++ b/VDS/Components/Tooltip/TooltipDialog.swift @@ -29,7 +29,6 @@ open class TooltipDialog: View, UIScrollViewDelegate { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- - private var scrollView = UIScrollView().with { $0.translatesAutoresizingMaskIntoConstraints = false $0.backgroundColor = .clear @@ -46,6 +45,12 @@ open class TooltipDialog: View, UIScrollViewDelegate { instance.lineViewColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark).eraseToAnyColorable() } + lazy var primaryAccessibilityElement = UIAccessibilityElement(accessibilityContainer: self).with { + $0.accessibilityLabel = "Tooltip" + $0.accessibilityValue = "expanded" + $0.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: fullWidth, height: VDSLayout.Spacing.space1X.value)) + } + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- @@ -91,7 +96,7 @@ open class TooltipDialog: View, UIScrollViewDelegate { private var heightConstraint: NSLayoutConstraint? //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { @@ -222,13 +227,7 @@ open class TooltipDialog: View, UIScrollViewDelegate { heightConstraint?.constant = contentHeight } - - lazy var primaryAccessibilityElement = UIAccessibilityElement(accessibilityContainer: self).with { - $0.accessibilityLabel = "Tooltip" - $0.accessibilityValue = "expanded" - $0.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: fullWidth, height: VDSLayout.Spacing.space1X.value)) - } - + /// Used to update any Accessibility properties. open override func updateAccessibility() { super.updateAccessibility()