refactored to sample
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
c6e578f270
commit
c742fbab35
@ -212,13 +212,13 @@ class BadgeIndicatorViewController: BaseViewController<BadgeIndicator> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension BadgeIndicatorViewController: Componentable {
|
extension BadgeIndicatorViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.fillColor = .red
|
component.fillColor = .red
|
||||||
component.number = 23
|
component.number = 23
|
||||||
component.kind = .simple
|
component.kind = .simple
|
||||||
component.size = .medium
|
component.size = .medium
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,13 +108,13 @@ class BadgeViewController: BaseViewController<Badge> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension BadgeViewController: Componentable {
|
extension BadgeViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.fillColor = .red
|
component.fillColor = .red
|
||||||
component.text = "Terms and conditions"
|
component.text = "Terms and conditions"
|
||||||
component.maxWidth = 70
|
component.maxWidth = 70
|
||||||
component.numberOfLines = 3
|
component.numberOfLines = 3
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -199,8 +199,8 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ButtonGroupViewController: Componentable {
|
extension ButtonGroupViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.buttons = [
|
component.buttons = [
|
||||||
Button().with{ $0.use = .secondary; $0.text = "Secondary" },
|
Button().with{ $0.use = .secondary; $0.text = "Secondary" },
|
||||||
@ -210,6 +210,6 @@ extension ButtonGroupViewController: Componentable {
|
|||||||
TextLinkCaret().with { $0.text = "Text Link Caret" }
|
TextLinkCaret().with { $0.text = "Text Link Caret" }
|
||||||
]
|
]
|
||||||
|
|
||||||
return TestViewWrapper(component: component, isTrailing: false)
|
return ComponentSample(component: component, canPinTrailing: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -170,11 +170,11 @@ extension UITextField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ButtonIconViewController: Componentable {
|
extension ButtonIconViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.iconName = .addToFavorite
|
component.iconName = .addToFavorite
|
||||||
component.size = .large
|
component.size = .large
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,13 +99,13 @@ class ButtonViewController: BaseViewController<Button> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ButtonViewController: Componentable {
|
extension ButtonViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.text = "Try me"
|
component.text = "Try me"
|
||||||
component.onClick = { c in print("\(c.text!) Click")}
|
component.onClick = { c in print("\(c.text!) Click")}
|
||||||
component.use = .primary
|
component.use = .primary
|
||||||
component.size = .large
|
component.size = .large
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,8 +118,8 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension CheckboxGroupViewController: Componentable {
|
extension CheckboxGroupViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
|
|
||||||
var checkbox1 = CheckboxGroup.CheckboxModel()
|
var checkbox1 = CheckboxGroup.CheckboxModel()
|
||||||
@ -138,6 +138,6 @@ extension CheckboxGroupViewController: Componentable {
|
|||||||
|
|
||||||
component.selectorModels = [checkbox1, checkbox2]
|
component.selectorModels = [checkbox1, checkbox2]
|
||||||
|
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,13 +94,13 @@ class CheckboxItemViewController: BaseViewController<CheckboxItem> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension CheckboxItemViewController: Componentable {
|
extension CheckboxItemViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.labelText = "Terms and conditions"
|
component.labelText = "Terms and conditions"
|
||||||
component.childText = "I agree to Verizon's terms and conditions click here"
|
component.childText = "I agree to Verizon's terms and conditions click here"
|
||||||
component.errorText = "Error Text"
|
component.errorText = "Error Text"
|
||||||
|
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,9 +62,9 @@ class CheckboxViewController: BaseViewController<Checkbox> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension CheckboxViewController: Componentable {
|
extension CheckboxViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,14 +88,14 @@ class IconViewController: BaseViewController<Icon> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension IconViewController: Componentable {
|
extension IconViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
let name = Icon.Name.accessibility
|
let name = Icon.Name.accessibility
|
||||||
let color = UIColor.VDSColor.paletteBlack
|
let color = UIColor.VDSColor.paletteBlack
|
||||||
component.color = color.uiColor
|
component.color = color.uiColor
|
||||||
component.name = name
|
component.name = name
|
||||||
component.size = .XLarge
|
component.size = .XLarge
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -168,8 +168,8 @@ class InputFieldViewController: BaseViewController<InputField> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extension InputFieldViewController: Componentable {
|
extension InputFieldViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.type = .text
|
component.type = .text
|
||||||
component.width = 328
|
component.width = 328
|
||||||
@ -179,6 +179,6 @@ extension InputFieldViewController: Componentable {
|
|||||||
component.successText = "Good job entering a valid address!"
|
component.successText = "Good job entering a valid address!"
|
||||||
component.tooltipTitle = "Check the formatting of your address"
|
component.tooltipTitle = "Check the formatting of your address"
|
||||||
component.tooltipContent = "House/Building number then street name"
|
component.tooltipContent = "House/Building number then street name"
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -342,10 +342,10 @@ extension Slider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extension LabelViewController: Componentable {
|
extension LabelViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.text = "Helg¹ worldg Hell¹ worldg"
|
component.text = "Helg¹ worldg Hell¹ worldg"
|
||||||
return TestViewWrapper(component: component, isTrailing: false)
|
return ComponentSample(component: component, canPinTrailing: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,9 +41,9 @@ class LineViewController: BaseViewController<Line> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension LineViewController: Componentable {
|
extension LineViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,9 +83,9 @@ class LoaderViewController: BaseViewController<Loader>, LoaderLaunchable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension LoaderViewController: Componentable {
|
extension LoaderViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -146,8 +146,8 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NotificationViewController: Componentable {
|
extension NotificationViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
|
|
||||||
let titleDefaultText = "This is title"
|
let titleDefaultText = "This is title"
|
||||||
@ -160,6 +160,6 @@ extension NotificationViewController: Componentable {
|
|||||||
component.primaryButtonModel = .init(text: firstButtonDefaultText, onClick: {b in print("\(b.text!) click")})
|
component.primaryButtonModel = .init(text: firstButtonDefaultText, onClick: {b in print("\(b.text!) click")})
|
||||||
component.secondaryButtonModel = .init(text: secondButtonDefaultText, onClick: {b in print("\(b.text!) click")})
|
component.secondaryButtonModel = .init(text: secondButtonDefaultText, onClick: {b in print("\(b.text!) click")})
|
||||||
component.onCloseClick = {_ in print("notification on close click")}
|
component.onCloseClick = {_ in print("notification on close click")}
|
||||||
return TestViewWrapper(component: component, isTrailing: false)
|
return ComponentSample(component: component, canPinTrailing: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,8 +111,8 @@ class RadioBoxGroupViewController: BaseViewController<RadioBoxGroup>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RadioBoxGroupViewController: Componentable {
|
extension RadioBoxGroupViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
|
|
||||||
var radioBox1 = RadioBoxGroup.RadioBoxModel()
|
var radioBox1 = RadioBoxGroup.RadioBoxModel()
|
||||||
@ -131,6 +131,6 @@ extension RadioBoxGroupViewController: Componentable {
|
|||||||
|
|
||||||
component.selectorModels = [radioBox1, radioBox2]
|
component.selectorModels = [radioBox1, radioBox2]
|
||||||
|
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,8 +109,8 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extension RadioButtonGroupViewController: Componentable {
|
extension RadioButtonGroupViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
|
|
||||||
var radioButton1 = RadioButtonGroup.RadioButtonModel()
|
var radioButton1 = RadioButtonGroup.RadioButtonModel()
|
||||||
@ -133,6 +133,6 @@ extension RadioButtonGroupViewController: Componentable {
|
|||||||
|
|
||||||
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
||||||
|
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,13 +98,13 @@ class RadioButtonItemViewController: BaseViewController<RadioButtonItem> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RadioButtonItemViewController: Componentable {
|
extension RadioButtonItemViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.labelText = "Terms and conditions"
|
component.labelText = "Terms and conditions"
|
||||||
component.childText = "I agree to Verizon's terms and conditions click here"
|
component.childText = "I agree to Verizon's terms and conditions click here"
|
||||||
component.errorText = "Error Text"
|
component.errorText = "Error Text"
|
||||||
|
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,9 +66,9 @@ class RadioButtonViewController: BaseViewController<RadioButton> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RadioButtonViewController: Componentable {
|
extension RadioButtonViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,8 +105,8 @@ class RadioSwatchGroupViewController: BaseViewController<RadioSwatchGroup> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RadioSwatchGroupViewController: Componentable {
|
extension RadioSwatchGroupViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
|
|
||||||
var radioSwatch1 = RadioSwatchGroup.RadioSwatchModel()
|
var radioSwatch1 = RadioSwatchGroup.RadioSwatchModel()
|
||||||
@ -152,7 +152,7 @@ extension RadioSwatchGroupViewController: Componentable {
|
|||||||
|
|
||||||
component.selectorModels = [radioSwatch1, radioSwatch2, radioSwatch3, radioSwatch4, radioSwatch5, radioSwatch6, radioSwatch7, radioSwatch8]
|
component.selectorModels = [radioSwatch1, radioSwatch2, radioSwatch3, radioSwatch4, radioSwatch5, radioSwatch6, radioSwatch7, radioSwatch8]
|
||||||
|
|
||||||
return TestViewWrapper(component: component, isTrailing: false)
|
return ComponentSample(component: component, canPinTrailing: true)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,15 +10,31 @@ import UIKit
|
|||||||
import VDS
|
import VDS
|
||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
|
|
||||||
public typealias TestView = UIView & Surfaceable
|
public typealias ComponentSampleView = UIView & Surfaceable
|
||||||
public typealias TestViewWrapper = (component: TestView, isTrailing: Bool)
|
|
||||||
protocol Componentable {
|
public struct ComponentSample {
|
||||||
static func getComponent() -> TestViewWrapper
|
public var component: ComponentSampleView
|
||||||
|
public var canPinLeading: Bool
|
||||||
|
public var canPinTrailing: Bool
|
||||||
|
public var canPinTop: Bool
|
||||||
|
public var canPinBottom: Bool
|
||||||
|
|
||||||
|
public init(component: ComponentSampleView, canPinLeading: Bool = true, canPinTrailing: Bool = true, canPinTop: Bool = true, canPinBottom: Bool = true) {
|
||||||
|
self.component = component
|
||||||
|
self.canPinLeading = canPinLeading
|
||||||
|
self.canPinTrailing = canPinTrailing
|
||||||
|
self.canPinTop = canPinTop
|
||||||
|
self.canPinBottom = canPinBottom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protocol ComponentSampleable {
|
||||||
|
static func makeSample() -> ComponentSample
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TableViewTestController: UITableViewController, Initable, Surfaceable {
|
public class TableViewTestController: UITableViewController, Initable, Surfaceable {
|
||||||
|
|
||||||
var components:[TestViewWrapper] = []
|
var components:[ComponentSample] = []
|
||||||
public var surface: Surface = .light {
|
public var surface: Surface = .light {
|
||||||
didSet {
|
didSet {
|
||||||
tableView.reloadData()
|
tableView.reloadData()
|
||||||
@ -38,8 +54,8 @@ public class TableViewTestController: UITableViewController, Initable, Surfaceab
|
|||||||
public override func viewDidLoad() {
|
public override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
MenuViewController.items.forEach { menuItem in
|
MenuViewController.items.forEach { menuItem in
|
||||||
if let componentable = menuItem.viewController as? Componentable.Type {
|
if let componentable = menuItem.viewController as? ComponentSampleable.Type {
|
||||||
components.append(componentable.getComponent())
|
components.append(componentable.makeSample())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tableView.register(VDSCell.self, forCellReuseIdentifier: "cell")
|
tableView.register(VDSCell.self, forCellReuseIdentifier: "cell")
|
||||||
@ -84,33 +100,53 @@ public class TableViewTestController: UITableViewController, Initable, Surfaceab
|
|||||||
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? VDSCell else { return UITableViewCell() }
|
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? VDSCell else { return UITableViewCell() }
|
||||||
cell.prepareForReuse()
|
cell.prepareForReuse()
|
||||||
cell.surface = surface
|
cell.surface = surface
|
||||||
let wrapper = components[indexPath.section]
|
cell.sample = components[indexPath.section]
|
||||||
cell.isTrailing = wrapper.isTrailing
|
|
||||||
cell.component = wrapper.component
|
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VDSCell: UITableViewCell, AppleGuidlinesTouchable, Surfaceable {
|
public class VDSCell: UITableViewCell, AppleGuidlinesTouchable, Surfaceable {
|
||||||
public var isTrailing: Bool = true
|
|
||||||
public var surface: Surface = .light
|
public var surface: Surface = .light
|
||||||
public var shouldWrap: Bool = true
|
public var sample: ComponentSample? {
|
||||||
public var component: TestView? {
|
|
||||||
didSet {
|
didSet {
|
||||||
contentView.subviews.forEach { $0.removeFromSuperview() }
|
contentView.subviews.forEach { $0.removeFromSuperview() }
|
||||||
let edges: UIEdgeInsets = .init(top: 16, left: 16, bottom: 16, right: 16)
|
let edges: UIEdgeInsets = .init(top: 16, left: 16, bottom: 16, right: 16)
|
||||||
guard var component else { return }
|
guard let sample else { return }
|
||||||
if shouldWrap {
|
var component = sample.component
|
||||||
let wrapper = UIView.makeWrapper(for: component, isTrailing: isTrailing)
|
|
||||||
contentView.addSubview(wrapper)
|
|
||||||
wrapper.pinToSuperView(edges)
|
|
||||||
} else {
|
|
||||||
contentView.addSubview(component)
|
|
||||||
component.pinToSuperView(edges)
|
|
||||||
}
|
|
||||||
backgroundColor = surface.color
|
|
||||||
component.surface = surface
|
component.surface = surface
|
||||||
|
|
||||||
|
|
||||||
|
let wrapper = View()
|
||||||
|
wrapper.addSubview(component)
|
||||||
|
if sample.canPinTop {
|
||||||
|
component.pinTop(anchor: wrapper.topAnchor, constant: edges.top)
|
||||||
|
} else {
|
||||||
|
component.pinTopGreaterThanOrEqualTo(anchor: wrapper.topAnchor, constant: edges.top)
|
||||||
|
}
|
||||||
|
|
||||||
|
if sample.canPinLeading {
|
||||||
|
component.pinLeading(anchor: wrapper.leadingAnchor, constant: edges.left)
|
||||||
|
} else {
|
||||||
|
component.pinLeadingGreaterThanOrEqualTo(anchor: wrapper.leadingAnchor, constant: edges.left)
|
||||||
|
}
|
||||||
|
|
||||||
|
if sample.canPinTrailing {
|
||||||
|
component.pinTrailing(anchor: wrapper.trailingAnchor, constant: edges.right)
|
||||||
|
} else {
|
||||||
|
component.pinTrailingLessThanOrEqualTo(anchor: wrapper.trailingAnchor, constant: edges.right)
|
||||||
|
}
|
||||||
|
|
||||||
|
if sample.canPinBottom {
|
||||||
|
component.pinBottom(anchor: wrapper.bottomAnchor, constant: edges.bottom)
|
||||||
|
} else {
|
||||||
|
component.pinBottomLessThanOrEqualTo(anchor: wrapper.bottomAnchor, constant: edges.bottom)
|
||||||
|
}
|
||||||
|
|
||||||
|
contentView.addSubview(wrapper)
|
||||||
|
wrapper.pinToSuperView(edges)
|
||||||
|
|
||||||
|
backgroundColor = .systemYellow //surface.color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,10 +154,5 @@ public class VDSCell: UITableViewCell, AppleGuidlinesTouchable, Surfaceable {
|
|||||||
Self.acceptablyOutsideBounds(point: point, bounds: bounds)
|
Self.acceptablyOutsideBounds(point: point, bounds: bounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override var intrinsicContentSize: CGSize {
|
|
||||||
guard let component else { return .zero }
|
|
||||||
return component.intrinsicContentSize
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -143,8 +143,8 @@ class TabsViewController: BaseViewController<Tabs> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TabsViewController: Componentable {
|
extension TabsViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.tabModels = [
|
component.tabModels = [
|
||||||
.init(text: "Accessories"),
|
.init(text: "Accessories"),
|
||||||
@ -153,6 +153,6 @@ extension TabsViewController: Componentable {
|
|||||||
.init(text: "Contact Us")
|
.init(text: "Contact Us")
|
||||||
]
|
]
|
||||||
|
|
||||||
return TestViewWrapper(component: component, isTrailing: false)
|
return ComponentSample(component: component, canPinTrailing: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,8 +139,8 @@ class TextAreaViewController: BaseViewController<TextArea> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TextAreaViewController: Componentable {
|
extension TextAreaViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.width = 328
|
component.width = 328
|
||||||
component.labelText = "Street Address"
|
component.labelText = "Street Address"
|
||||||
@ -148,6 +148,6 @@ extension TextAreaViewController: Componentable {
|
|||||||
component.errorText = "Enter a valid address."
|
component.errorText = "Enter a valid address."
|
||||||
component.tooltipTitle = "Check the formatting of your address"
|
component.tooltipTitle = "Check the formatting of your address"
|
||||||
component.tooltipContent = "House/Building number then street name"
|
component.tooltipContent = "House/Building number then street name"
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,11 +73,11 @@ class TextLinkCaretViewController: BaseViewController<TextLinkCaret> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TextLinkCaretViewController: Componentable {
|
extension TextLinkCaretViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.text = "Text Link Caret"
|
component.text = "Text Link Caret"
|
||||||
component.onClick = { c in print("\(c.text!) Click")}
|
component.onClick = { c in print("\(c.text!) Click")}
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,11 +75,11 @@ class TextLinkViewController: BaseViewController<TextLink> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TextLinkViewController: Componentable {
|
extension TextLinkViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.text = "Text Link"
|
component.text = "Text Link"
|
||||||
component.onClick = { c in print("\(c.text!) Click")}
|
component.onClick = { c in print("\(c.text!) Click")}
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,11 +148,11 @@ class TileContainerViewController: BaseViewController<TileContainer> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TileContainerViewController: Componentable {
|
extension TileContainerViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.width = 150
|
component.width = 150
|
||||||
component.color = .black
|
component.color = .black
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -230,8 +230,8 @@ class TileletViewController: BaseViewController<Tilelet> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TileletViewController: Componentable {
|
extension TileletViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
let titleModel = Tilelet.TitleModel(text: "Save $XX on your monthly bill.")
|
let titleModel = Tilelet.TitleModel(text: "Save $XX on your monthly bill.")
|
||||||
let subTitleModel = Tilelet.SubTitleModel(text: "Enroll in Auto Pay & paper-free billing to save on your monthly bill.")
|
let subTitleModel = Tilelet.SubTitleModel(text: "Enroll in Auto Pay & paper-free billing to save on your monthly bill.")
|
||||||
@ -240,6 +240,6 @@ extension TileletViewController: Componentable {
|
|||||||
component.titleModel = titleModel
|
component.titleModel = titleModel
|
||||||
component.subTitleModel = subTitleModel
|
component.subTitleModel = subTitleModel
|
||||||
component.width = 250
|
component.width = 250
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -173,8 +173,8 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TitleLockupViewController: Componentable {
|
extension TitleLockupViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
let eyebrowModel = TitleLockup.EyebrowModel(text: "Today only.")
|
let eyebrowModel = TitleLockup.EyebrowModel(text: "Today only.")
|
||||||
let titleModel = TitleLockup.TitleModel(text: "Get more of our best")
|
let titleModel = TitleLockup.TitleModel(text: "Get more of our best")
|
||||||
@ -184,6 +184,6 @@ extension TitleLockupViewController: Componentable {
|
|||||||
component.titleModel = titleModel
|
component.titleModel = titleModel
|
||||||
component.subTitleModel = subTitleModel
|
component.subTitleModel = subTitleModel
|
||||||
component.debugBorder(show: true)
|
component.debugBorder(show: true)
|
||||||
return TestViewWrapper(component: component, isTrailing: false)
|
return ComponentSample(component: component, canPinTrailing: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,9 +116,9 @@ class ToggleViewController: BaseViewController<Toggle> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ToggleViewController: Componentable {
|
extension ToggleViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,12 +101,12 @@ class TooltipViewController: BaseViewController<Tooltip> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TooltipViewController: Componentable {
|
extension TooltipViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.title = "5G Ultra Wideband is available in your area."
|
component.title = "5G Ultra Wideband is available in your area."
|
||||||
component.content = "$799.99 (128 GB only) "
|
component.content = "$799.99 (128 GB only) "
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -168,13 +168,13 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TrailingTooltipLabelViewController: Componentable {
|
extension TrailingTooltipLabelViewController: ComponentSampleable {
|
||||||
static func getComponent() -> TestViewWrapper {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.labelText = "5G Ultra Wideband is available in your area"
|
component.labelText = "5G Ultra Wideband is available in your area"
|
||||||
component.tooltipTitle = "5G Ultra Wideband is available in your area."
|
component.tooltipTitle = "5G Ultra Wideband is available in your area."
|
||||||
component.tooltipContent = "$799.99 (128 GB only)"
|
component.tooltipContent = "$799.99 (128 GB only)"
|
||||||
return TestViewWrapper(component: component, isTrailing: true)
|
return ComponentSample(component: component, canPinTrailing: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user