Merge branch 'feature/tilet' into 'develop'
added selectedItem See merge request BPHV_MIPS/vds_ios_sample!16
This commit is contained in:
commit
996c1f343d
@ -8,6 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import VDS
|
import VDS
|
||||||
|
import VDSFormControlsTokens
|
||||||
|
|
||||||
public class TextField: UITextField {
|
public class TextField: UITextField {
|
||||||
public var isNumeric: Bool = false
|
public var isNumeric: Bool = false
|
||||||
@ -30,14 +31,14 @@ public class TextField: UITextField {
|
|||||||
|
|
||||||
public override func textRect(forBounds bounds: CGRect) -> CGRect {
|
public override func textRect(forBounds bounds: CGRect) -> CGRect {
|
||||||
layer.borderColor = UIColor.black.cgColor
|
layer.borderColor = UIColor.black.cgColor
|
||||||
layer.borderWidth = 1
|
layer.borderWidth = VDSFormControls.widthBorder
|
||||||
let rect = super.textRect(forBounds: bounds)
|
let rect = super.textRect(forBounds: bounds)
|
||||||
return rect.inset(by: textPadding)
|
return rect.inset(by: textPadding)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func editingRect(forBounds bounds: CGRect) -> CGRect {
|
public override func editingRect(forBounds bounds: CGRect) -> CGRect {
|
||||||
layer.borderColor = UIColor.black.cgColor
|
layer.borderColor = UIColor.black.cgColor
|
||||||
layer.borderWidth = 1
|
layer.borderWidth = VDSFormControls.widthBorder
|
||||||
let rect = super.editingRect(forBounds: bounds)
|
let rect = super.editingRect(forBounds: bounds)
|
||||||
return rect.inset(by: textPadding)
|
return rect.inset(by: textPadding)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,10 @@ public class PickerSelectorView<EnumType: RawRepresentable>: UIStackView, Picker
|
|||||||
$0.typograpicalStyle = .BodyLarge
|
$0.typograpicalStyle = .BodyLarge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var selectedItem: EnumType {
|
||||||
|
return items[selectedIndex]
|
||||||
|
}
|
||||||
|
|
||||||
private var button = Button().with { instance in
|
private var button = Button().with { instance in
|
||||||
instance.size = .small
|
instance.size = .small
|
||||||
instance.use = .secondary
|
instance.use = .secondary
|
||||||
|
|||||||
@ -15,13 +15,13 @@ class TiletViewController: BaseViewController {
|
|||||||
lazy var titleTextStylePickerSelectorView = {
|
lazy var titleTextStylePickerSelectorView = {
|
||||||
PickerSelectorView(title: "",
|
PickerSelectorView(title: "",
|
||||||
picker: self.picker,
|
picker: self.picker,
|
||||||
items: TiletTitleTypographicalStyle.allCases.sorted{ $0.rawValue < $1.rawValue })
|
items: TiletTitleModel.TitleTypographicalStyle.allCases.sorted{ $0.rawValue < $1.rawValue })
|
||||||
}()
|
}()
|
||||||
|
|
||||||
lazy var otherTextStylePickerSelectorView = {
|
lazy var otherTextStylePickerSelectorView = {
|
||||||
PickerSelectorView(title: "",
|
PickerSelectorView(title: "",
|
||||||
picker: self.picker,
|
picker: self.picker,
|
||||||
items: TiletOtherTypographicalStyle.allCases.sorted{ $0.rawValue < $1.rawValue })
|
items: TiletSubTitleModel.SubTitleTypographicalStyle.allCases.sorted{ $0.rawValue < $1.rawValue })
|
||||||
}()
|
}()
|
||||||
|
|
||||||
lazy var subtitleColorPickerSelectorView = {
|
lazy var subtitleColorPickerSelectorView = {
|
||||||
@ -33,9 +33,12 @@ class TiletViewController: BaseViewController {
|
|||||||
var titleTextField = TextField()
|
var titleTextField = TextField()
|
||||||
var subTitleTextField = TextField()
|
var subTitleTextField = TextField()
|
||||||
var widthTextField = NumericField()
|
var widthTextField = NumericField()
|
||||||
|
var heightTextField = NumericField()
|
||||||
var textPercentageTextField = NumericField()
|
var textPercentageTextField = NumericField()
|
||||||
var textWidthTextField = NumericField()
|
var textWidthTextField = NumericField()
|
||||||
|
|
||||||
|
var showBadgeSwitch = Toggle()
|
||||||
|
var badgeTextField = TextField()
|
||||||
var tilet = Tilet()
|
var tilet = Tilet()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
@ -47,7 +50,7 @@ class TiletViewController: BaseViewController {
|
|||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func allTextFields() -> [TextField]? { [titleTextField, subTitleTextField, widthTextField, textWidthTextField, textPercentageTextField] }
|
override func allTextFields() -> [TextField]? { [titleTextField, subTitleTextField, widthTextField, heightTextField, textWidthTextField, textPercentageTextField, badgeTextField] }
|
||||||
|
|
||||||
func setupForm(){
|
func setupForm(){
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
@ -59,8 +62,11 @@ class TiletViewController: BaseViewController {
|
|||||||
addFormRow(label: "Subtitle Color", view: subtitleColorPickerSelectorView)
|
addFormRow(label: "Subtitle Color", view: subtitleColorPickerSelectorView)
|
||||||
addFormRow(label: "Subtitle Text", view: subTitleTextField)
|
addFormRow(label: "Subtitle Text", view: subTitleTextField)
|
||||||
addFormRow(label: "Width", view: widthTextField)
|
addFormRow(label: "Width", view: widthTextField)
|
||||||
|
addFormRow(label: "Height", view: heightTextField)
|
||||||
addFormRow(label: "Text Width", view: textWidthTextField)
|
addFormRow(label: "Text Width", view: textWidthTextField)
|
||||||
addFormRow(label: "Text Percentage", view: textPercentageTextField)
|
addFormRow(label: "Text Percentage", view: badgeTextField)
|
||||||
|
|
||||||
|
addFormRow(label: "Badge Text", view: badgeTextField)
|
||||||
|
|
||||||
widthTextField
|
widthTextField
|
||||||
.textPublisher
|
.textPublisher
|
||||||
@ -70,6 +76,16 @@ class TiletViewController: BaseViewController {
|
|||||||
}
|
}
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
|
heightTextField
|
||||||
|
.textPublisher
|
||||||
|
.sink { [weak self] text in
|
||||||
|
if let n = NumberFormatter().number(from: text) {
|
||||||
|
self?.tilet.height = CGFloat(truncating: n)
|
||||||
|
} else {
|
||||||
|
self?.tilet.height = nil
|
||||||
|
}
|
||||||
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
textWidthTextField
|
textWidthTextField
|
||||||
.textPublisher
|
.textPublisher
|
||||||
.sink { [weak self] text in
|
.sink { [weak self] text in
|
||||||
@ -96,32 +112,65 @@ class TiletViewController: BaseViewController {
|
|||||||
titleTextField
|
titleTextField
|
||||||
.textPublisher
|
.textPublisher
|
||||||
.sink { [weak self] text in
|
.sink { [weak self] text in
|
||||||
self?.tilet.titleText = text
|
self?.setTitleModel()
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
subTitleTextField
|
subTitleTextField
|
||||||
.textPublisher
|
.textPublisher
|
||||||
.sink { [weak self] text in
|
.sink { [weak self] text in
|
||||||
self?.tilet.subTitleText = text
|
self?.setSubTitleModel()
|
||||||
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
|
badgeTextField
|
||||||
|
.textPublisher
|
||||||
|
.sink { [weak self] text in
|
||||||
|
self?.setBadgeModel()
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupModel() {
|
func setupModel() {
|
||||||
|
let titleModel = TiletTitleModel(text: "Save $XX 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.width = 312
|
||||||
tilet.titleText = "Save $XX on your monthly bill."
|
tilet.titleModel = titleModel
|
||||||
tilet.subTitleText = "Enroll in Auto Pay & paper-free billing to save on your monthly bill."
|
tilet.subTitleModel = subTitleModel
|
||||||
|
|
||||||
//setup UI
|
//setup UI
|
||||||
surfacePickerSelectorView.text = tilet.surface.rawValue
|
surfacePickerSelectorView.text = tilet.surface.rawValue
|
||||||
otherTextStylePickerSelectorView.text = tilet.otherTypograpicalStyle.rawValue
|
otherTextStylePickerSelectorView.text = subTitleModel.typographicalStyle.rawValue
|
||||||
titleTextStylePickerSelectorView.text = tilet.titleTypograpicalStyle.rawValue
|
titleTextStylePickerSelectorView.text = titleModel.typographicalStyle.rawValue
|
||||||
subtitleColorPickerSelectorView.text = tilet.subTitleColor.rawValue
|
subtitleColorPickerSelectorView.text = subTitleModel.textColor.rawValue
|
||||||
titleTextField.text = tilet.titleText
|
titleTextField.text = titleModel.text
|
||||||
subTitleTextField.text = tilet.subTitleText
|
subTitleTextField.text = subTitleModel.text
|
||||||
widthTextField.text = "\(tilet.width)"
|
widthTextField.text = "\(tilet.width)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sub models
|
||||||
|
func setBadgeModel() {
|
||||||
|
if let text = badgeTextField.text, !text.isEmpty {
|
||||||
|
tilet.badgeModel = TiletBadgeModel(text: text)
|
||||||
|
} else {
|
||||||
|
tilet.badgeModel = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTitleModel() {
|
||||||
|
if let text = titleTextField.text, !text.isEmpty {
|
||||||
|
tilet.titleModel = TiletTitleModel(text: text, typographicalStyle: titleTextStylePickerSelectorView.selectedItem)
|
||||||
|
} else {
|
||||||
|
tilet.titleModel = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setSubTitleModel() {
|
||||||
|
if let text = subTitleTextField.text, !text.isEmpty {
|
||||||
|
tilet.subTitleModel = TiletSubTitleModel(text: text, typographicalStyle: otherTextStylePickerSelectorView.selectedItem)
|
||||||
|
} else {
|
||||||
|
tilet.subTitleModel = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Picker
|
//Picker
|
||||||
func setupPicker(){
|
func setupPicker(){
|
||||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
@ -130,15 +179,15 @@ class TiletViewController: BaseViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
titleTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
titleTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
self?.tilet.titleTypograpicalStyle = item
|
self?.setTitleModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
otherTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
otherTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
self?.tilet.otherTypograpicalStyle = item
|
self?.setSubTitleModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
subtitleColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
subtitleColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
self?.tilet.subTitleColor = item
|
self?.setSubTitleModel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,36 +69,64 @@ class TitleLockupViewController: BaseViewController {
|
|||||||
eyebrowTextField
|
eyebrowTextField
|
||||||
.textPublisher
|
.textPublisher
|
||||||
.sink { [weak self] text in
|
.sink { [weak self] text in
|
||||||
self?.titleLockup.eyebrowText = text
|
self?.setEyebrowModel()
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
titleTextField
|
titleTextField
|
||||||
.textPublisher
|
.textPublisher
|
||||||
.sink { [weak self] text in
|
.sink { [weak self] text in
|
||||||
self?.titleLockup.titleText = text
|
self?.setTitleModel()
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
subTitleTextField
|
subTitleTextField
|
||||||
.textPublisher
|
.textPublisher
|
||||||
.sink { [weak self] text in
|
.sink { [weak self] text in
|
||||||
self?.titleLockup.subTitleText = text
|
self?.setSubTitleModel()
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupModel() {
|
func setupModel() {
|
||||||
titleLockup.eyebrowText = "Today only."
|
let eyebrowModel = TitleLockupEyebrowModel(text: "Today only.")
|
||||||
titleLockup.titleText = "Get more of our best"
|
let titleModel = TitleLockupTitleModel(text: "Get more of our best")
|
||||||
titleLockup.subTitleText = "Get both of our best and pay less. Pair 5G Home Internet with Verizon mobile to save every month."
|
let subTitleModel = TitleLockupSubTitleModel(text: "Get both of our best and pay less. Pair 5G Home Internet with Verizon mobile to save every month.")
|
||||||
|
|
||||||
|
titleLockup.eyebrowModel = eyebrowModel
|
||||||
|
titleLockup.titleModel = titleModel
|
||||||
|
titleLockup.subTitleModel = subTitleModel
|
||||||
|
|
||||||
//setup UI
|
//setup UI
|
||||||
surfacePickerSelectorView.text = titleLockup.surface.rawValue
|
surfacePickerSelectorView.text = titleLockup.surface.rawValue
|
||||||
textPositionPickerSelectorView.text = titleLockup.textPosition.rawValue
|
textPositionPickerSelectorView.text = titleLockup.textPosition.rawValue
|
||||||
otherTextStylePickerSelectorView.text = titleLockup.otherTypograpicalStyle.rawValue
|
otherTextStylePickerSelectorView.text = titleLockup.otherTypograpicalStyle.rawValue
|
||||||
titleTextStylePickerSelectorView.text = titleLockup.titleTypograpicalStyle.rawValue
|
titleTextStylePickerSelectorView.text = titleModel.typographicalStyle.rawValue
|
||||||
subtitleColorPickerSelectorView.text = titleLockup.subTitleColor.rawValue
|
subtitleColorPickerSelectorView.text = subTitleModel.textColor.rawValue
|
||||||
eyebrowTextField.text = titleLockup.eyebrowText
|
eyebrowTextField.text = eyebrowModel.text
|
||||||
titleTextField.text = titleLockup.titleText
|
titleTextField.text = titleModel.text
|
||||||
subTitleTextField.text = titleLockup.subTitleText
|
subTitleTextField.text = subTitleModel.text
|
||||||
|
}
|
||||||
|
|
||||||
|
func setEyebrowModel() {
|
||||||
|
if let text = eyebrowTextField.text, !text.isEmpty {
|
||||||
|
titleLockup.eyebrowModel = TitleLockupEyebrowModel(text: text)
|
||||||
|
} else {
|
||||||
|
titleLockup.eyebrowModel = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTitleModel() {
|
||||||
|
if let text = titleTextField.text, !text.isEmpty {
|
||||||
|
titleLockup.titleModel = TitleLockupTitleModel(text: text, typographicalStyle: titleTextStylePickerSelectorView.selectedItem)
|
||||||
|
} else {
|
||||||
|
titleLockup.titleModel = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setSubTitleModel() {
|
||||||
|
if let text = subTitleTextField.text, !text.isEmpty {
|
||||||
|
titleLockup.subTitleModel = TitleLockupSubTitleModel(text: text, textColor: subtitleColorPickerSelectorView.selectedItem)
|
||||||
|
} else {
|
||||||
|
titleLockup.subTitleModel = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Picker
|
//Picker
|
||||||
@ -113,7 +141,7 @@ class TitleLockupViewController: BaseViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
titleTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
titleTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
self?.titleLockup.titleTypograpicalStyle = item
|
self?.setTitleModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
otherTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
otherTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
@ -121,7 +149,7 @@ class TitleLockupViewController: BaseViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subtitleColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
subtitleColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
self?.titleLockup.subTitleColor = item
|
self?.setSubTitleModel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user