added click

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-01-11 16:18:54 -06:00
parent da9e8ef404
commit 1e7648b114
2 changed files with 47 additions and 10 deletions

View File

@ -9,6 +9,7 @@ import Foundation
import UIKit import UIKit
import VDS import VDS
import VDSColorTokens import VDSColorTokens
import Combine
class TileContainerViewController: BaseViewController { class TileContainerViewController: BaseViewController {
@ -34,6 +35,9 @@ class TileContainerViewController: BaseViewController {
items: TileContainer.ContainerScalingType.allCases) items: TileContainer.ContainerScalingType.allCases)
}() }()
var clickableSwitch = Toggle()
var clickableCancel: AnyCancellable?
var showBackgroundImageSwitch = Toggle() var showBackgroundImageSwitch = Toggle()
var showBorderSwitch = Toggle() var showBorderSwitch = Toggle()
var showDropShadowSwitch = Toggle() var showDropShadowSwitch = Toggle()
@ -46,20 +50,20 @@ class TileContainerViewController: BaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
addContentTopView(view: .makeWrapper(for: tileContainer)) addContentTopView(view: .makeWrapper(for: tileContainer))
tileContainer.width = 150
setupForm() setupForm()
setupPicker() setupPicker()
setupModel() setupModel()
} }
override func allTextFields() -> [TextField]? { [widthTextField, heightTextField] } override func allTextFields() -> [TextField]? { [widthTextField, heightTextField] }
func setupForm(){ func setupForm(){
formStackView.addArrangedSubview(Label().with{ formStackView.addArrangedSubview(Label().with{
$0.typograpicalStyle = .BoldBodyLarge $0.typograpicalStyle = .BoldBodyLarge
$0.text = "This object does NOT reflect normal \"surface\" changes, all properties are maually set" $0.text = "This object does NOT reflect normal \"surface\" changes, all properties are maually set"
}) })
addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Clickable", view: .makeWrapper(for: clickableSwitch))
addFormRow(label: "Width", view: widthTextField) addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "Height", view: heightTextField) addFormRow(label: "Height", view: heightTextField)
addFormRow(label: "Show Border", view: showBorderSwitch) addFormRow(label: "Show Border", view: showBorderSwitch)
@ -67,9 +71,24 @@ class TileContainerViewController: BaseViewController {
addFormRow(label: "Background Color", view: backgroundColorPickerSelectorView) addFormRow(label: "Background Color", view: backgroundColorPickerSelectorView)
addFormRow(label: "Padding", view: paddingPickerSelectorView) addFormRow(label: "Padding", view: paddingPickerSelectorView)
addFormRow(label: "Aspect Ratio", view: scalingTypePickerSelectorView) addFormRow(label: "Aspect Ratio", view: scalingTypePickerSelectorView)
addFormRow(label: "Background Image", view: showBackgroundImageSwitch) addFormRow(label: "Background Image", view: .makeWrapper(for: showBackgroundImageSwitch))
addFormRow(label: "Image Fallback Color", view: imageFallbackColorPickerSelectorView) addFormRow(label: "Image Fallback Color", view: imageFallbackColorPickerSelectorView)
clickableSwitch
.publisher(for: .valueChanged)
.sink { [weak self] sender in
if sender.isOn {
self?.clickableCancel = self?.tileContainer
.publisher(for: .touchUpInside)
.sink(receiveValue: { _ in
print("you click on me!")
})
} else {
self?.clickableCancel?.cancel()
self?.clickableCancel = nil
}
}.store(in: &subscribers)
showBackgroundImageSwitch showBackgroundImageSwitch
.publisher(for: .valueChanged) .publisher(for: .valueChanged)
.sink { [weak self] sender in .sink { [weak self] sender in
@ -117,7 +136,7 @@ class TileContainerViewController: BaseViewController {
surfacePickerSelectorView.text = tileContainer.surface.rawValue surfacePickerSelectorView.text = tileContainer.surface.rawValue
paddingPickerSelectorView.text = tileContainer.containerPadding.rawValue paddingPickerSelectorView.text = tileContainer.containerPadding.rawValue
scalingTypePickerSelectorView.text = tileContainer.aspectRatio.rawValue scalingTypePickerSelectorView.text = tileContainer.aspectRatio.rawValue
widthTextField.text = "\(tileContainer.width)" widthTextField.text = tileContainer.width != nil ? "\(tileContainer.width!)" : ""
heightTextField.text = tileContainer.height != nil ? "\(tileContainer.height!)" : "" heightTextField.text = tileContainer.height != nil ? "\(tileContainer.height!)" : ""
} }

View File

@ -9,6 +9,7 @@ import Foundation
import UIKit import UIKit
import VDS import VDS
import VDSColorTokens import VDSColorTokens
import Combine
class TiletViewController: BaseViewController { class TiletViewController: BaseViewController {
@ -30,6 +31,9 @@ class TiletViewController: BaseViewController {
items: [.primary, .secondary]) items: [.primary, .secondary])
}() }()
var clickableSwitch = Toggle()
var clickableCancel: AnyCancellable?
var titleTextField = TextField() var titleTextField = TextField()
var subTitleTextField = TextField() var subTitleTextField = TextField()
var widthTextField = NumericField() var widthTextField = NumericField()
@ -55,7 +59,8 @@ class TiletViewController: BaseViewController {
func setupForm(){ func setupForm(){
addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Clickable", view: .makeWrapper(for: clickableSwitch))
addFormRow(label: "Title Style", view: titleTextStylePickerSelectorView) addFormRow(label: "Title Style", view: titleTextStylePickerSelectorView)
addFormRow(label: "Other Style", view: otherTextStylePickerSelectorView) addFormRow(label: "Other Style", view: otherTextStylePickerSelectorView)
@ -67,9 +72,23 @@ class TiletViewController: BaseViewController {
addFormRow(label: "Text Width", view: textWidthTextField) addFormRow(label: "Text Width", view: textWidthTextField)
addFormRow(label: "Text Percentage", view: badgeTextField) addFormRow(label: "Text Percentage", view: badgeTextField)
addFormRow(label: "Badge Text", view: badgeTextField) addFormRow(label: "Badge Text", view: badgeTextField)
addFormRow(label: "Description Icon", view: showDescriptionIconSwitch) addFormRow(label: "Description Icon", view: .makeWrapper(for: showDescriptionIconSwitch))
addFormRow(label: "Directional Icon", view: showDirectionalIconSwitch) addFormRow(label: "Directional Icon", view: .makeWrapper(for: showDirectionalIconSwitch))
clickableSwitch
.publisher(for: .valueChanged)
.sink { [weak self] sender in
if sender.isOn {
self?.clickableCancel = self?.tilet
.publisher(for: .touchUpInside)
.sink(receiveValue: { _ in
print("you click on me!")
})
} else {
self?.clickableCancel?.cancel()
self?.clickableCancel = nil
}
}.store(in: &subscribers)
widthTextField widthTextField
.textPublisher .textPublisher
@ -93,7 +112,7 @@ class TiletViewController: BaseViewController {
.textPublisher .textPublisher
.sink { [weak self] text in .sink { [weak self] text in
guard let self else { return } guard let self else { return }
if let n = NumberFormatter().number(from: text), n.floatValue > 50.0 && n.floatValue <= Float(self.tilet.width) { if let n = NumberFormatter().number(from: text), n.floatValue > 50.0 {
self.tilet.textWidth = CGFloat(truncating: n) self.tilet.textWidth = CGFloat(truncating: n)
self.textPercentageTextField.text = "" self.textPercentageTextField.text = ""
} else { } else {
@ -159,7 +178,6 @@ class TiletViewController: BaseViewController {
let subTitleModel = TiletSubTitleModel(text: "Enroll in Auto Pay & paper-free billing to save on your monthly bill.") let subTitleModel = TiletSubTitleModel(text: "Enroll in Auto Pay & paper-free billing to save on your monthly bill.")
tilet.surface = .light tilet.surface = .light
tilet.width = 312
tilet.titleModel = titleModel tilet.titleModel = titleModel
tilet.subTitleModel = subTitleModel tilet.subTitleModel = subTitleModel
@ -170,7 +188,7 @@ class TiletViewController: BaseViewController {
subtitleColorPickerSelectorView.text = subTitleModel.textColor.rawValue subtitleColorPickerSelectorView.text = subTitleModel.textColor.rawValue
titleTextField.text = titleModel.text titleTextField.text = titleModel.text
subTitleTextField.text = subTitleModel.text subTitleTextField.text = subTitleModel.text
widthTextField.text = "\(tilet.width)" widthTextField.text = tilet.width != nil ? "\(tilet.width!)" : ""
} }
//sub models //sub models