refacgtored classes
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
9605be6796
commit
422695a427
@ -11,7 +11,7 @@ import VDS
|
||||
import VDSFormControlsTokens
|
||||
import Combine
|
||||
|
||||
public class TextField: UITextField {
|
||||
open class TextField: UITextField {
|
||||
public var resigner: AnyCancellable?
|
||||
|
||||
public var resignAction: ((TextField) -> Void)?
|
||||
|
||||
@ -300,6 +300,7 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable ,
|
||||
|
||||
var activeTextField: UITextField?
|
||||
|
||||
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
|
||||
open func setup() {
|
||||
|
||||
if let textFields = allTextFields()?.filter({ $0.isKind(of: TextField.self) == false || $0.isKind(of: NumericField.self) }) {
|
||||
|
||||
@ -48,9 +48,9 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
|
||||
}
|
||||
|
||||
lazy var buttonPositionSelectorView = {
|
||||
PickerSelectorView<ButtonGroup.ButtonPosition>(title: "",
|
||||
PickerSelectorView<ButtonGroup.Alignment>(title: "",
|
||||
picker: self.picker,
|
||||
items: ButtonGroup.ButtonPosition.allCases)
|
||||
items: ButtonGroup.Alignment.allCases)
|
||||
}()
|
||||
|
||||
lazy var rowQuantitySelectorView = {
|
||||
@ -128,25 +128,25 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
if let number {
|
||||
self?.component.buttonWidth = number.cgFloatValue
|
||||
self?.smallButtonGroup.buttonWidth = number.cgFloatValue
|
||||
self?.component.childWidth = .value(number.cgFloatValue)
|
||||
self?.smallButtonGroup.childWidth = .value(number.cgFloatValue)
|
||||
self?.percentageTextField.text = ""
|
||||
} else {
|
||||
self?.component.buttonWidth = nil
|
||||
self?.component.childWidth = nil
|
||||
self?.smallButtonGroup.childWidth = nil
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
|
||||
percentageTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
let rowQty = self?.component.rowQuantity ?? 0
|
||||
if let number, number.intValue <= 100, rowQty > 0 {
|
||||
self?.component.buttonPercentage = number.cgFloatValue
|
||||
self?.smallButtonGroup.buttonPercentage = number.cgFloatValue
|
||||
if let number {
|
||||
self?.component.childWidth = .percentage(number.cgFloatValue)
|
||||
self?.smallButtonGroup.childWidth = .percentage(number.cgFloatValue)
|
||||
self?.widthTextField.text = ""
|
||||
} else {
|
||||
self?.component.buttonPercentage = nil
|
||||
self?.smallButtonGroup.buttonPercentage = nil
|
||||
self?.component.childWidth = nil
|
||||
self?.smallButtonGroup.childWidth = nil
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
|
||||
@ -155,7 +155,7 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
|
||||
func setupModel() {
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
buttonPositionSelectorView.text = component.buttonPosition.rawValue
|
||||
buttonPositionSelectorView.text = component.alignment.rawValue
|
||||
disabledSwitch.isOn = !component.isEnabled
|
||||
rowQuantitySelectorView.text = RowQuantity(quantity: component.rowQuantity).rawValue
|
||||
widthTextField.text = ""
|
||||
@ -172,8 +172,8 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
|
||||
}
|
||||
|
||||
buttonPositionSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.buttonPosition = item
|
||||
self?.smallButtonGroup.buttonPosition = item
|
||||
self?.component.alignment = item
|
||||
self?.smallButtonGroup.alignment = item
|
||||
}
|
||||
|
||||
rowQuantitySelectorView.onPickerDidSelect = { [weak self] item in
|
||||
@ -184,8 +184,8 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
|
||||
self?.percentageTextField.text = ""
|
||||
} else {
|
||||
self?.widthTextField.text = ""
|
||||
self?.component.buttonWidth = nil
|
||||
self?.smallButtonGroup.buttonWidth = nil
|
||||
self?.component.childWidth = nil
|
||||
self?.smallButtonGroup.childWidth = nil
|
||||
}
|
||||
|
||||
if UIDevice.isIPad {
|
||||
|
||||
@ -78,14 +78,14 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
var checkbox1 = CheckboxGroup.CheckboxModel()
|
||||
var checkbox1 = CheckboxGroup.CheckboxItemModel()
|
||||
checkbox1.inputId = "model1"
|
||||
checkbox1.value = "model 1 Value"
|
||||
checkbox1.labelText = "iPhone 11 Bundle 1"
|
||||
checkbox1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
checkbox1.errorText = "Please Choose 1"
|
||||
|
||||
var checkbox2 = CheckboxGroup.CheckboxModel()
|
||||
var checkbox2 = CheckboxGroup.CheckboxItemModel()
|
||||
checkbox2.inputId = "model2"
|
||||
checkbox2.value = "model 2 Value"
|
||||
checkbox2.labelText = "iPhone 11 Bundle 2"
|
||||
@ -122,14 +122,14 @@ extension CheckboxGroupViewController: ComponentSampleable {
|
||||
static func makeSample() -> ComponentSample {
|
||||
let component = Self.makeComponent()
|
||||
|
||||
var checkbox1 = CheckboxGroup.CheckboxModel()
|
||||
var checkbox1 = CheckboxGroup.CheckboxItemModel()
|
||||
checkbox1.inputId = "model1"
|
||||
checkbox1.value = "model 1 Value"
|
||||
checkbox1.labelText = "iPhone 11 Bundle 1"
|
||||
checkbox1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
checkbox1.errorText = "Please Choose 1"
|
||||
|
||||
var checkbox2 = CheckboxGroup.CheckboxModel()
|
||||
var checkbox2 = CheckboxGroup.CheckboxItemModel()
|
||||
checkbox2.inputId = "model2"
|
||||
checkbox2.value = "model 2 Value"
|
||||
checkbox2.labelText = "iPhone 11 Bundle 2"
|
||||
|
||||
@ -67,15 +67,15 @@ class RadioBoxGroupViewController: BaseViewController<RadioBoxGroup>{
|
||||
|
||||
func setupModel(){
|
||||
|
||||
var radioBox1 = RadioBoxGroup.RadioBoxModel()
|
||||
var radioBox1 = RadioBoxGroup.RadioBoxItemModel()
|
||||
radioBox1.inputId = "model1"
|
||||
radioBox1.selected = true
|
||||
radioBox1.value = "model 1 Value"
|
||||
radioBox1.text = "iPhone 11 Bundle 1"
|
||||
radioBox1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
//radioBox1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
radioBox1.subTextRight = "Right Text"
|
||||
|
||||
var radioBox2 = RadioBoxGroup.RadioBoxModel()
|
||||
var radioBox2 = RadioBoxGroup.RadioBoxItemModel()
|
||||
radioBox2.inputId = "model2"
|
||||
radioBox2.value = "model 2 Value"
|
||||
radioBox2.text = "iPhone 11 Bundle 2"
|
||||
@ -115,7 +115,7 @@ extension RadioBoxGroupViewController: ComponentSampleable {
|
||||
static func makeSample() -> ComponentSample {
|
||||
let component = Self.makeComponent()
|
||||
|
||||
var radioBox1 = RadioBoxGroup.RadioBoxModel()
|
||||
var radioBox1 = RadioBoxGroup.RadioBoxItemModel()
|
||||
radioBox1.inputId = "model1"
|
||||
radioBox1.selected = true
|
||||
radioBox1.value = "model 1 Value"
|
||||
@ -123,7 +123,7 @@ extension RadioBoxGroupViewController: ComponentSampleable {
|
||||
radioBox1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
radioBox1.subTextRight = "Right Text"
|
||||
|
||||
var radioBox2 = RadioBoxGroup.RadioBoxModel()
|
||||
var radioBox2 = RadioBoxGroup.RadioBoxItemModel()
|
||||
radioBox2.inputId = "model2"
|
||||
radioBox2.value = "model 2 Value"
|
||||
radioBox2.text = "iPhone 11 Bundle 2"
|
||||
|
||||
@ -58,19 +58,19 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
|
||||
}
|
||||
|
||||
func setupModel(){
|
||||
var radioButton1 = RadioButtonGroup.RadioButtonModel()
|
||||
var radioButton1 = RadioButtonGroup.RadioButtonItemModel()
|
||||
radioButton1.inputId = "model1"
|
||||
radioButton1.value = "model 1 Value"
|
||||
radioButton1.labelText = "iPhone 11 Bundle 1"
|
||||
radioButton1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
|
||||
var radioButton2 = RadioButtonGroup.RadioButtonModel()
|
||||
var radioButton2 = RadioButtonGroup.RadioButtonItemModel()
|
||||
radioButton2.inputId = "model2"
|
||||
radioButton2.value = "model 2 Value"
|
||||
radioButton2.labelText = "iPhone 11 Bundle 2"
|
||||
radioButton2.childText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
var radioButton3 = RadioButtonGroup.RadioButtonModel()
|
||||
var radioButton3 = RadioButtonGroup.RadioButtonItemModel()
|
||||
radioButton3.inputId = "model3"
|
||||
radioButton3.value = "model 3 Value"
|
||||
radioButton3.labelText = "iPhone 11 Bundle 3"
|
||||
@ -113,19 +113,19 @@ extension RadioButtonGroupViewController: ComponentSampleable {
|
||||
static func makeSample() -> ComponentSample {
|
||||
let component = Self.makeComponent()
|
||||
|
||||
var radioButton1 = RadioButtonGroup.RadioButtonModel()
|
||||
var radioButton1 = RadioButtonGroup.RadioButtonItemModel()
|
||||
radioButton1.inputId = "model1"
|
||||
radioButton1.value = "model 1 Value"
|
||||
radioButton1.labelText = "iPhone 11 Bundle 1"
|
||||
radioButton1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
|
||||
var radioButton2 = RadioButtonGroup.RadioButtonModel()
|
||||
var radioButton2 = RadioButtonGroup.RadioButtonItemModel()
|
||||
radioButton2.inputId = "model2"
|
||||
radioButton2.value = "model 2 Value"
|
||||
radioButton2.labelText = "iPhone 11 Bundle 2"
|
||||
radioButton2.childText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
var radioButton3 = RadioButtonGroup.RadioButtonModel()
|
||||
var radioButton3 = RadioButtonGroup.RadioButtonItemModel()
|
||||
radioButton3.inputId = "model3"
|
||||
radioButton3.value = "model 3 Value"
|
||||
radioButton3.labelText = "iPhone 11 Bundle 3"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user