updated for actions
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
5797b5c7e9
commit
b28bfc0e55
@ -37,6 +37,22 @@ extension UIView {
|
||||
}
|
||||
}
|
||||
|
||||
extension Changeable {
|
||||
func labelPublisher(_ text: String, label: UILabel) {
|
||||
onChange = { _ in
|
||||
let newText = "\(text) clicked - "
|
||||
if let labelText = label.text {
|
||||
let components = labelText.components(separatedBy: " - ")
|
||||
let last: String = (components.last ?? "0").trimmingCharacters(in: .whitespaces)
|
||||
let count = Int(last)!
|
||||
label.text = "\(newText)\(count+1)"
|
||||
} else {
|
||||
label.text = "\(newText)1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ButtonBase {
|
||||
func labelPublisher(_ label: UILabel){
|
||||
onClick = { control in
|
||||
|
||||
@ -28,8 +28,10 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func setupForm() {
|
||||
var actionLabel = Label()
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
addFormRow(label: "Action", view: actionLabel)
|
||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Label Text", view: labelTextField)
|
||||
@ -55,6 +57,25 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
|
||||
.sink { [weak self] text in
|
||||
self?.checkbox?.childText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
component.onChange = { [weak self] group in
|
||||
guard let label = self?.actionLabel else { return }
|
||||
let selected = group.selectedHandlers?
|
||||
.compactMap{"\($0.labelText!)"}
|
||||
.joined(separator: "\r") ?? "none selected"
|
||||
|
||||
let newText = "Selected Checkboxes:\r\(selected) \rclicked - "
|
||||
if let labelText = label.text {
|
||||
let components = labelText.components(separatedBy: " - ")
|
||||
let last: String = (components.last ?? "0").trimmingCharacters(in: .whitespaces)
|
||||
let count = Int(last)!
|
||||
label.text = "\(newText)\(count+1)"
|
||||
} else {
|
||||
label.text = "\(newText)1"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
@ -73,18 +94,6 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
|
||||
checkbox2.errorText = "Please Choose 2"
|
||||
|
||||
component.selectorModels = [checkbox1, checkbox2]
|
||||
|
||||
component.onChange = { [weak self] group in
|
||||
let selected = group.selectedHandlers?
|
||||
.compactMap{"\($0.labelText!)"}
|
||||
.joined(separator: "\r") ?? "none selected"
|
||||
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "Selected Checkboxes:\r\(selected)",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
}
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
|
||||
@ -27,8 +27,10 @@ class CheckboxItemViewController: BaseViewController<CheckboxItem> {
|
||||
setupModel()
|
||||
}
|
||||
|
||||
var actionLabel = Label()
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
super.setupForm()
|
||||
addFormRow(label: "Action", view: actionLabel)
|
||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Label Text", view: labelTextField)
|
||||
@ -65,23 +67,15 @@ class CheckboxItemViewController: BaseViewController<CheckboxItem> {
|
||||
.sink { [weak self] text in
|
||||
self?.component.errorText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
component.labelPublisher("Checkbox", label: actionLabel)
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
component.labelText = "Terms and conditions"
|
||||
component.childText = "I agree to Verizon's terms and conditions click here"
|
||||
component.errorText = "Error Text"
|
||||
|
||||
component.onChange = { [weak self] checkbox in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "\(checkbox.labelText!): \(checkbox.isSelected)",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
self?.showErrorSwitch.isOn = checkbox.showError
|
||||
print("checkbox selected: \(checkbox.isSelected)")
|
||||
}
|
||||
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
disabledSwitch.isOn = component.disabled
|
||||
|
||||
@ -22,8 +22,11 @@ class CheckboxViewController: BaseViewController<Checkbox> {
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
var actionLabel = Label()
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
addFormRow(label: "Action", view: actionLabel)
|
||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Error", view: showErrorSwitch)
|
||||
@ -40,19 +43,10 @@ class CheckboxViewController: BaseViewController<Checkbox> {
|
||||
self?.component.disabled = sender.isOn
|
||||
}
|
||||
|
||||
component.labelPublisher("Checkbox", label: actionLabel)
|
||||
}
|
||||
|
||||
|
||||
func setupModel() {
|
||||
component.onChange = { [weak self] checkbox in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "Checkbox: \(checkbox.isSelected)",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
self?.showErrorSwitch.isOn = checkbox.showError
|
||||
print("checkbox selected: \(checkbox.isSelected)")
|
||||
}
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
disabledSwitch.isOn = component.disabled
|
||||
|
||||
@ -26,8 +26,10 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func setupForm() {
|
||||
var actionLabel = Label()
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
addFormRow(label: "Action", view: actionLabel)
|
||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Label Text", view: labelTextField)
|
||||
@ -78,13 +80,9 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
|
||||
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
||||
|
||||
component.onChange = { [weak self] group in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "Selected:\r\(group.selectedHandler?.labelText ?? "none")",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
|
||||
print("Selected: \(group.selectedHandler?.labelText ?? "none")")
|
||||
let newText = "Selected:\r\(group.selectedHandler?.labelText ?? "none")"
|
||||
self?.showErrorSwitch.isOn = group.showError
|
||||
self?.actionLabel.text = newText
|
||||
}
|
||||
|
||||
//set UI values
|
||||
|
||||
@ -27,8 +27,10 @@ class RadioButtonItemViewController: BaseViewController<RadioButtonItem> {
|
||||
setupModel()
|
||||
}
|
||||
|
||||
var actionLabel = Label()
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
addFormRow(label: "Action", view: actionLabel)
|
||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Label Text", view: labelTextField)
|
||||
@ -73,13 +75,9 @@ class RadioButtonItemViewController: BaseViewController<RadioButtonItem> {
|
||||
component.errorText = "Error Text"
|
||||
|
||||
component.onChange = { [weak self] item in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "\(item.labelText!): \(item.isSelected)",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
let newText = "\(item.labelText!): \(item.isSelected)"
|
||||
self?.showErrorSwitch.isOn = item.showError
|
||||
print("checkbox selected: \(item.isSelected)")
|
||||
self?.actionLabel.text = newText
|
||||
}
|
||||
|
||||
//setup UI
|
||||
|
||||
@ -22,8 +22,10 @@ class RadioButtonViewController: BaseViewController<RadioButton> {
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
var actionLabel = Label()
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
addFormRow(label: "Action", view: actionLabel)
|
||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Error", view: showErrorSwitch)
|
||||
@ -44,12 +46,9 @@ class RadioButtonViewController: BaseViewController<RadioButton> {
|
||||
|
||||
func setupModel() {
|
||||
component.onChange = { [weak self] item in
|
||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
||||
message: "RadioButton: \(item.isSelected)",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
||||
self?.present(alertController, animated: true)
|
||||
let newText = "Radiobutton: \(item.isSelected)"
|
||||
self?.showErrorSwitch.isOn = item.showError
|
||||
self?.actionLabel.text = newText
|
||||
}
|
||||
|
||||
//setup UI
|
||||
|
||||
@ -73,7 +73,7 @@ class TooltipViewController: BaseViewController<Tooltip> {
|
||||
|
||||
func setupModel() {
|
||||
component.title = "5G Ultra Wideband is available in your area."
|
||||
component.content = "$799.99 (128 GB only) device payment purchase w/new or upgrade smartphone line on postpaid 5G Unlimited plans only req'd. Less up to $800 trade-in/promo credit applied over 36 mos.; promo credit ends if eligibility req’s are no longer met; 0% APR. Trade-in conditions apply.$799.99 (128 GB only) device payment purchase w/new or upgrade smartphone line on postpaid 5G Unlimited plans only req'd. Less up to $800 trade-in. LAST"
|
||||
component.content = "$799.99 (128 GB only) "
|
||||
//component.contentView = Icon().with { $0.name = .addFolder; $0.size = .medium }
|
||||
|
||||
//setup UI
|
||||
|
||||
@ -40,7 +40,7 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
|
||||
|
||||
setupPicker()
|
||||
setupModel()
|
||||
@ -99,7 +99,7 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
|
||||
func setupModel() {
|
||||
component.labelText = "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) device payment purchase w/new or upgrade smartphone line on postpaid 5G Unlimited plans only req'd. Less up to $800 trade-in/promo credit applied over 36 mos.; promo credit ends if eligibility req’s are no longer met; 0% APR. Trade-in conditions apply.$799.99 (128 GB only) device payment purchase w/new or upgrade smartphone line on postpaid 5G Unlimited plans only req'd. Less up to $800 trade-in."
|
||||
component.tooltipContent = "$799.99 (128 GB only)"
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
|
||||
Loading…
Reference in New Issue
Block a user