refactored table content sample
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
ea9e5dd55b
commit
02315048fd
@ -219,6 +219,6 @@ extension BadgeIndicatorViewController: ComponentSampleable {
|
|||||||
component.number = 23
|
component.number = 23
|
||||||
component.kind = .simple
|
component.kind = .simple
|
||||||
component.size = .medium
|
component.size = .medium
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,6 +115,6 @@ extension BadgeViewController: ComponentSampleable {
|
|||||||
component.text = "Terms and conditions"
|
component.text = "Terms and conditions"
|
||||||
component.maxWidth = 70
|
component.maxWidth = 70
|
||||||
component.numberOfLines = 3
|
component.numberOfLines = 3
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -210,6 +210,6 @@ extension ButtonGroupViewController: ComponentSampleable {
|
|||||||
TextLinkCaret().with { $0.text = "Text Link Caret" }
|
TextLinkCaret().with { $0.text = "Text Link Caret" }
|
||||||
]
|
]
|
||||||
|
|
||||||
return ComponentSample(component: component, canPinTrailing: true)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -175,6 +175,6 @@ extension ButtonIconViewController: ComponentSampleable {
|
|||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.iconName = .addToFavorite
|
component.iconName = .addToFavorite
|
||||||
component.size = .large
|
component.size = .large
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,6 +106,6 @@ extension ButtonViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,6 +138,6 @@ extension CheckboxGroupViewController: ComponentSampleable {
|
|||||||
|
|
||||||
component.selectorModels = [checkbox1, checkbox2]
|
component.selectorModels = [checkbox1, checkbox2]
|
||||||
|
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,6 +101,6 @@ extension CheckboxItemViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,6 +65,6 @@ class CheckboxViewController: BaseViewController<Checkbox> {
|
|||||||
extension CheckboxViewController: ComponentSampleable {
|
extension CheckboxViewController: ComponentSampleable {
|
||||||
static func makeSample() -> ComponentSample {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,6 +96,6 @@ extension IconViewController: ComponentSampleable {
|
|||||||
component.color = color.uiColor
|
component.color = color.uiColor
|
||||||
component.name = name
|
component.name = name
|
||||||
component.customSize = 50
|
component.customSize = 50
|
||||||
return ComponentSample(component: component, canPinTrailing: false, canPinBottom: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual, bottomPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -179,6 +179,6 @@ extension InputFieldViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -346,6 +346,6 @@ extension LabelViewController: ComponentSampleable {
|
|||||||
static func makeSample() -> ComponentSample {
|
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 ComponentSample(component: component, canPinTrailing: true)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -160,6 +160,6 @@ extension NotificationViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: true)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,6 +131,6 @@ extension RadioBoxGroupViewController: ComponentSampleable {
|
|||||||
|
|
||||||
component.selectorModels = [radioBox1, radioBox2]
|
component.selectorModels = [radioBox1, radioBox2]
|
||||||
|
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,6 +133,6 @@ extension RadioButtonGroupViewController: ComponentSampleable {
|
|||||||
|
|
||||||
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
||||||
|
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,6 +105,6 @@ extension RadioButtonItemViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,6 +69,6 @@ class RadioButtonViewController: BaseViewController<RadioButton> {
|
|||||||
extension RadioButtonViewController: ComponentSampleable {
|
extension RadioButtonViewController: ComponentSampleable {
|
||||||
static func makeSample() -> ComponentSample {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,7 +152,7 @@ extension RadioSwatchGroupViewController: ComponentSampleable {
|
|||||||
|
|
||||||
component.selectorModels = [radioSwatch1, radioSwatch2, radioSwatch3, radioSwatch4, radioSwatch5, radioSwatch6, radioSwatch7, radioSwatch8]
|
component.selectorModels = [radioSwatch1, radioSwatch2, radioSwatch3, radioSwatch4, radioSwatch5, radioSwatch6, radioSwatch7, radioSwatch8]
|
||||||
|
|
||||||
return ComponentSample(component: component, canPinTrailing: true)
|
return ComponentSample(component: component)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
//
|
|
||||||
// TableViewTestController.swift
|
// TableViewTestController.swift
|
||||||
// VDSSample
|
// VDSSample
|
||||||
//
|
//
|
||||||
@ -14,17 +13,76 @@ public typealias ComponentSampleView = UIView & Surfaceable
|
|||||||
|
|
||||||
public struct ComponentSample {
|
public struct ComponentSample {
|
||||||
public var component: ComponentSampleView
|
public var component: ComponentSampleView
|
||||||
public var canPinLeading: Bool
|
public enum GreaterThanPinningType: String {
|
||||||
public var canPinTrailing: Bool
|
case none, equalTo, greaterThanOrEqual
|
||||||
public var canPinTop: Bool
|
}
|
||||||
public var canPinBottom: Bool
|
|
||||||
|
|
||||||
public init(component: ComponentSampleView, canPinLeading: Bool = true, canPinTrailing: Bool = true, canPinTop: Bool = true, canPinBottom: Bool = true) {
|
public enum LessThanPinningType: String {
|
||||||
|
case none, equalTo, lessThanOrEqual
|
||||||
|
}
|
||||||
|
|
||||||
|
public var top: GreaterThanPinningType = .equalTo
|
||||||
|
public var leading: GreaterThanPinningType = .equalTo
|
||||||
|
public var trailing: LessThanPinningType = .equalTo
|
||||||
|
public var bottom: LessThanPinningType = .equalTo
|
||||||
|
|
||||||
|
public init(component: ComponentSampleView,
|
||||||
|
topPinningType: GreaterThanPinningType = .equalTo,
|
||||||
|
leadingPinningType: GreaterThanPinningType = .equalTo,
|
||||||
|
trailingPinningType: LessThanPinningType = .equalTo,
|
||||||
|
bottomPinningType: LessThanPinningType = .equalTo) {
|
||||||
|
|
||||||
self.component = component
|
self.component = component
|
||||||
self.canPinLeading = canPinLeading
|
self.top = topPinningType
|
||||||
self.canPinTrailing = canPinTrailing
|
self.leading = leadingPinningType
|
||||||
self.canPinTop = canPinTop
|
self.trailing = trailingPinningType
|
||||||
self.canPinBottom = canPinBottom
|
self.bottom = bottomPinningType
|
||||||
|
}
|
||||||
|
|
||||||
|
public func pin(edgeInset: UIEdgeInsets = .zero) {
|
||||||
|
|
||||||
|
guard let superview = component.superview else { return }
|
||||||
|
switch top {
|
||||||
|
case .equalTo:
|
||||||
|
component.pinTop(anchor: superview.topAnchor, constant: edgeInset.top)
|
||||||
|
|
||||||
|
case .greaterThanOrEqual:
|
||||||
|
component.pinTopGreaterThanOrEqualTo(anchor: superview.topAnchor, constant: edgeInset.top)
|
||||||
|
|
||||||
|
case .none: break
|
||||||
|
}
|
||||||
|
|
||||||
|
switch leading {
|
||||||
|
case .equalTo:
|
||||||
|
component.pinLeading(anchor: superview.leadingAnchor, constant: edgeInset.left)
|
||||||
|
|
||||||
|
case .greaterThanOrEqual:
|
||||||
|
component.pinLeadingGreaterThanOrEqualTo(anchor: superview.leadingAnchor, constant: edgeInset.left)
|
||||||
|
|
||||||
|
case .none: break
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
switch trailing {
|
||||||
|
case .equalTo:
|
||||||
|
component.pinTrailing(anchor: superview.trailingAnchor, constant: edgeInset.right)
|
||||||
|
|
||||||
|
case .lessThanOrEqual:
|
||||||
|
component.pinTrailingLessThanOrEqualTo(anchor: superview.trailingAnchor, constant: edgeInset.right)
|
||||||
|
|
||||||
|
case .none: break
|
||||||
|
}
|
||||||
|
|
||||||
|
switch bottom {
|
||||||
|
case .equalTo:
|
||||||
|
component.pinBottom(anchor: superview.bottomAnchor, constant: edgeInset.bottom)
|
||||||
|
|
||||||
|
case .lessThanOrEqual:
|
||||||
|
component.pinBottomLessThanOrEqualTo(anchor: superview.bottomAnchor, constant: edgeInset.bottom)
|
||||||
|
|
||||||
|
case .none: break
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,9 +90,15 @@ protocol ComponentSampleable {
|
|||||||
static func makeSample() -> ComponentSample
|
static func makeSample() -> ComponentSample
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TableViewTestController: UITableViewController, Initable, Surfaceable {
|
public class TableViewTestController: UIViewController, Initable, Surfaceable {
|
||||||
|
|
||||||
var components:[ComponentSample] = []
|
var components:[ComponentSample] = []
|
||||||
|
lazy var tableView = UITableView().with {
|
||||||
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
$0.delegate = self
|
||||||
|
$0.dataSource = self
|
||||||
|
}
|
||||||
|
|
||||||
public var surface: Surface = .light {
|
public var surface: Surface = .light {
|
||||||
didSet {
|
didSet {
|
||||||
tableView.reloadData()
|
tableView.reloadData()
|
||||||
@ -46,113 +110,121 @@ public class TableViewTestController: UITableViewController, Initable, Surfaceab
|
|||||||
required public init() {
|
required public init() {
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func viewDidLoad() {
|
public override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
MenuViewController.items.forEach { menuItem in
|
|
||||||
if let componentable = menuItem.viewController as? ComponentSampleable.Type {
|
|
||||||
components.append(componentable.makeSample())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tableView.register(VDSCell.self, forCellReuseIdentifier: "cell")
|
|
||||||
tableView.allowsSelection = false
|
|
||||||
tableView.estimatedRowHeight = 45
|
|
||||||
tableView.separatorStyle = .none
|
|
||||||
tableView.rowHeight = UITableView.automaticDimension
|
|
||||||
tableView.reloadData()
|
|
||||||
let view = View(frame: .init(origin: .zero, size: .init(width: tableView.bounds.width, height: 100)))
|
|
||||||
let toggle = Toggle().with {
|
let toggle = Toggle().with {
|
||||||
$0.showText = true
|
$0.showText = true
|
||||||
$0.textPosition = .right
|
//$0.textPosition = .right
|
||||||
$0.offText = "Light"
|
$0.offText = "Light"
|
||||||
$0.onText = "Dark"
|
$0.onText = "Dark"
|
||||||
$0.onChange = { [weak self] toggle in
|
$0.onChange = { [weak self] toggle in
|
||||||
self?.surface = toggle.isOn ? .dark : .light
|
self?.surface = toggle.isOn ? .dark : .light
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view.addSubview(toggle)
|
|
||||||
toggle.pinToSuperView(.init(top: 5, left: 16, bottom: 5, right: 16))
|
let toggleSample = ComponentSample(component: toggle, leadingPinningType: .none)
|
||||||
tableView.tableHeaderView = view
|
let wrapper = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false }
|
||||||
tableView.tableHeaderView?.frame.size.height = 40
|
wrapper.addSubview(toggle)
|
||||||
|
toggleSample.pin(edgeInset: .init(top: 5, left: 5, bottom: 5, right: 5))
|
||||||
|
|
||||||
|
let stackView = UIStackView(arrangedSubviews: [wrapper, tableView]).with {
|
||||||
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
$0.axis = .vertical
|
||||||
|
$0.spacing = 4
|
||||||
|
$0.distribution = .fill
|
||||||
|
}
|
||||||
|
view.backgroundColor = Surface.light.color
|
||||||
|
view.addSubview(stackView)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
stackView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
|
||||||
|
stackView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
|
||||||
|
stackView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
|
||||||
|
stackView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
|
||||||
|
])
|
||||||
|
|
||||||
|
//var items = MenuViewController.items
|
||||||
|
let items = [
|
||||||
|
MenuComponent(title: "Badge", completed: true, viewController: BadgeViewController.self),
|
||||||
|
MenuComponent(title: "Button", completed: true, viewController: ButtonViewController.self),
|
||||||
|
MenuComponent(title: "ButtonGroup", completed: true, viewController: ButtonGroupViewController.self),
|
||||||
|
MenuComponent(title: "Icon", completed: true, viewController: IconViewController.self),
|
||||||
|
MenuComponent(title: "Line", completed: true, viewController: LineViewController.self),
|
||||||
|
MenuComponent(title: "Loader", completed: true, viewController: LoaderViewController.self),
|
||||||
|
MenuComponent(title: "Tabs", completed: true, viewController: TabsViewController.self),
|
||||||
|
MenuComponent(title: "TextLink", completed: true, viewController: TextLinkViewController.self),
|
||||||
|
MenuComponent(title: "TextLinkCaret", completed: true, viewController: TextLinkCaretViewController.self),
|
||||||
|
MenuComponent(title: "TitleLockup", completed: true, viewController: TitleLockupViewController.self),
|
||||||
|
MenuComponent(title: "Tooltip", completed: true, viewController: TooltipViewController.self)
|
||||||
|
]
|
||||||
|
|
||||||
|
items.forEach { menuItem in
|
||||||
|
if let componentable = menuItem.viewController as? ComponentSampleable.Type {
|
||||||
|
components.append(componentable.makeSample())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tableView.register(VDSCell.self, forCellReuseIdentifier: "cell")
|
||||||
|
tableView.allowsSelection = false
|
||||||
|
tableView.estimatedRowHeight = 45
|
||||||
|
tableView.separatorStyle = .singleLine
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func viewDidAppear(_ animated: Bool) {
|
||||||
|
super.viewDidAppear(animated)
|
||||||
|
tableView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func numberOfSections(in tableView: UITableView) -> Int {
|
public func refresh() {
|
||||||
components.count
|
DispatchQueue.main.async { [self] in
|
||||||
|
tableView.beginUpdates()
|
||||||
|
tableView.endUpdates()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension TableViewTestController : UITableViewDelegate, UITableViewDataSource {
|
||||||
|
|
||||||
public override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
public func numberOfSections(in tableView: UITableView) -> Int {
|
||||||
"\(type(of: components[section].component))"
|
|
||||||
}
|
|
||||||
|
|
||||||
public override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
||||||
40
|
|
||||||
}
|
|
||||||
|
|
||||||
public override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
|
components.count
|
||||||
|
}
|
||||||
|
|
||||||
public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
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
|
||||||
cell.sample = components[indexPath.section]
|
cell.sample = components[indexPath.row]
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VDSCell: UITableViewCell, AppleGuidlinesTouchable, Surfaceable {
|
public class VDSCell: UITableViewCell, Surfaceable {
|
||||||
public var surface: Surface = .light
|
public var surface: Surface = .light
|
||||||
public var sample: ComponentSample? {
|
public var sample: ComponentSample? {
|
||||||
didSet {
|
didSet {
|
||||||
contentView.subviews.forEach { $0.removeFromSuperview() }
|
contentView.subviews.forEach { $0.removeFromSuperview() }
|
||||||
let edges: UIEdgeInsets = .init(top: 16, left: 16, bottom: 16, right: 16)
|
|
||||||
guard let sample else { return }
|
guard let sample else { return }
|
||||||
|
|
||||||
var component = sample.component
|
var component = sample.component
|
||||||
component.surface = surface
|
component.surface = surface
|
||||||
|
|
||||||
|
|
||||||
let wrapper = View()
|
contentView.addSubview(component)
|
||||||
wrapper.addSubview(component)
|
sample.pin(edgeInset: .init(top: 16, left: 16, bottom: 16, right: 16))
|
||||||
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 {
|
backgroundColor = surface.color
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
|
||||||
Self.acceptablyOutsideBounds(point: point, bounds: bounds)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -153,6 +153,6 @@ extension TabsViewController: ComponentSampleable {
|
|||||||
.init(text: "Contact Us")
|
.init(text: "Contact Us")
|
||||||
]
|
]
|
||||||
|
|
||||||
return ComponentSample(component: component, canPinTrailing: true)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,6 +148,6 @@ extension TextAreaViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,6 +78,6 @@ extension TextLinkCaretViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,6 @@ extension TextLinkViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -153,6 +153,6 @@ extension TileContainerViewController: ComponentSampleable {
|
|||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
component.width = 150
|
component.width = 150
|
||||||
component.color = .black
|
component.color = .black
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -240,6 +240,6 @@ extension TileletViewController: ComponentSampleable {
|
|||||||
component.titleModel = titleModel
|
component.titleModel = titleModel
|
||||||
component.subTitleModel = subTitleModel
|
component.subTitleModel = subTitleModel
|
||||||
component.width = 250
|
component.width = 250
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -184,6 +184,6 @@ extension TitleLockupViewController: ComponentSampleable {
|
|||||||
component.titleModel = titleModel
|
component.titleModel = titleModel
|
||||||
component.subTitleModel = subTitleModel
|
component.subTitleModel = subTitleModel
|
||||||
component.debugBorder(show: true)
|
component.debugBorder(show: true)
|
||||||
return ComponentSample(component: component, canPinTrailing: true)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -119,6 +119,6 @@ class ToggleViewController: BaseViewController<Toggle> {
|
|||||||
extension ToggleViewController: ComponentSampleable {
|
extension ToggleViewController: ComponentSampleable {
|
||||||
static func makeSample() -> ComponentSample {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let component = Self.makeComponent()
|
||||||
return ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,7 +106,7 @@ extension TooltipViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: false, canPinBottom: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual, bottomPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -174,7 +174,7 @@ extension TrailingTooltipLabelViewController: ComponentSampleable {
|
|||||||
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 ComponentSample(component: component, canPinTrailing: false)
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user