Digital ACT-191 ONEAPP-9314 story: did setup form, setup model, pass values to price-lockup properties.
This commit is contained in:
parent
2b14c6e068
commit
5d06bc6ac2
@ -11,6 +11,36 @@ import VDS
|
||||
|
||||
class PriceLockupViewController: BaseViewController<PriceLockup> {
|
||||
|
||||
lazy var kindPickerSelectorView = {
|
||||
PickerSelectorView(title: "primary",
|
||||
picker: self.picker,
|
||||
items: PriceLockup.Kind.allCases)
|
||||
}()
|
||||
|
||||
lazy var termPickerSelectorView = {
|
||||
PickerSelectorView(title: "month",
|
||||
picker: self.picker,
|
||||
items: PriceLockup.Term.allCases)
|
||||
}()
|
||||
|
||||
lazy var sizePickerSelectorView = {
|
||||
PickerSelectorView(title: "medium",
|
||||
picker: self.picker,
|
||||
items: PriceLockup.Size.allCases)
|
||||
}()
|
||||
|
||||
var boldSwitch = Toggle()
|
||||
var hideCurrencySwitch = Toggle()
|
||||
var strikethroughSwitch = Toggle()
|
||||
var uniformSizeSwitch = Toggle()
|
||||
|
||||
var priceTextField = NumericField()
|
||||
var leadingTextField = TextField()
|
||||
var termTextField = TextField()
|
||||
var trailingTextField = TextField()
|
||||
var superscriptTextField = TextField()
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
@ -20,9 +50,69 @@ class PriceLockupViewController: BaseViewController<PriceLockup> {
|
||||
|
||||
override func setupForm() {
|
||||
super.setupForm()
|
||||
addFormRow(label: "Bold", view: boldSwitch)
|
||||
addFormRow(label: "Kind", view: kindPickerSelectorView)
|
||||
addFormRow(label: "Size", view: sizePickerSelectorView)
|
||||
addFormRow(label: "Hide Currency", view: hideCurrencySwitch)
|
||||
addFormRow(label: "Price", view: priceTextField)
|
||||
addFormRow(label: "Leading Text", view: leadingTextField)
|
||||
addFormRow(label: "Strikethrough", view: strikethroughSwitch)
|
||||
addFormRow(label: "Uniform Size", view: uniformSizeSwitch)
|
||||
addFormRow(label: "Term", view: termPickerSelectorView)
|
||||
addFormRow(label: "Trailing Text", view: trailingTextField)
|
||||
addFormRow(label: "Superscript", view: superscriptTextField)
|
||||
|
||||
boldSwitch.publisher(for: .valueChanged).sink { [weak self] control in
|
||||
self?.component.bold = control.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
hideCurrencySwitch.publisher(for: .valueChanged).sink { [weak self] control in
|
||||
self?.component.hideCurrency = control.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
strikethroughSwitch.publisher(for: .valueChanged).sink { [weak self] control in
|
||||
self?.component.strikethrough = control.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
uniformSizeSwitch.publisher(for: .valueChanged).sink { [weak self] control in
|
||||
self?.component.uniformSize = control.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
priceTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
guard let number else { return }
|
||||
self?.component.price = number.cgFloatValue
|
||||
}.store(in: &subscribers)
|
||||
|
||||
leadingTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.leadingText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
trailingTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.trailingText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
superscriptTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.superscript = text
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
component.price = 24.99
|
||||
component.superscript = "*"
|
||||
component.leadingText = "Save"
|
||||
component.trailingText = "with Auto Pay"
|
||||
|
||||
sizePickerSelectorView.text = component.size.rawValue
|
||||
kindPickerSelectorView.text = component.kind.rawValue
|
||||
termPickerSelectorView.text = component.term.rawValue
|
||||
}
|
||||
|
||||
func setupPicker() {
|
||||
@ -30,5 +120,17 @@ class PriceLockupViewController: BaseViewController<PriceLockup> {
|
||||
self?.component.surface = item
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
}
|
||||
|
||||
kindPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.kind = item
|
||||
}
|
||||
|
||||
sizePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.size = item
|
||||
}
|
||||
|
||||
termPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.term = item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user