128 lines
4.5 KiB
Swift
128 lines
4.5 KiB
Swift
//
|
|
// TitleLockupViewController.swift
|
|
// VDSSample
|
|
//
|
|
// Created by Matt Bruce on 12/19/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
import VDS
|
|
import VDSColorTokens
|
|
|
|
class TitleLockupViewController: BaseViewController {
|
|
|
|
lazy var textPositionPickerSelectorView = {
|
|
PickerSelectorView(title: "left",
|
|
picker: self.picker,
|
|
items: TitleLockupTextPosition.allCases)
|
|
}()
|
|
|
|
lazy var titleTextStylePickerSelectorView = {
|
|
PickerSelectorView(title: "",
|
|
picker: self.picker,
|
|
items: TitleLockupitleTypographicalStyle.allCases.sorted{ $0.rawValue < $1.rawValue })
|
|
}()
|
|
|
|
lazy var otherTextStylePickerSelectorView = {
|
|
PickerSelectorView(title: "",
|
|
picker: self.picker,
|
|
items: TitleLockupOtherTypographicalStyle.allCases.sorted{ $0.rawValue < $1.rawValue })
|
|
}()
|
|
|
|
lazy var subtitleColorPickerSelectorView = {
|
|
PickerSelectorView<Use>(title: "",
|
|
picker: self.picker,
|
|
items: [.primary, .secondary])
|
|
}()
|
|
|
|
var eyebrowTextField = TextField()
|
|
var titleTextField = TextField()
|
|
var subTitleTextField = TextField()
|
|
|
|
var titleLockup = TitleLockup()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
addContentTopView(view: titleLockup)
|
|
|
|
setupForm()
|
|
setupPicker()
|
|
setupModel()
|
|
}
|
|
|
|
override func allTextFields() -> [UITextField]? { [eyebrowTextField, titleTextField, subTitleTextField] }
|
|
|
|
func setupForm(){
|
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
|
addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
|
|
|
|
addFormRow(label: "Title Style", view: titleTextStylePickerSelectorView)
|
|
addFormRow(label: "Other Style", view: otherTextStylePickerSelectorView)
|
|
|
|
addFormRow(label: "Eyebrow Text", view: eyebrowTextField)
|
|
addFormRow(label: "Title Text", view: titleTextField)
|
|
|
|
addFormRow(label: "Subtitle Color", view: subtitleColorPickerSelectorView)
|
|
addFormRow(label: "Subtitle Text", view: subTitleTextField)
|
|
|
|
eyebrowTextField
|
|
.textPublisher
|
|
.sink { [weak self] text in
|
|
self?.titleLockup.eyebrowText = text
|
|
}.store(in: &subscribers)
|
|
|
|
titleTextField
|
|
.textPublisher
|
|
.sink { [weak self] text in
|
|
self?.titleLockup.titleText = text
|
|
}.store(in: &subscribers)
|
|
|
|
subTitleTextField
|
|
.textPublisher
|
|
.sink { [weak self] text in
|
|
self?.titleLockup.subTitleText = text
|
|
}.store(in: &subscribers)
|
|
}
|
|
|
|
func setupModel() {
|
|
titleLockup.eyebrowText = "Today only."
|
|
titleLockup.titleText = "Get more of our best"
|
|
titleLockup.subTitleText = "Get both of our best and pay less. Pair 5G Home Internet with Verizon mobile to save every month."
|
|
|
|
//setup UI
|
|
surfacePickerSelectorView.text = titleLockup.surface.rawValue
|
|
textPositionPickerSelectorView.text = titleLockup.textPosition.rawValue
|
|
otherTextStylePickerSelectorView.text = titleLockup.otherTypograpicalStyle.rawValue
|
|
titleTextStylePickerSelectorView.text = titleLockup.titleTypograpicalStyle.rawValue
|
|
subtitleColorPickerSelectorView.text = titleLockup.subTitleColor.rawValue
|
|
eyebrowTextField.text = titleLockup.eyebrowText
|
|
titleTextField.text = titleLockup.titleText
|
|
subTitleTextField.text = titleLockup.subTitleText
|
|
}
|
|
|
|
//Picker
|
|
func setupPicker(){
|
|
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
self?.titleLockup.surface = item
|
|
self?.contentTopView.backgroundColor = item.color
|
|
}
|
|
|
|
textPositionPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
self?.titleLockup.textPosition = item
|
|
}
|
|
|
|
titleTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
self?.titleLockup.titleTypograpicalStyle = item
|
|
}
|
|
|
|
otherTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
self?.titleLockup.otherTypograpicalStyle = item
|
|
}
|
|
|
|
subtitleColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
self?.titleLockup.subTitleColor = item
|
|
}
|
|
}
|
|
}
|