refactored code for monarch
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
558d19f315
commit
5d94f076dc
@ -43,7 +43,7 @@ public class FormSection: UIStackView {
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
open func addFormRow(label: String, view: UIView) -> UIView {
|
||||
open func addFormRow(label: String, tooltip: Tooltip.TooltipModel? = nil, view: UIView) -> UIView {
|
||||
let formRow = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .fill
|
||||
@ -56,6 +56,10 @@ public class FormSection: UIStackView {
|
||||
$0.tag = 1
|
||||
$0.text = label
|
||||
$0.textStyle = .bodyLarge
|
||||
$0.numberOfLines = 0
|
||||
if let tooltip {
|
||||
$0.addTooltip(tooltip)
|
||||
}
|
||||
}
|
||||
|
||||
formRow.addArrangedSubview(label)
|
||||
@ -333,10 +337,10 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable ,
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
open func addFormRow(label: String, view: UIView) -> UIView {
|
||||
return formStackView.addFormRow(label: label, view: view)
|
||||
open func addFormRow(label: String, tooltip: Tooltip.TooltipModel? = nil, view: UIView) -> UIView {
|
||||
return formStackView.addFormRow(label: label,tooltip: tooltip, view: view)
|
||||
}
|
||||
|
||||
|
||||
var activeTextField: UITextField?
|
||||
|
||||
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
|
||||
|
||||
@ -49,6 +49,19 @@ class InputFieldViewController: BaseViewController<InputField> {
|
||||
$0.isHidden = true
|
||||
}
|
||||
|
||||
//date
|
||||
lazy var dateFormatPickerSelectorView = {
|
||||
PickerSelectorView(title: "",
|
||||
picker: self.picker,
|
||||
items: InputField.DateFormat.allCases)
|
||||
}()
|
||||
|
||||
lazy var dateSection = FormSection().with {
|
||||
$0.title = "Date Settings"
|
||||
$0.addFormRow(label: "Date Format", view: dateFormatPickerSelectorView)
|
||||
$0.isHidden = true
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
@ -74,7 +87,8 @@ class InputFieldViewController: BaseViewController<InputField> {
|
||||
addFormRow(label: "Field Type", view: inputTypePickerSelectorView)
|
||||
|
||||
append(section: passwordSection)
|
||||
|
||||
append(section: dateSection)
|
||||
|
||||
requiredSwitch.onChange = { [weak self] sender in
|
||||
self?.component.isRequired = sender.isOn
|
||||
}
|
||||
@ -201,6 +215,11 @@ class InputFieldViewController: BaseViewController<InputField> {
|
||||
self?.component.fieldType = item
|
||||
self?.updateFormSections()
|
||||
}
|
||||
|
||||
dateFormatPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.dateFormat = item
|
||||
self?.updateFormSections()
|
||||
}
|
||||
}
|
||||
|
||||
func updateTooltip() {
|
||||
@ -212,8 +231,7 @@ class InputFieldViewController: BaseViewController<InputField> {
|
||||
}
|
||||
|
||||
func updateFormSections() {
|
||||
passwordSection.isHidden = true
|
||||
|
||||
[passwordSection, dateSection].forEach { $0.isHidden = true }
|
||||
switch component.fieldType {
|
||||
case .text:
|
||||
break
|
||||
@ -234,7 +252,7 @@ class InputFieldViewController: BaseViewController<InputField> {
|
||||
break
|
||||
|
||||
case .date:
|
||||
break
|
||||
dateSection.isHidden = false
|
||||
|
||||
case .securityCode:
|
||||
break
|
||||
|
||||
@ -308,8 +308,8 @@ extension TileContainerViewController: UIColorPickerViewControllerDelegate {
|
||||
}
|
||||
|
||||
func updateGradientColors(){
|
||||
if let selectedGradient1Color = gradientColorView1.selectedColor?.hexString,
|
||||
let selectedGradient2Color = gradientColorView2.selectedColor?.hexString{
|
||||
if let selectedGradient1Color = gradientColorView1.selectedColor,
|
||||
let selectedGradient2Color = gradientColorView2.selectedColor{
|
||||
component.backgroundEffect = .gradient(selectedGradient1Color, selectedGradient2Color)
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,38 +223,8 @@ class TileletViewController: BaseViewController<Tilelet> {
|
||||
addFormRow(label: "Text Alignment", view: textAlignmentPickerSelectorView)
|
||||
addFormRow(label: "Text Width", view: textWidthTextField)
|
||||
addFormRow(label: "Text Percentage", view: textPercentageTextField)
|
||||
addFormRow(label: "Text Position(Minimum height is configurable.)", view: textPositionPickerSelectorView)
|
||||
addFormRow(label: "Description Icon", view: showDescriptionIconSwitch)
|
||||
addFormRow(label: "Directional Icon", view: showDirectionalIconSwitch)
|
||||
|
||||
addFormRow(label: "Badge Text", view: badgeTextField)
|
||||
addFormRow(label: "Badge Fill Color", view: badgeFillColorPickerSelectorView)
|
||||
addFormRow(label: "Badge Number of Lines", view: badgeNumberOfLinesPickerSelectorView)
|
||||
addFormRow(label: "Badge Max Width", view: maxWidthTextField)
|
||||
|
||||
addFormRow(label: "Eyebrow/Subtitle Style", view: otherStandardStylePickerSelectorView)
|
||||
addFormRow(label: "Eyebrow is Bold", view: eyebrowIsBold)
|
||||
addFormRow(label: "Eyebrow Text", view: eyebrowTextField)
|
||||
addFormRow(label: "Eyebrow Color", view: eyebrowColorPickerSelectorView)
|
||||
eyebrowColorsFormStackView.addFormRow(label: "Light", view: eyebrowLightColorView)
|
||||
eyebrowColorsFormStackView.addFormRow(label: "Dark", view: eyebrowDarkColorView)
|
||||
append(section: eyebrowColorsFormStackView)
|
||||
|
||||
addFormRow(label: "Title Style", view: titleStandardStylePickerSelectorView)
|
||||
addFormRow(label: "Title is Bold", view: titleIsBold)
|
||||
addFormRow(label: "Title Text", view: titleTextField)
|
||||
addFormRow(label: "Title Color", view: titleColorPickerSelectorView)
|
||||
titleColorsFormStackView.addFormRow(label: "Light", view: titleLightColorView)
|
||||
titleColorsFormStackView.addFormRow(label: "Dark", view: titleDarkColorView)
|
||||
append(section: titleColorsFormStackView)
|
||||
|
||||
addFormRow(label: "Subtitle Text", view: subTitleTextField)
|
||||
addFormRow(label: "Subtitle Color", view: subtitleColorPickerSelectorView)
|
||||
subtitleColorsFormStackView.addFormRow(label: "Light", view: subtitleLightColorView)
|
||||
subtitleColorsFormStackView.addFormRow(label: "Dark", view: subtitleDarkColorView)
|
||||
append(section: subtitleColorsFormStackView)
|
||||
|
||||
addFormRow(label: "Background Color", view: backgroundColorPickerSelectorView)
|
||||
addFormRow(label: "Text Position", tooltip: .init(title:"Text Position", content: "Minimum height is configurable"), view: textPositionPickerSelectorView)
|
||||
addFormRow(label: "Background Color", tooltip: .init(title:"Background Color", content: "This color takes precedence over surface and will set all children's surface property to this value."), view: backgroundColorPickerSelectorView)
|
||||
addFormRow(label: "Background Image", view: showBackgroundImageSwitch)
|
||||
addFormRow(label: "Show Drop Shadow", view: showDropShadowSwitch)
|
||||
addFormRow(label: "Image Fallback Color", view: imageFallbackColorPickerSelectorView)
|
||||
@ -264,6 +234,52 @@ class TileletViewController: BaseViewController<Tilelet> {
|
||||
gradientColorsFormStackView.addFormRow(label: "Gradient Color2", view: gradientColorView2)
|
||||
append(section: gradientColorsFormStackView)
|
||||
|
||||
append(section: .init().with({
|
||||
$0.title = "Badge"
|
||||
$0.addFormRow(label: "Text", view: badgeTextField)
|
||||
$0.addFormRow(label: "Fill Color", view: badgeFillColorPickerSelectorView)
|
||||
$0.addFormRow(label: "Number of Lines", view: badgeNumberOfLinesPickerSelectorView)
|
||||
$0.addFormRow(label: "Max Width", view: maxWidthTextField)
|
||||
}))
|
||||
|
||||
append(section: .init().with({
|
||||
$0.title = "Eyebrow"
|
||||
$0.addFormRow(label: "Text Style", tooltip: .init(title: "Text Style", content: "Eyebrow and Subtitle will share the same textStyle."), view: otherStandardStylePickerSelectorView)
|
||||
$0.addFormRow(label: "is Bold", view: eyebrowIsBold)
|
||||
$0.addFormRow(label: "Text", view: eyebrowTextField)
|
||||
$0.addFormRow(label: "Color", view: eyebrowColorPickerSelectorView)
|
||||
}))
|
||||
|
||||
eyebrowColorsFormStackView.addFormRow(label: "Light", view: eyebrowLightColorView)
|
||||
eyebrowColorsFormStackView.addFormRow(label: "Dark", view: eyebrowDarkColorView)
|
||||
append(section: eyebrowColorsFormStackView)
|
||||
|
||||
append(section: .init().with({
|
||||
$0.title = "Title"
|
||||
$0.addFormRow(label: "Text Style", view: titleStandardStylePickerSelectorView)
|
||||
$0.addFormRow(label: "is Bold", view: titleIsBold)
|
||||
$0.addFormRow(label: "Text", view: titleTextField)
|
||||
$0.addFormRow(label: "Color", view: titleColorPickerSelectorView)
|
||||
}))
|
||||
titleColorsFormStackView.addFormRow(label: "Light", view: titleLightColorView)
|
||||
titleColorsFormStackView.addFormRow(label: "Dark", view: titleDarkColorView)
|
||||
append(section: titleColorsFormStackView)
|
||||
|
||||
append(section: .init().with({
|
||||
$0.title = "Subtitle"
|
||||
$0.addFormRow(label: "Text", view: subTitleTextField)
|
||||
$0.addFormRow(label: "Color", view: subtitleColorPickerSelectorView)
|
||||
}))
|
||||
subtitleColorsFormStackView.addFormRow(label: "Light", view: subtitleLightColorView)
|
||||
subtitleColorsFormStackView.addFormRow(label: "Dark", view: subtitleDarkColorView)
|
||||
append(section: subtitleColorsFormStackView)
|
||||
|
||||
append(section: .init().with({
|
||||
$0.title = "Icons"
|
||||
$0.addFormRow(label: "Description", view: showDescriptionIconSwitch)
|
||||
$0.addFormRow(label: "Directional", view: showDirectionalIconSwitch)
|
||||
}))
|
||||
|
||||
clickableSwitch.onChange = { [weak self] sender in
|
||||
guard let self else { return }
|
||||
if sender.isOn {
|
||||
@ -435,11 +451,11 @@ class TileletViewController: BaseViewController<Tilelet> {
|
||||
case .primary:
|
||||
textColor = .primary
|
||||
case .custom:
|
||||
if let light = titleLightColorView.selectedColor?.hexString {
|
||||
let dark = titleDarkColorView.selectedColor?.hexString ?? light
|
||||
if let light = titleLightColorView.selectedColor {
|
||||
let dark = titleDarkColorView.selectedColor ?? light
|
||||
textColor = .custom(light, dark)
|
||||
} else {
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight.hexString!, VDSColor.elementsPrimaryOndark.hexString!)
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
|
||||
}
|
||||
}
|
||||
|
||||
@ -458,11 +474,11 @@ class TileletViewController: BaseViewController<Tilelet> {
|
||||
case .secondary:
|
||||
textColor = .secondary
|
||||
case .custom:
|
||||
if let light = subtitleLightColorView.selectedColor?.hexString {
|
||||
let dark = subtitleDarkColorView.selectedColor?.hexString ?? light
|
||||
if let light = subtitleLightColorView.selectedColor {
|
||||
let dark = subtitleDarkColorView.selectedColor ?? light
|
||||
textColor = .custom(light, dark)
|
||||
} else {
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight.hexString!, VDSColor.elementsPrimaryOndark.hexString!)
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
|
||||
}
|
||||
}
|
||||
|
||||
@ -481,11 +497,11 @@ class TileletViewController: BaseViewController<Tilelet> {
|
||||
case .secondary:
|
||||
textColor = .secondary
|
||||
case .custom:
|
||||
if let light = eyebrowLightColorView.selectedColor?.hexString {
|
||||
let dark = eyebrowDarkColorView.selectedColor?.hexString ?? light
|
||||
if let light = eyebrowLightColorView.selectedColor {
|
||||
let dark = eyebrowDarkColorView.selectedColor ?? light
|
||||
textColor = .custom(light, dark)
|
||||
} else {
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight.hexString!, VDSColor.elementsPrimaryOndark.hexString!)
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
|
||||
}
|
||||
}
|
||||
|
||||
@ -695,8 +711,8 @@ extension TileletViewController: UIColorPickerViewControllerDelegate {
|
||||
}
|
||||
|
||||
func updateGradientColors(){
|
||||
if let selectedGradient1Color = gradientColorView1.selectedColor?.hexString,
|
||||
let selectedGradient2Color = gradientColorView2.selectedColor?.hexString{
|
||||
if let selectedGradient1Color = gradientColorView1.selectedColor,
|
||||
let selectedGradient2Color = gradientColorView2.selectedColor{
|
||||
component.backgroundEffect = .gradient(selectedGradient1Color, selectedGradient2Color)
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,11 +222,11 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
|
||||
case .primary:
|
||||
textColor = .primary
|
||||
case .custom:
|
||||
if let light = titleLightColorView.selectedColor?.hexString {
|
||||
let dark = titleDarkColorView.selectedColor?.hexString ?? light
|
||||
if let light = titleLightColorView.selectedColor {
|
||||
let dark = titleDarkColorView.selectedColor ?? light
|
||||
textColor = .custom(light, dark)
|
||||
} else {
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight.hexString!, VDSColor.elementsPrimaryOndark.hexString!)
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,11 +256,11 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
|
||||
case .secondary:
|
||||
textColor = .secondary
|
||||
case .custom:
|
||||
if let light = subtitleLightColorView.selectedColor?.hexString {
|
||||
let dark = subtitleDarkColorView.selectedColor?.hexString ?? light
|
||||
if let light = subtitleLightColorView.selectedColor {
|
||||
let dark = subtitleDarkColorView.selectedColor ?? light
|
||||
textColor = .custom(light, dark)
|
||||
} else {
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight.hexString!, VDSColor.elementsPrimaryOndark.hexString!)
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
|
||||
}
|
||||
}
|
||||
component.subTitleModel = TitleLockup.SubTitleModel(text: text, otherStandardStyle: style, textColor: textColor)
|
||||
@ -277,11 +277,11 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
|
||||
case .secondary:
|
||||
textColor = .secondary
|
||||
case .custom:
|
||||
if let light = eyebrowLightColorView.selectedColor?.hexString {
|
||||
let dark = eyebrowDarkColorView.selectedColor?.hexString ?? light
|
||||
if let light = eyebrowLightColorView.selectedColor {
|
||||
let dark = eyebrowDarkColorView.selectedColor ?? light
|
||||
textColor = .custom(light, dark)
|
||||
} else {
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight.hexString!, VDSColor.elementsPrimaryOndark.hexString!)
|
||||
textColor = .custom(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
|
||||
} }
|
||||
component.eyebrowModel = TitleLockup.EyebrowModel(text: text, textColor: textColor, isBold: eyebrowIsBold.isOn, standardStyle: style)
|
||||
debug(type: "EyeBrow", textStyle: eyebrowIsBold.isOn ? style.value.bold : style.value.regular)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user