Merge branch 'develop' of https://gitlab.verizon.com/BPHV_MIPS/vds_ios_sample into vasavk/priceLockup
This commit is contained in:
commit
a4b99d1ecc
@ -32,6 +32,7 @@
|
||||
/* End PBXAggregateTarget section */
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
180636CB2C29B12B00C92D86 /* InputStepperViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 180636CA2C29B12B00C92D86 /* InputStepperViewController.swift */; };
|
||||
1808BEBE2BA4479500129230 /* CarouselScrollbarViewConttroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1808BEBD2BA4479500129230 /* CarouselScrollbarViewConttroller.swift */; };
|
||||
1832AC5B2BA1347B008AE476 /* BreadcrumbsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1832AC5A2BA1347B008AE476 /* BreadcrumbsViewController.swift */; };
|
||||
184023492C61E9E700A412C8 /* PriceLockupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 184023482C61E9E700A412C8 /* PriceLockupViewController.swift */; };
|
||||
@ -131,6 +132,7 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
180636CA2C29B12B00C92D86 /* InputStepperViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputStepperViewController.swift; sourceTree = "<group>"; };
|
||||
1808BEBD2BA4479500129230 /* CarouselScrollbarViewConttroller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselScrollbarViewConttroller.swift; sourceTree = "<group>"; };
|
||||
1832AC5A2BA1347B008AE476 /* BreadcrumbsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BreadcrumbsViewController.swift; sourceTree = "<group>"; };
|
||||
184023482C61E9E700A412C8 /* PriceLockupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceLockupViewController.swift; sourceTree = "<group>"; };
|
||||
@ -340,6 +342,7 @@
|
||||
EA1758452BC8893700A5C0D9 /* DatePickerViewController.swift */,
|
||||
186D13CC2BBA990800986B53 /* DropdownSelectViewController.swift */,
|
||||
EA985C00296CC21C00F2FF2E /* IconViewController.swift */,
|
||||
180636CA2C29B12B00C92D86 /* InputStepperViewController.swift */,
|
||||
EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */,
|
||||
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
|
||||
44604AD829CE1CF900E62B51 /* LineViewController.swift */,
|
||||
@ -537,6 +540,7 @@
|
||||
EAB2376C29E9E74900AABE9A /* TrailingTooltipLabelViewController.swift in Sources */,
|
||||
EAB1D2C928AAAA1D00DAE764 /* BaseViewController.swift in Sources */,
|
||||
EA1758462BC8893700A5C0D9 /* DatePickerViewController.swift in Sources */,
|
||||
180636CB2C29B12B00C92D86 /* InputStepperViewController.swift in Sources */,
|
||||
EAD062AD2A3B86950015965D /* BadgeIndicatorViewController.swift in Sources */,
|
||||
EA5E305C295111050082B959 /* TileletViewController.swift in Sources */,
|
||||
EAD062A32A3913920015965D /* DropShawdowViewController.swift in Sources */,
|
||||
|
||||
@ -60,7 +60,16 @@ extension Changeable {
|
||||
}
|
||||
}
|
||||
|
||||
extension Clickable {
|
||||
extension Clickable where Self: UIControl {
|
||||
func onClickActionPublisher(_ text: String, label: UILabel) {
|
||||
onClick = { _ in
|
||||
let handler = labelPublisherCompletionHandler()
|
||||
handler(text, label)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Clickable where Self: UIView {
|
||||
func onClickActionPublisher(_ text: String, label: UILabel) {
|
||||
onClick = { _ in
|
||||
let handler = labelPublisherCompletionHandler()
|
||||
|
||||
255
VDSSample/ViewControllers/InputStepperViewController.swift
Normal file
255
VDSSample/ViewControllers/InputStepperViewController.swift
Normal file
@ -0,0 +1,255 @@
|
||||
//
|
||||
// InputStepperViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Kanamarlapudi, Vasavi on 24/06/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDS
|
||||
import VDSCoreTokens
|
||||
import Combine
|
||||
|
||||
class InputStepperViewController: BaseViewController<InputStepper> {
|
||||
|
||||
var controlWidthTextField = TextField()
|
||||
var controlWidthPercentageTextField = TextField()
|
||||
var defaultValueField = NumericField()
|
||||
var maxValueTextField = NumericField()
|
||||
var minValueTextField = NumericField()
|
||||
var trailingTextField = TextField()
|
||||
|
||||
var widthTextField = NumericField()
|
||||
var widthPercentageTextField = NumericField()
|
||||
var disabledSwitch = Toggle()
|
||||
var readOnlySwitch = Toggle()
|
||||
var requiredSwitch = Toggle()
|
||||
var labelTextField = TextField()
|
||||
var showErrorSwitch = Toggle()
|
||||
var errorTextField = TextField()
|
||||
var helperTextField = TextField()
|
||||
var tooltipTitleTextField = TextField()
|
||||
var tooltipContentTextField = TextField()
|
||||
|
||||
lazy var helperTextPlacementPickerSelectorView = {
|
||||
PickerSelectorView(title: "", picker: self.picker, items: InputStepper.HelperTextPlacement.allCases)
|
||||
}()
|
||||
|
||||
lazy var sizePickerSelectorView = {
|
||||
PickerSelectorView(title: "", picker: self.picker, items: InputStepper.Size.allCases)
|
||||
}()
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Control Width", view: controlWidthTextField)
|
||||
addFormRow(label: "ControlWidth Percentage", view: controlWidthPercentageTextField)
|
||||
addFormRow(label: "Default Value", view: defaultValueField)
|
||||
addFormRow(label: "Max Value", view: maxValueTextField)
|
||||
addFormRow(label: "Min Value", view: minValueTextField)
|
||||
addFormRow(label: "Trailing Text", view: trailingTextField)
|
||||
addFormRow(label: "Size", view: sizePickerSelectorView)
|
||||
|
||||
addFormRow(label: "Width Value", view: widthTextField)
|
||||
addFormRow(label: "Width Percentage", view: widthPercentageTextField)
|
||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||
addFormRow(label: "Read Only", view: readOnlySwitch)
|
||||
addFormRow(label: "Required", view: requiredSwitch)
|
||||
addFormRow(label: "Label Text", view: labelTextField)
|
||||
addFormRow(label: "Error", view: showErrorSwitch)
|
||||
addFormRow(label: "Error Text", view: errorTextField)
|
||||
addFormRow(label: "Helper Text Placement", view: helperTextPlacementPickerSelectorView)
|
||||
addFormRow(label: "Helper Text", view: helperTextField)
|
||||
addFormRow(label: "Tooltip Title", view: tooltipTitleTextField)
|
||||
addFormRow(label: "Tooltip Content", view: tooltipContentTextField)
|
||||
|
||||
controlWidthTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
if let number {
|
||||
self?.component.controlWidth = .value(number.cgFloatValue)
|
||||
self?.controlWidthPercentageTextField.text = ""
|
||||
} else {
|
||||
self?.component.controlWidth = nil
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
|
||||
controlWidthPercentageTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
if let number {
|
||||
self?.component.controlWidth = .percentage(number.cgFloatValue)
|
||||
self?.controlWidthTextField.text = ""
|
||||
} else {
|
||||
self?.component.controlWidth = nil
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
|
||||
defaultValueField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
self?.component.defaultValue = number?.intValue ?? 0
|
||||
}.store(in: &subscribers)
|
||||
|
||||
maxValueTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
guard let number else { return }
|
||||
self?.component.maxValue = number.intValue
|
||||
}.store(in: &subscribers)
|
||||
|
||||
minValueTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
guard let number else { return }
|
||||
self?.component.minValue = number.intValue
|
||||
}.store(in: &subscribers)
|
||||
|
||||
trailingTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.trailingText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
|
||||
requiredSwitch.onChange = { [weak self] sender in
|
||||
self?.component.isRequired = sender.isOn
|
||||
}
|
||||
|
||||
showErrorSwitch.onChange = { [weak self] sender in
|
||||
guard let self else { return }
|
||||
self.component.showError = sender.isOn
|
||||
if self.component.showError != sender.isOn {
|
||||
self.showErrorSwitch.isOn = self.component.showError
|
||||
}
|
||||
}
|
||||
|
||||
disabledSwitch.onChange = { [weak self] sender in
|
||||
self?.component.isEnabled = !sender.isOn
|
||||
}
|
||||
|
||||
readOnlySwitch.onChange = { [weak self] sender in
|
||||
self?.component.isReadOnly = sender.isOn
|
||||
}
|
||||
|
||||
labelTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.labelText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
helperTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.helperText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
errorTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.errorText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
widthTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
if let number {
|
||||
self?.component.widthPercentage = nil
|
||||
self?.component.width = number.cgFloatValue
|
||||
self?.widthPercentageTextField.text = ""
|
||||
} else {
|
||||
self?.component.width = nil
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
|
||||
widthPercentageTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
if let number, number.intValue > 10 {
|
||||
self?.component.width = nil
|
||||
self?.component.widthPercentage = number.cgFloatValue
|
||||
self?.widthTextField.text = ""
|
||||
} else {
|
||||
self?.component.widthPercentage = nil
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
|
||||
tooltipTitleTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.updateTooltip()
|
||||
}.store(in: &subscribers)
|
||||
|
||||
tooltipContentTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.updateTooltip()
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
func updateTooltip() {
|
||||
let title = tooltipTitleTextField.text ?? ""
|
||||
let content = tooltipContentTextField.text ?? ""
|
||||
|
||||
component.tooltipModel = !title.isEmpty || !content.isEmpty ? .init(title: title,
|
||||
content: content) : nil
|
||||
}
|
||||
|
||||
//Picker
|
||||
func setupPicker(){
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.surface = item
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
}
|
||||
|
||||
helperTextPlacementPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.helperTextPlacement = item
|
||||
}
|
||||
|
||||
sizePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.size = item
|
||||
}
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
component.labelText = "Quantity"
|
||||
component.helperText = "Add up to max lines."
|
||||
component.errorText = "You must choose a number of lines before advancing to the next step."
|
||||
component.defaultValue = nil
|
||||
component.trailingText = ""
|
||||
component.onChange = { component in
|
||||
if let text = component.value {
|
||||
print("inputStepper Change: \(text)")
|
||||
} else {
|
||||
print("inputStepper Change: check code")
|
||||
}
|
||||
}
|
||||
|
||||
trailingTextField.text = component.trailingText
|
||||
controlWidthTextField.text = ""
|
||||
errorTextField.text = component.errorText
|
||||
helperTextField.text = component.helperText
|
||||
labelTextField.text = component.labelText
|
||||
if let defaultVal = component.defaultValue {
|
||||
defaultValueField.text = String(defaultVal)
|
||||
}
|
||||
minValueTextField.text = String(component.minValue)
|
||||
maxValueTextField.text = String(component.maxValue)
|
||||
component.size = .large
|
||||
sizePickerSelectorView.text = "large"
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
helperTextPlacementPickerSelectorView.text = component.helperTextPlacement.rawValue
|
||||
}
|
||||
}
|
||||
@ -84,6 +84,7 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
|
||||
MenuComponent(title: "DropdownSelect", completed: true, viewController: DropdownSelectViewController.self),
|
||||
MenuComponent(title: "Icon", completed: true, viewController: IconViewController.self),
|
||||
MenuComponent(title: "InputField", completed: true, viewController: InputFieldViewController.self),
|
||||
MenuComponent(title: "InputStepper", completed: true, viewController: InputStepperViewController.self),
|
||||
MenuComponent(title: "Label", completed: true, viewController: LabelViewController.self),
|
||||
MenuComponent(title: "Line", completed: true, viewController: LineViewController.self),
|
||||
MenuComponent(title: "Loader", completed: true, viewController: LoaderViewController.self),
|
||||
|
||||
@ -127,8 +127,9 @@ class TileContainerViewController: BaseViewController<TileContainer> {
|
||||
topLabel.text = "Do you want to Register?"
|
||||
|
||||
let topButton = Button()
|
||||
topButton.setTitle("Register", for: .normal)
|
||||
|
||||
topButton.text = "Register"
|
||||
topButton.onClick = { c in print("clicked \(c.text!)") }
|
||||
|
||||
///bottom
|
||||
let bottomView = View()
|
||||
bottomView.backgroundColor = .green
|
||||
@ -137,7 +138,8 @@ class TileContainerViewController: BaseViewController<TileContainer> {
|
||||
bottomLabel.text = "Forgot your info?"
|
||||
|
||||
let bottomButton = Button()
|
||||
bottomButton.setTitle("Forgot Password", for: .normal)
|
||||
bottomButton.text = "Forgot Password"
|
||||
bottomButton.onClick = { c in print("clicked \(c.text!)") }
|
||||
|
||||
mainView.addSubview(topView)
|
||||
mainView.addSubview(bottomView)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user