diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index e62e7761..fbdf5c5c 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 44604AD729CE196600E62B51 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD629CE196600E62B51 /* Line.swift */; }; 445BA07829C07B3D0036A7C5 /* Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 445BA07729C07B3D0036A7C5 /* Notification.swift */; }; 44604AD029CE17EC00E62B51 /* NotificationTitleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604ACF29CE17EC00E62B51 /* NotificationTitleModel.swift */; }; 44604AD229CE180F00E62B51 /* NotificationSubTitleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD129CE180F00E62B51 /* NotificationSubTitleModel.swift */; }; @@ -124,6 +125,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 44604AD629CE196600E62B51 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; 445BA07729C07B3D0036A7C5 /* Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notification.swift; sourceTree = ""; }; 44604ACF29CE17EC00E62B51 /* NotificationTitleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationTitleModel.swift; sourceTree = ""; }; 44604AD129CE180F00E62B51 /* NotificationSubTitleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSubTitleModel.swift; sourceTree = ""; }; @@ -253,6 +255,14 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 44604AD529CE195300E62B51 /* Line */ = { + isa = PBXGroup; + children = ( + 44604AD629CE196600E62B51 /* Line.swift */, + ); + path = Line; + sourceTree = ""; + }; 445BA07629C07ABA0036A7C5 /* Notification */ = { isa = PBXGroup; children = ( @@ -368,6 +378,7 @@ EA985BF3296C609E00F2FF2E /* Icon */, EA1F265F28B945070033E859 /* RadioSwatch */, EA3362412892EF700071C351 /* Label */, + 44604AD529CE195300E62B51 /* Line */, 445BA07629C07ABA0036A7C5 /* Notification */, EA89200B28B530F0006B9984 /* RadioBox */, EAF7F11428A1470D00B287F5 /* RadioButton */, @@ -822,6 +833,7 @@ 44604AD229CE180F00E62B51 /* NotificationSubTitleModel.swift in Sources */, EAB5FEF829393A7200998C17 /* ButtonGroupConstants.swift in Sources */, EA3361AF288B26310071C351 /* FormFieldable.swift in Sources */, + 44604AD729CE196600E62B51 /* Line.swift in Sources */, EA5E3058295105A40082B959 /* Tilelet.swift in Sources */, EA5E304E294CC7F00082B959 /* VDSColor.swift in Sources */, EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */, diff --git a/VDS/Components/Line/Line.swift b/VDS/Components/Line/Line.swift new file mode 100644 index 00000000..4ffd5b4f --- /dev/null +++ b/VDS/Components/Line/Line.swift @@ -0,0 +1,67 @@ +// +// Line.swift +// VDS +// +// Created by Nadigadda, Sumanth on 24/03/23. +// + +import Foundation +import UIKit +import VDSColorTokens + +@objc(VDSLine) +public class Line: View { + + //-------------------------------------------------- + // MARK: - Enums + //-------------------------------------------------- + public enum Style: String, CaseIterable { + case primary, secondary + } + + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + open var lineView = UIView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + } + + open var style: Style = .primary { didSet { didChange() } } + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + + open override func setup() { + super.setup() + + addSubview(lineView) + lineView.height(1) + + lineView + .pinLeading() + .pinTrailing() + } + + open override func reset() { + super.reset() + style = .primary + } + + //-------------------------------------------------- + // MARK: - Configuration + //-------------------------------------------------- + private var lineViewColorConfig: AnyColorable = { + let config = KeyedColorConfiguration(keyPath: \.style) + config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forKey: .primary) + config.setSurfaceColors(VDSColor.elementsLowContrastOnLight, VDSColor.elementsLowContrastOnDark, forKey: .secondary) + return config.eraseToAnyColorable() + }() + + //-------------------------------------------------- + // MARK: - State + //-------------------------------------------------- + open override func updateView() { + lineView.backgroundColor = lineViewColorConfig.getColor(self) + } +}