ewnsure comments marks are in the correct order and naming convention

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-08-28 16:59:44 -05:00
parent fe54617a07
commit f398dcf9a8
22 changed files with 322 additions and 328 deletions

View File

@ -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() } }

View File

@ -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)
}
}

View File

@ -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()

View File

@ -26,6 +26,16 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBoxItem> {
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<RadioBoxItem> {
setNeedsUpdate()
}
}
//--------------------------------------------------
// MARK: - Private Properties
//--------------------------------------------------
private var mainStackView: UIStackView = {
return UIStackView().with {
$0.translatesAutoresizingMaskIntoConstraints = false
$0.spacing = VDSLayout.Spacing.space3X.value
}
}()
//--------------------------------------------------
// MARK: - Overrides

View File

@ -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
//--------------------------------------------------

View File

@ -26,6 +26,19 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButtonItem> {
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<RadioButtonItem> {
}
}
//--------------------------------------------------
// 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
//--------------------------------------------------

View File

@ -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 {

View File

@ -27,6 +27,31 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, 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<RadioSwatch>, 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

View File

@ -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 {

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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
//--------------------------------------------------

View File

@ -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() {

View File

@ -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

View File

@ -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 {

View File

@ -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() {

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -64,9 +64,6 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
}
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
open func setup() {
view.accessibilityElements = [tooltipDialog]

View File

@ -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()