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 {
|
extension ButtonBase {
|
||||||
func labelPublisher(_ label: UILabel){
|
func labelPublisher(_ label: UILabel){
|
||||||
onClick = { control in
|
onClick = { control in
|
||||||
|
|||||||
@ -28,8 +28,10 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
|
|||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func setupForm() {
|
var actionLabel = Label()
|
||||||
|
override func setupForm(){
|
||||||
super.setupForm()
|
super.setupForm()
|
||||||
|
addFormRow(label: "Action", view: actionLabel)
|
||||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
addFormRow(label: "Label Text", view: labelTextField)
|
addFormRow(label: "Label Text", view: labelTextField)
|
||||||
@ -55,6 +57,25 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
|
|||||||
.sink { [weak self] text in
|
.sink { [weak self] text in
|
||||||
self?.checkbox?.childText = text
|
self?.checkbox?.childText = text
|
||||||
}.store(in: &subscribers)
|
}.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() {
|
func setupModel() {
|
||||||
@ -74,18 +95,6 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
|
|||||||
|
|
||||||
component.selectorModels = [checkbox1, checkbox2]
|
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
|
//setup UI
|
||||||
surfacePickerSelectorView.text = component.surface.rawValue
|
surfacePickerSelectorView.text = component.surface.rawValue
|
||||||
disabledSwitch.isOn = component.disabled
|
disabledSwitch.isOn = component.disabled
|
||||||
|
|||||||
@ -27,8 +27,10 @@ class CheckboxItemViewController: BaseViewController<CheckboxItem> {
|
|||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var actionLabel = Label()
|
||||||
override func setupForm(){
|
override func setupForm(){
|
||||||
super.setupForm()
|
super.setupForm()
|
||||||
|
addFormRow(label: "Action", view: actionLabel)
|
||||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
addFormRow(label: "Label Text", view: labelTextField)
|
addFormRow(label: "Label Text", view: labelTextField)
|
||||||
@ -65,6 +67,8 @@ class CheckboxItemViewController: BaseViewController<CheckboxItem> {
|
|||||||
.sink { [weak self] text in
|
.sink { [weak self] text in
|
||||||
self?.component.errorText = text
|
self?.component.errorText = text
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
|
component.labelPublisher("Checkbox", label: actionLabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupModel() {
|
func setupModel() {
|
||||||
@ -72,16 +76,6 @@ class CheckboxItemViewController: BaseViewController<CheckboxItem> {
|
|||||||
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"
|
||||||
|
|
||||||
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
|
//setup UI
|
||||||
surfacePickerSelectorView.text = component.surface.rawValue
|
surfacePickerSelectorView.text = component.surface.rawValue
|
||||||
disabledSwitch.isOn = component.disabled
|
disabledSwitch.isOn = component.disabled
|
||||||
|
|||||||
@ -22,8 +22,11 @@ class CheckboxViewController: BaseViewController<Checkbox> {
|
|||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var actionLabel = Label()
|
||||||
override func setupForm(){
|
override func setupForm(){
|
||||||
super.setupForm()
|
super.setupForm()
|
||||||
|
addFormRow(label: "Action", view: actionLabel)
|
||||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
addFormRow(label: "Error", view: showErrorSwitch)
|
addFormRow(label: "Error", view: showErrorSwitch)
|
||||||
@ -40,19 +43,10 @@ class CheckboxViewController: BaseViewController<Checkbox> {
|
|||||||
self?.component.disabled = sender.isOn
|
self?.component.disabled = sender.isOn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component.labelPublisher("Checkbox", label: actionLabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupModel() {
|
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
|
//setup UI
|
||||||
surfacePickerSelectorView.text = component.surface.rawValue
|
surfacePickerSelectorView.text = component.surface.rawValue
|
||||||
disabledSwitch.isOn = component.disabled
|
disabledSwitch.isOn = component.disabled
|
||||||
|
|||||||
@ -26,8 +26,10 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
|
|||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func setupForm() {
|
var actionLabel = Label()
|
||||||
|
override func setupForm(){
|
||||||
super.setupForm()
|
super.setupForm()
|
||||||
|
addFormRow(label: "Action", view: actionLabel)
|
||||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
addFormRow(label: "Label Text", view: labelTextField)
|
addFormRow(label: "Label Text", view: labelTextField)
|
||||||
@ -78,13 +80,9 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
|
|||||||
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
||||||
|
|
||||||
component.onChange = { [weak self] group in
|
component.onChange = { [weak self] group in
|
||||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
let newText = "Selected:\r\(group.selectedHandler?.labelText ?? "none")"
|
||||||
message: "Selected:\r\(group.selectedHandler?.labelText ?? "none")",
|
self?.showErrorSwitch.isOn = group.showError
|
||||||
preferredStyle: UIAlertController.Style.alert)
|
self?.actionLabel.text = newText
|
||||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
|
||||||
self?.present(alertController, animated: true)
|
|
||||||
|
|
||||||
print("Selected: \(group.selectedHandler?.labelText ?? "none")")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//set UI values
|
//set UI values
|
||||||
|
|||||||
@ -27,8 +27,10 @@ class RadioButtonItemViewController: BaseViewController<RadioButtonItem> {
|
|||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var actionLabel = Label()
|
||||||
override func setupForm(){
|
override func setupForm(){
|
||||||
super.setupForm()
|
super.setupForm()
|
||||||
|
addFormRow(label: "Action", view: actionLabel)
|
||||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
addFormRow(label: "Label Text", view: labelTextField)
|
addFormRow(label: "Label Text", view: labelTextField)
|
||||||
@ -73,13 +75,9 @@ class RadioButtonItemViewController: BaseViewController<RadioButtonItem> {
|
|||||||
component.errorText = "Error Text"
|
component.errorText = "Error Text"
|
||||||
|
|
||||||
component.onChange = { [weak self] item in
|
component.onChange = { [weak self] item in
|
||||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
let newText = "\(item.labelText!): \(item.isSelected)"
|
||||||
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)
|
|
||||||
self?.showErrorSwitch.isOn = item.showError
|
self?.showErrorSwitch.isOn = item.showError
|
||||||
print("checkbox selected: \(item.isSelected)")
|
self?.actionLabel.text = newText
|
||||||
}
|
}
|
||||||
|
|
||||||
//setup UI
|
//setup UI
|
||||||
|
|||||||
@ -22,8 +22,10 @@ class RadioButtonViewController: BaseViewController<RadioButton> {
|
|||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
|
var actionLabel = Label()
|
||||||
override func setupForm(){
|
override func setupForm(){
|
||||||
super.setupForm()
|
super.setupForm()
|
||||||
|
addFormRow(label: "Action", view: actionLabel)
|
||||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
addFormRow(label: "Error", view: showErrorSwitch)
|
addFormRow(label: "Error", view: showErrorSwitch)
|
||||||
@ -44,12 +46,9 @@ class RadioButtonViewController: BaseViewController<RadioButton> {
|
|||||||
|
|
||||||
func setupModel() {
|
func setupModel() {
|
||||||
component.onChange = { [weak self] item in
|
component.onChange = { [weak self] item in
|
||||||
let alertController:UIAlertController = UIAlertController(title: "Alert",
|
let newText = "Radiobutton: \(item.isSelected)"
|
||||||
message: "RadioButton: \(item.isSelected)",
|
|
||||||
preferredStyle: UIAlertController.Style.alert)
|
|
||||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil))
|
|
||||||
self?.present(alertController, animated: true)
|
|
||||||
self?.showErrorSwitch.isOn = item.showError
|
self?.showErrorSwitch.isOn = item.showError
|
||||||
|
self?.actionLabel.text = newText
|
||||||
}
|
}
|
||||||
|
|
||||||
//setup UI
|
//setup UI
|
||||||
|
|||||||
@ -73,7 +73,7 @@ class TooltipViewController: BaseViewController<Tooltip> {
|
|||||||
|
|
||||||
func setupModel() {
|
func setupModel() {
|
||||||
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) 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 }
|
//component.contentView = Icon().with { $0.name = .addFolder; $0.size = .medium }
|
||||||
|
|
||||||
//setup UI
|
//setup UI
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
addContentTopView(view: component)
|
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
|
||||||
|
|
||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
@ -99,7 +99,7 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
|
|||||||
func setupModel() {
|
func setupModel() {
|
||||||
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) 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
|
//setup UI
|
||||||
surfacePickerSelectorView.text = component.surface.rawValue
|
surfacePickerSelectorView.text = component.surface.rawValue
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user