Merge branch 'develop' into feature/entryFields
# Conflicts: # VDSSample.xcodeproj/project.pbxproj Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
commit
edac86924a
@ -54,7 +54,7 @@
|
||||
EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */; };
|
||||
EA89205128B68307006B9984 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89205028B68307006B9984 /* TextField.swift */; };
|
||||
EAA5EEAD28EB6924003B3210 /* TextEntryFieldViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEAC28EB6924003B3210 /* TextEntryFieldViewController.swift */; };
|
||||
EAB1D2C928AAAA1D00DAE764 /* ModelScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C828AAAA1D00DAE764 /* ModelScrollViewController.swift */; };
|
||||
EAB1D2C928AAAA1D00DAE764 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */; };
|
||||
EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */; };
|
||||
EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07B2899698800B287F5 /* Assets.xcassets */; };
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */; };
|
||||
@ -118,7 +118,7 @@
|
||||
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckBoxGroupViewController.swift; sourceTree = "<group>"; };
|
||||
EA89205028B68307006B9984 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; };
|
||||
EAA5EEAC28EB6924003B3210 /* TextEntryFieldViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryFieldViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2C828AAAA1D00DAE764 /* ModelScrollViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelScrollViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelViewController.swift; sourceTree = "<group>"; };
|
||||
EAF7F07B2899698800B287F5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxViewController.swift; sourceTree = "<group>"; };
|
||||
@ -249,7 +249,7 @@
|
||||
children = (
|
||||
EA89203E28B66CE2006B9984 /* ScrollViewController */,
|
||||
EA3C3BB228996775000CA526 /* MenuViewController.swift */,
|
||||
EAB1D2C828AAAA1D00DAE764 /* ModelScrollViewController.swift */,
|
||||
EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */,
|
||||
EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */,
|
||||
5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */,
|
||||
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */,
|
||||
@ -416,7 +416,7 @@
|
||||
5FC35BE928D5235A004EBEAC /* ButtonViewController.swift in Sources */,
|
||||
EA89204A28B66CE2006B9984 /* KeyboardFrameChange.swift in Sources */,
|
||||
EA3C3BB428996775000CA526 /* PickerBase.swift in Sources */,
|
||||
EAB1D2C928AAAA1D00DAE764 /* ModelScrollViewController.swift in Sources */,
|
||||
EAB1D2C928AAAA1D00DAE764 /* BaseViewController.swift in Sources */,
|
||||
EA89204728B66CE2006B9984 /* KeyboardFrameChangeListener.swift in Sources */,
|
||||
EA4DB30428DCD25B00103EE3 /* BadgeViewController.swift in Sources */,
|
||||
EA89204828B66CE2006B9984 /* ScrollViewKeyboardAvoiding.swift in Sources */,
|
||||
|
||||
@ -2,16 +2,7 @@
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "S_1590095FQ_975.jpeg",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
|
||||
@ -11,7 +11,7 @@ import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class BadgeViewController: ModelScrollViewController<DefaultBadgeModel> {
|
||||
class BadgeViewController: BaseViewController {
|
||||
|
||||
enum NumberOfLines: String, CaseIterable {
|
||||
case unlimited
|
||||
@ -72,7 +72,7 @@ class BadgeViewController: ModelScrollViewController<DefaultBadgeModel> {
|
||||
addFormRow(label: "Fill Color", view: fillColorPickerSelectorView)
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Text", view: textField)
|
||||
addFormRow(label: "Width", view: maxWidthTextField)
|
||||
addFormRow(label: "Max Width", view: maxWidthTextField)
|
||||
addFormRow(label: "Number of Lines", view: numberOfLinesPickerSelectorView)
|
||||
|
||||
textField
|
||||
@ -93,28 +93,13 @@ class BadgeViewController: ModelScrollViewController<DefaultBadgeModel> {
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
var defaultModel = DefaultBadgeModel()
|
||||
defaultModel.fillColor = .red
|
||||
defaultModel.text = "Terms and conditions"
|
||||
defaultModel.numberOfLines = 1
|
||||
|
||||
set(with: defaultModel)
|
||||
|
||||
badge
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] viewModel in
|
||||
self?.model = viewModel
|
||||
}.store(in: &subscribers)
|
||||
|
||||
badge.fillColor = .red
|
||||
badge.text = "Terms and conditions"
|
||||
badge.numberOfLines = 1
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = model.surface.rawValue
|
||||
textField.text = model.text
|
||||
}
|
||||
|
||||
override func updateView(viewModel: DefaultBadgeModel) {
|
||||
print("\(Self.self) updateView(viewModel)")
|
||||
badge.set(with: viewModel)
|
||||
surfacePickerSelectorView.text = badge.surface.rawValue
|
||||
textField.text = badge.text
|
||||
}
|
||||
|
||||
func setupPicker(){
|
||||
|
||||
@ -10,7 +10,7 @@ import UIKit
|
||||
import Combine
|
||||
import VDS
|
||||
|
||||
public class ModelScrollViewController<ModelType: Modelable>: UIViewController, ModelHandlerable, Initable {
|
||||
public class BaseViewController: UIViewController, Initable {
|
||||
deinit {
|
||||
print("\(Self.self) deinit")
|
||||
}
|
||||
@ -21,8 +21,6 @@ public class ModelScrollViewController<ModelType: Modelable>: UIViewController,
|
||||
//--------------------------------------------------
|
||||
// MARK: - Combine Properties
|
||||
//--------------------------------------------------
|
||||
@Published public var model: ModelType = ModelType()
|
||||
public var modelPublisher: Published<ModelType>.Publisher { $model }
|
||||
public var subscribers = Set<AnyCancellable>()
|
||||
public var firstRender: Bool = false
|
||||
|
||||
@ -30,12 +28,6 @@ public class ModelScrollViewController<ModelType: Modelable>: UIViewController,
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
private var initialSetupPerformed = false
|
||||
|
||||
@Proxy(\.model.surface)
|
||||
open var surface: Surface
|
||||
|
||||
@Proxy(\.model.disabled)
|
||||
open var disabled: Bool
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -43,15 +35,8 @@ public class ModelScrollViewController<ModelType: Modelable>: UIViewController,
|
||||
required public init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
initialSetup()
|
||||
set(with: model)
|
||||
}
|
||||
|
||||
public required init(with model: ModelType) {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
initialSetup()
|
||||
set(with: model)
|
||||
}
|
||||
|
||||
|
||||
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
initialSetup()
|
||||
@ -69,7 +54,7 @@ public class ModelScrollViewController<ModelType: Modelable>: UIViewController,
|
||||
public func initialSetup() {
|
||||
if !initialSetupPerformed {
|
||||
initialSetupPerformed = true
|
||||
setupUpdateView()
|
||||
//setupUpdateView()
|
||||
setup()
|
||||
contentTopView.backgroundColor = Surface.light.color
|
||||
surfacePickerSelectorView.scrollToBottom = { [weak self] in self?.scrollToBottom()}
|
||||
@ -206,6 +191,8 @@ public class ModelScrollViewController<ModelType: Modelable>: UIViewController,
|
||||
|
||||
open func setup() {}
|
||||
|
||||
open func updateView(viewModel: ModelType) {}
|
||||
|
||||
open func updateView() {
|
||||
print("\(Self.self) updateView()")
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,7 +10,7 @@ import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
|
||||
class ButtonViewController: ModelScrollViewController<DefaultButtonModel> {
|
||||
class ButtonViewController: BaseViewController {
|
||||
|
||||
lazy var usePickerSelectorView = {
|
||||
PickerSelectorView<Use>(title: "",
|
||||
@ -77,16 +77,8 @@ class ButtonViewController: ModelScrollViewController<DefaultButtonModel> {
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
var defaultModel = DefaultButtonModel()
|
||||
defaultModel.text = "Button"
|
||||
set(with: defaultModel)
|
||||
button.text = "Button"
|
||||
|
||||
button
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] viewModel in
|
||||
self?.model = viewModel
|
||||
}.store(in: &subscribers)
|
||||
|
||||
button
|
||||
.publisher(for: .touchUpInside)
|
||||
.sink { control in
|
||||
@ -95,17 +87,13 @@ class ButtonViewController: ModelScrollViewController<DefaultButtonModel> {
|
||||
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = model.surface.rawValue
|
||||
disabledSwitch.isOn = model.disabled
|
||||
textField.text = model.text
|
||||
usePickerSelectorView.text = model.use.rawValue
|
||||
surfacePickerSelectorView.text = button.surface.rawValue
|
||||
disabledSwitch.isOn = button.disabled
|
||||
textField.text = button.text
|
||||
usePickerSelectorView.text = button.use.rawValue
|
||||
widthTextField.text = ""
|
||||
buttonSizePickerSelectorView.text = ButtonSize.large.rawValue
|
||||
}
|
||||
|
||||
override func updateView(viewModel: DefaultButtonModel) {
|
||||
button.set(with: viewModel)
|
||||
}
|
||||
|
||||
func setupPicker(){
|
||||
|
||||
|
||||
@ -11,14 +11,13 @@ import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class CheckboxGroupViewController: ModelScrollViewController<DefaultCheckboxGroupModel> {
|
||||
class CheckboxGroupViewController: BaseViewController {
|
||||
|
||||
var disabledSwitch = UISwitch()
|
||||
var labelTextField = TextField()
|
||||
var childTextField = TextField()
|
||||
var showErrorSwitch = UISwitch()
|
||||
|
||||
|
||||
var checkboxGroup = CheckboxGroup()
|
||||
|
||||
override func viewDidLoad() {
|
||||
@ -63,31 +62,24 @@ class CheckboxGroupViewController: ModelScrollViewController<DefaultCheckboxGro
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
var defaultModel = DefaultCheckboxGroupModel()
|
||||
var model1 = DefaultCheckboxModel()
|
||||
model1.inputId = "model1"
|
||||
model1.value = "model 1 Value"
|
||||
model1.labelText = "iPhone 11 Bundle 1"
|
||||
model1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
var checkbox1 = Checkbox()
|
||||
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"
|
||||
|
||||
var model2 = DefaultCheckboxModel()
|
||||
model2.inputId = "model2"
|
||||
model2.value = "model 2 Value"
|
||||
model2.labelText = "iPhone 11 Bundle 2"
|
||||
model2.childText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
defaultModel.selectors = [model1, model2]
|
||||
set(with: defaultModel)
|
||||
var checkbox2 = Checkbox()
|
||||
checkbox2.inputId = "model2"
|
||||
checkbox2.value = "model 2 Value"
|
||||
checkbox2.labelText = "iPhone 11 Bundle 2"
|
||||
checkbox2.childText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
checkboxGroup.selectorViews = [checkbox1, checkbox2]
|
||||
|
||||
checkboxGroup
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] viewModel in
|
||||
self?.model = viewModel
|
||||
}.store(in: &subscribers)
|
||||
|
||||
checkboxGroup
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { group in
|
||||
let selected = group.selectedModelHandlers?
|
||||
let selected = group.selectedHandlers?
|
||||
.compactMap{$0.labelText}
|
||||
.joined(separator: ", ") ?? "none"
|
||||
|
||||
@ -95,21 +87,14 @@ class CheckboxGroupViewController: ModelScrollViewController<DefaultCheckboxGro
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = model.surface.rawValue
|
||||
disabledSwitch.isOn = model.disabled
|
||||
labelTextField.text = model2.labelText
|
||||
childTextField.text = model1.childText
|
||||
showErrorSwitch.isOn = model.showError
|
||||
surfacePickerSelectorView.text = checkboxGroup.surface.rawValue
|
||||
disabledSwitch.isOn = checkboxGroup.disabled
|
||||
labelTextField.text = checkbox1.labelText
|
||||
childTextField.text = checkbox1.childText
|
||||
showErrorSwitch.isOn = checkboxGroup.showError
|
||||
|
||||
}
|
||||
|
||||
override func updateView(viewModel: DefaultCheckboxGroupModel) {
|
||||
print("\(Self.self) updateView(viewModel)")
|
||||
showErrorSwitch.isOn = viewModel.showError
|
||||
disabledSwitch.isOn = viewModel.disabled
|
||||
checkboxGroup.set(with: viewModel)
|
||||
}
|
||||
|
||||
|
||||
var checkbox: Checkbox? {
|
||||
checkboxGroup.selectorViews.first
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class CheckboxViewController: ModelScrollViewController<DefaultCheckboxModel> {
|
||||
class CheckboxViewController: BaseViewController {
|
||||
|
||||
var disabledSwitch = UISwitch()
|
||||
var labelTextField = TextField()
|
||||
@ -38,12 +38,6 @@ class CheckboxViewController: ModelScrollViewController<DefaultCheckboxModel> {
|
||||
addFormRow(label: "Error", view: showErrorSwitch)
|
||||
addFormRow(label: "Error Text", view: errorTextField)
|
||||
|
||||
checkbox
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] viewModel in
|
||||
self?.model = viewModel
|
||||
}.store(in: &subscribers)
|
||||
|
||||
showErrorSwitch
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { [weak self] sender in
|
||||
@ -76,18 +70,10 @@ class CheckboxViewController: ModelScrollViewController<DefaultCheckboxModel> {
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
var defaultModel = DefaultCheckboxModel()
|
||||
defaultModel.labelText = "Terms and conditions"
|
||||
defaultModel.childText = "I agree to Verizon's terms and conditions click here"
|
||||
defaultModel.errorText = "Error Text"
|
||||
set(with: defaultModel)
|
||||
checkbox.labelText = "Terms and conditions"
|
||||
checkbox.childText = "I agree to Verizon's terms and conditions click here"
|
||||
checkbox.errorText = "Error Text"
|
||||
|
||||
checkbox
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] viewModel in
|
||||
self?.model = viewModel
|
||||
}.store(in: &subscribers)
|
||||
|
||||
checkbox
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { checkbox in
|
||||
@ -95,22 +81,15 @@ class CheckboxViewController: ModelScrollViewController<DefaultCheckboxModel> {
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = model.surface.rawValue
|
||||
disabledSwitch.isOn = model.selected
|
||||
labelTextField.text = model.labelText
|
||||
childTextField.text = model.childText
|
||||
showErrorSwitch.isOn = model.showError
|
||||
errorTextField.text = model.errorText
|
||||
surfacePickerSelectorView.text = checkbox.surface.rawValue
|
||||
disabledSwitch.isOn = checkbox.disabled
|
||||
labelTextField.text = checkbox.labelText
|
||||
childTextField.text = checkbox.childText
|
||||
showErrorSwitch.isOn = checkbox.showError
|
||||
errorTextField.text = checkbox.errorText
|
||||
|
||||
}
|
||||
|
||||
override func updateView(viewModel: DefaultCheckboxModel) {
|
||||
print("\(Self.self) updateView(viewModel)")
|
||||
showErrorSwitch.isOn = viewModel.showError
|
||||
disabledSwitch.isOn = viewModel.disabled
|
||||
checkbox.set(with: viewModel)
|
||||
}
|
||||
|
||||
|
||||
//Picker
|
||||
func setupPicker(){
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
|
||||
@ -10,7 +10,7 @@ import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
|
||||
class LabelViewController: ModelScrollViewController<DefaultLabelModel> {
|
||||
class LabelViewController: BaseViewController {
|
||||
|
||||
lazy var textSizePickerSelectorView = {
|
||||
TextSizePickerSelectorView(title: "",
|
||||
@ -67,22 +67,14 @@ class LabelViewController: ModelScrollViewController<DefaultLabelModel> {
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
var defaultModel = DefaultLabelModel()
|
||||
defaultModel.text = "Label Component"
|
||||
defaultModel.typograpicalStyle = .FeatureSmall
|
||||
set(with: defaultModel)
|
||||
|
||||
label
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] viewModel in
|
||||
self?.model = viewModel
|
||||
}.store(in: &subscribers)
|
||||
label.text = "Label Component"
|
||||
label.typograpicalStyle = .FeatureSmall
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = model.surface.rawValue
|
||||
disabledSwitch.isOn = model.disabled
|
||||
surfacePickerSelectorView.text = label.surface.rawValue
|
||||
disabledSwitch.isOn = label.disabled
|
||||
boldSwitch.isOn = isBold
|
||||
textField.text = model.text
|
||||
textField.text = label.text
|
||||
|
||||
//set the font
|
||||
fontCategory = .feature
|
||||
@ -91,10 +83,6 @@ class LabelViewController: ModelScrollViewController<DefaultLabelModel> {
|
||||
textSizePickerSelectorView.text = "Small"
|
||||
}
|
||||
|
||||
override func updateView(viewModel: DefaultLabelModel) {
|
||||
label.set(with: viewModel)
|
||||
}
|
||||
|
||||
//Picker
|
||||
private var fontCategory: TypographicalStyle.FontCategory = .feature {
|
||||
didSet {
|
||||
|
||||
@ -11,7 +11,7 @@ import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class RadioBoxGroupViewController: ModelScrollViewController<DefaultRadioBoxGroupModel> {
|
||||
class RadioBoxGroupViewController: BaseViewController {
|
||||
|
||||
var disabledSwitch = UISwitch()
|
||||
var strikeThroughSwitch = UISwitch()
|
||||
@ -71,55 +71,37 @@ class RadioBoxGroupViewController: ModelScrollViewController<DefaultRadioBoxGro
|
||||
}
|
||||
|
||||
func setupModel(){
|
||||
var defaultModel = DefaultRadioBoxGroupModel()
|
||||
var model1 = DefaultRadioBoxModel()
|
||||
model1.inputId = "model1"
|
||||
model1.selected = true
|
||||
model1.value = "model 1 Value"
|
||||
model1.text = "iPhone 11 Bundle 1"
|
||||
model1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
model1.subTextRight = "Right Text"
|
||||
|
||||
var model2 = DefaultRadioBoxModel()
|
||||
model2.inputId = "model2"
|
||||
model2.value = "model 2 Value"
|
||||
model2.text = "iPhone 11 Bundle 2"
|
||||
model2.subText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
var radioBox1 = RadioBox()
|
||||
radioBox1.inputId = "model1"
|
||||
radioBox1.isSelected = 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.subTextRight = "Right Text"
|
||||
|
||||
defaultModel.selectors = [model1, model2]
|
||||
set(with: defaultModel)
|
||||
var radioBox2 = RadioBox()
|
||||
radioBox2.inputId = "model2"
|
||||
radioBox2.value = "model 2 Value"
|
||||
radioBox2.text = "iPhone 11 Bundle 2"
|
||||
radioBox2.subText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
//update the model
|
||||
radioBoxGroup
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] updatedModel in
|
||||
self?.model = updatedModel
|
||||
self?.showErrorSwitch.isOn = updatedModel.showError
|
||||
self?.disabledSwitch.isOn = updatedModel.disabled
|
||||
}
|
||||
.store(in: &subscribers)
|
||||
radioBoxGroup.selectorViews = [radioBox1, radioBox2]
|
||||
|
||||
radioBoxGroup
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { group in
|
||||
print("Selected: \(group.selectedModelHandler?.text ?? "none")")
|
||||
print("Selected: \(group.selectedHandler?.text ?? "none")")
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//set UI values
|
||||
surfacePickerSelectorView.text = model.surface.rawValue
|
||||
disabledSwitch.isOn = model.disabled
|
||||
textField.text = model1.text
|
||||
subTextField.text = model1.subText
|
||||
subTextRightField.text = model1.subTextRight
|
||||
surfacePickerSelectorView.text = radioBoxGroup.surface.rawValue
|
||||
disabledSwitch.isOn = radioBoxGroup.disabled
|
||||
textField.text = radioBox1.text
|
||||
subTextField.text = radioBox1.subText
|
||||
subTextRightField.text = radioBox1.subTextRight
|
||||
}
|
||||
|
||||
override func updateView(viewModel: ModelType) {
|
||||
print("\(Self.self) updateView(viewModel)")
|
||||
showErrorSwitch.isOn = viewModel.showError
|
||||
disabledSwitch.isOn = viewModel.disabled
|
||||
radioBoxGroup.set(with: viewModel)
|
||||
}
|
||||
|
||||
|
||||
var radioBox: RadioBox? {
|
||||
radioBoxGroup.selectorViews.first
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class RadioButtonViewController: ModelScrollViewController<DefaultRadioButtonGroupModel> {
|
||||
class RadioButtonViewController: BaseViewController {
|
||||
|
||||
var disabledSwitch = UISwitch()
|
||||
var labelTextField = TextField()
|
||||
@ -63,56 +63,38 @@ class RadioButtonViewController: ModelScrollViewController<DefaultRadioButtonGr
|
||||
}
|
||||
|
||||
func setupModel(){
|
||||
var defaultModel = DefaultRadioButtonGroupModel()
|
||||
var model1 = DefaultRadioButtonModel()
|
||||
model1.inputId = "model1"
|
||||
model1.value = "model 1 Value"
|
||||
model1.labelText = "iPhone 11 Bundle 1"
|
||||
model1.childText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector"
|
||||
let radioButton1 = RadioButton()
|
||||
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 model2 = DefaultRadioButtonModel()
|
||||
model2.inputId = "model2"
|
||||
model2.value = "model 2 Value"
|
||||
model2.labelText = "iPhone 11 Bundle 2"
|
||||
model2.childText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
|
||||
let radioButton2 = RadioButton()
|
||||
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 model3 = DefaultRadioButtonModel()
|
||||
model3.inputId = "model3"
|
||||
model3.value = "model 3 Value"
|
||||
model3.labelText = "iPhone 11 Bundle 3"
|
||||
model3.childText = "Apple iPhone 11 - 256 GB\nOtterbox Case Black\nScreen Protector"
|
||||
defaultModel.selectors = [model1, model2, model3]
|
||||
set(with: defaultModel)
|
||||
|
||||
//update the model
|
||||
radioButtonGroup
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] updatedModel in
|
||||
self?.model = updatedModel
|
||||
self?.showErrorSwitch.isOn = updatedModel.showError
|
||||
self?.disabledSwitch.isOn = updatedModel.disabled
|
||||
}
|
||||
.store(in: &subscribers)
|
||||
let radioButton3 = RadioButton()
|
||||
radioButton3.inputId = "model3"
|
||||
radioButton3.value = "model 3 Value"
|
||||
radioButton3.labelText = "iPhone 11 Bundle 3"
|
||||
radioButton3.childText = "Apple iPhone 11 - 256 GB\nOtterbox Case Black\nScreen Protector"
|
||||
|
||||
radioButtonGroup.selectorViews = [radioButton1, radioButton2, radioButton3]
|
||||
|
||||
radioButtonGroup
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { group in
|
||||
print("Selected: \(group.selectedModelHandler?.labelText ?? "none")")
|
||||
print("Selected: \(group.selectedHandler?.labelText ?? "none")")
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//set UI values
|
||||
surfacePickerSelectorView.text = model.surface.rawValue
|
||||
disabledSwitch.isOn = model.disabled
|
||||
showErrorSwitch.isOn = model.showError
|
||||
labelTextField.text = model1.labelText
|
||||
childTextField.text = model1.childText
|
||||
}
|
||||
|
||||
override func updateView(viewModel: DefaultRadioButtonGroupModel) {
|
||||
print("\(Self.self) updateView(viewModel)")
|
||||
showErrorSwitch.isOn = viewModel.showError
|
||||
disabledSwitch.isOn = viewModel.disabled
|
||||
radioButtonGroup.set(with: viewModel)
|
||||
surfacePickerSelectorView.text = radioButtonGroup.surface.rawValue
|
||||
disabledSwitch.isOn = radioButtonGroup.disabled
|
||||
showErrorSwitch.isOn = radioButtonGroup.showError
|
||||
labelTextField.text = radioButton1.labelText
|
||||
childTextField.text = radioButton1.childText
|
||||
}
|
||||
|
||||
var radioButton: RadioButton? {
|
||||
|
||||
@ -11,7 +11,7 @@ import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class RadioSwatchGroupViewController: ModelScrollViewController<DefaultRadioSwatchGroupModel> {
|
||||
class RadioSwatchGroupViewController: BaseViewController {
|
||||
|
||||
var disabledSwitch = UISwitch()
|
||||
var strikeThroughSwitch = UISwitch()
|
||||
@ -39,93 +39,64 @@ class RadioSwatchGroupViewController: ModelScrollViewController<DefaultRadioSwa
|
||||
strikeThroughSwitch
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { [weak self] sender in
|
||||
let selectors = self?.model.selectors.compactMap { existing in
|
||||
if existing.id == self?.model.selectors.first?.id {
|
||||
return existing.copyWith {
|
||||
$0.strikethrough = sender.isOn
|
||||
}
|
||||
} else {
|
||||
return existing
|
||||
}
|
||||
}
|
||||
if let selectors {
|
||||
self?.model.selectors = selectors
|
||||
}
|
||||
self?.radioSwatchGroup.selectorViews.first?.strikethrough = sender.isOn
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
func setupModel(){
|
||||
var defaultModel = DefaultRadioSwatchGroupModel()
|
||||
|
||||
var model1 = DefaultRadioSwatchModel()
|
||||
model1.fillImage = UIImage(named: "imageSwatch")
|
||||
model1.text = "Image"
|
||||
model1.inputId = "radioSwatch1"
|
||||
let radioSwatch1 = RadioSwatch()
|
||||
radioSwatch1.fillImage = UIImage(named: "imageSwatch")
|
||||
radioSwatch1.text = "Image"
|
||||
radioSwatch1.inputId = "radioSwatch1"
|
||||
|
||||
var model2 = DefaultRadioSwatchModel()
|
||||
model2.primaryColor = .red
|
||||
model2.secondaryColor = .blue
|
||||
model2.text = "Red/Blue"
|
||||
model2.inputId = "radioSwatch2"
|
||||
let radioSwatch2 = RadioSwatch()
|
||||
radioSwatch2.primaryColor = .red
|
||||
radioSwatch2.secondaryColor = .blue
|
||||
radioSwatch2.text = "Red/Blue"
|
||||
radioSwatch2.inputId = "radioSwatch2"
|
||||
|
||||
var model3 = DefaultRadioSwatchModel()
|
||||
model3.primaryColor = .green
|
||||
model3.text = "Green"
|
||||
model3.inputId = "radioSwatch3"
|
||||
let radioSwatch3 = RadioSwatch()
|
||||
radioSwatch3.primaryColor = .green
|
||||
radioSwatch3.text = "Green"
|
||||
radioSwatch3.inputId = "radioSwatch3"
|
||||
|
||||
var model4 = DefaultRadioSwatchModel()
|
||||
model4.primaryColor = .orange
|
||||
model4.text = "Orange"
|
||||
model4.inputId = "radioSwatch4"
|
||||
let radioSwatch4 = RadioSwatch()
|
||||
radioSwatch4.primaryColor = .orange
|
||||
radioSwatch4.text = "Orange"
|
||||
radioSwatch4.inputId = "radioSwatch4"
|
||||
|
||||
var model5 = DefaultRadioSwatchModel()
|
||||
model5.primaryColor = .brown
|
||||
model5.text = "Brown"
|
||||
model5.inputId = "radioSwatch5"
|
||||
let radioSwatch5 = RadioSwatch()
|
||||
radioSwatch5.primaryColor = .brown
|
||||
radioSwatch5.text = "Brown"
|
||||
radioSwatch5.inputId = "radioSwatch5"
|
||||
|
||||
var model6 = DefaultRadioSwatchModel()
|
||||
model6.primaryColor = .yellow
|
||||
model6.text = "Yellow"
|
||||
model6.inputId = "radioSwatch6"
|
||||
let radioSwatch6 = RadioSwatch()
|
||||
radioSwatch6.primaryColor = .yellow
|
||||
radioSwatch6.text = "Yellow"
|
||||
radioSwatch6.inputId = "radioSwatch6"
|
||||
|
||||
var model7 = DefaultRadioSwatchModel()
|
||||
model7.primaryColor = .purple
|
||||
model7.text = "Puple"
|
||||
model7.inputId = "radioSwatch7"
|
||||
|
||||
var model8 = DefaultRadioSwatchModel()
|
||||
model8.primaryColor = .systemPink
|
||||
model8.text = "Pink"
|
||||
model8.inputId = "radioSwatch8"
|
||||
let radioSwatch7 = RadioSwatch()
|
||||
radioSwatch7.primaryColor = .purple
|
||||
radioSwatch7.text = "Puple"
|
||||
radioSwatch7.inputId = "radioSwatch7"
|
||||
|
||||
let radioSwatch8 = RadioSwatch()
|
||||
radioSwatch8.primaryColor = .systemPink
|
||||
radioSwatch8.text = "Pink"
|
||||
radioSwatch8.inputId = "radioSwatch8"
|
||||
|
||||
defaultModel.selectors = [model1, model2, model3, model4, model5, model6, model7, model8]
|
||||
set(with: defaultModel)
|
||||
|
||||
//update the model
|
||||
radioSwatchGroup
|
||||
.handlerPublisher()
|
||||
.sink { [weak self] updatedModel in
|
||||
self?.model = updatedModel
|
||||
self?.disabledSwitch.isOn = updatedModel.disabled
|
||||
}
|
||||
.store(in: &subscribers)
|
||||
radioSwatchGroup.selectorViews = [radioSwatch1, radioSwatch2, radioSwatch3, radioSwatch4, radioSwatch5, radioSwatch6, radioSwatch7, radioSwatch8]
|
||||
|
||||
radioSwatchGroup
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { group in
|
||||
print("Selected: \(group.selectedModelHandler?.text ?? "none")")
|
||||
print("Selected: \(group.selectedHandler?.text ?? "none")")
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//set UI values
|
||||
surfacePickerSelectorView.text = model.surface.rawValue
|
||||
disabledSwitch.isOn = model.disabled
|
||||
}
|
||||
|
||||
override func updateView(viewModel: ModelType) {
|
||||
print("\(Self.self) updateView(viewModel)")
|
||||
disabledSwitch.isOn = viewModel.disabled
|
||||
radioSwatchGroup.set(with: viewModel)
|
||||
surfacePickerSelectorView.text = radioSwatchGroup.surface.rawValue
|
||||
disabledSwitch.isOn = radioSwatchGroup.disabled
|
||||
}
|
||||
|
||||
//Picker
|
||||
|
||||
@ -10,15 +10,19 @@ import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
|
||||
class ToggleViewController: ModelScrollViewController<DefaultToggleModel> {
|
||||
class ToggleViewController: BaseViewController {
|
||||
|
||||
lazy var textSizePickerSelectorView = {
|
||||
TextSizePickerSelectorView(title: "Small",
|
||||
picker: self.picker)
|
||||
PickerSelectorView(title: "",
|
||||
picker: self.picker,
|
||||
items: ToggleTextSize.allCases)
|
||||
|
||||
}()
|
||||
|
||||
lazy var textPositionPickerSelectorView = {
|
||||
TextPositionPickerSelectorView(picker: self.picker)
|
||||
PickerSelectorView(title: "",
|
||||
picker: self.picker,
|
||||
items: ToggleTextPosition.allCases)
|
||||
}()
|
||||
|
||||
var disabledSwitch = UISwitch()
|
||||
@ -83,7 +87,7 @@ class ToggleViewController: ModelScrollViewController<DefaultToggleModel> {
|
||||
boldSwitch
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { [weak self] sender in
|
||||
self?.toggle.isBold = sender.isOn
|
||||
self?.toggle.textWeight = sender.isOn ? .bold : .regular
|
||||
}.store(in: &subscribers)
|
||||
|
||||
onTextField
|
||||
@ -99,15 +103,16 @@ class ToggleViewController: ModelScrollViewController<DefaultToggleModel> {
|
||||
}.store(in: &subscribers)
|
||||
|
||||
textFormStackView.isHidden = true
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = toggle.surface.rawValue
|
||||
textSizePickerSelectorView.text = toggle.textSize.rawValue
|
||||
textPositionPickerSelectorView.text = toggle.textPosition.rawValue
|
||||
onTextField.text = toggle.onText
|
||||
offTextField.text = toggle.offText
|
||||
}
|
||||
|
||||
override func updateView(viewModel: DefaultToggleModel) {
|
||||
print("\(Self.self) updateView(viewModel)")
|
||||
toggle.set(with: viewModel)
|
||||
}
|
||||
|
||||
//Picker
|
||||
|
||||
//Picker
|
||||
func setupPicker(){
|
||||
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
@ -116,7 +121,7 @@ class ToggleViewController: ModelScrollViewController<DefaultToggleModel> {
|
||||
}
|
||||
|
||||
textSizePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.toggle.fontSize = item
|
||||
self?.toggle.textSize = item
|
||||
}
|
||||
|
||||
textPositionPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
|
||||
Loading…
Reference in New Issue
Block a user