Merge branch 'develop' of https://gitlab.verizon.com/BPHV_MIPS/vds_ios_sample into vasavk/modal
This commit is contained in:
commit
62e0a6387b
@ -110,11 +110,8 @@ class BadgeViewController: BaseViewController<Badge> {
|
|||||||
|
|
||||||
extension BadgeViewController: ComponentSampleable {
|
extension BadgeViewController: ComponentSampleable {
|
||||||
static func makeSample() -> ComponentSample {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let c = Self()
|
||||||
component.fillColor = .red
|
c.setupModel()
|
||||||
component.text = "Terms and conditions"
|
return ComponentSample(component: c.component, trailingPinningType: .lessThanOrEqual)
|
||||||
component.maxWidth = 70
|
|
||||||
component.numberOfLines = 3
|
|
||||||
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -334,15 +334,33 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable ,
|
|||||||
viewController.didMove(toParent: self)
|
viewController.didMove(toParent: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var componentTrailingEqualConstraint: NSLayoutConstraint?
|
||||||
|
var componentTrailingLessThanEqualConstraint: NSLayoutConstraint?
|
||||||
open func addContentTopView(view: UIView, edgeSpacing: CGFloat = 16.0, pinTrailing: Bool = true) {
|
open func addContentTopView(view: UIView, edgeSpacing: CGFloat = 16.0, pinTrailing: Bool = true) {
|
||||||
view.translatesAutoresizingMaskIntoConstraints = false
|
view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
contentTopView.addSubview(view)
|
||||||
|
componentTrailingEqualConstraint = view.pinTrailing(anchor: contentTopView.trailingAnchor, constant: edgeSpacing)?.deactivate()
|
||||||
|
componentTrailingLessThanEqualConstraint = view.pinTrailingLessThanOrEqualTo(anchor: contentTopView.trailingAnchor, constant: edgeSpacing)?.deactivate()
|
||||||
|
view
|
||||||
|
.pinTop(edgeSpacing)
|
||||||
|
.pinLeading(edgeSpacing)
|
||||||
|
.pinBottom(edgeSpacing)
|
||||||
|
|
||||||
if pinTrailing {
|
if pinTrailing {
|
||||||
contentTopView.addSubview(view)
|
componentTrailingEqualConstraint?.activate()
|
||||||
view.pinToSuperView(.uniform(edgeSpacing))
|
|
||||||
} else {
|
} else {
|
||||||
let wrapper = UIView.makeWrapper(for: view)
|
componentTrailingLessThanEqualConstraint?.activate()
|
||||||
contentTopView.addSubview(wrapper)
|
}
|
||||||
wrapper.pinToSuperView(.uniform(edgeSpacing))
|
}
|
||||||
|
|
||||||
|
open func updateComponentConstraint(pinTrailing: Bool = true) {
|
||||||
|
componentTrailingEqualConstraint?.deactivate()
|
||||||
|
componentTrailingLessThanEqualConstraint?.deactivate()
|
||||||
|
|
||||||
|
if pinTrailing {
|
||||||
|
componentTrailingEqualConstraint?.activate()
|
||||||
|
} else {
|
||||||
|
componentTrailingLessThanEqualConstraint?.activate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,13 +47,6 @@ class CalendarViewController: BaseViewController<CalendarBase> {
|
|||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
addContentTopView(view: component)
|
addContentTopView(view: component)
|
||||||
component.minDate = Date().startOfMonth
|
|
||||||
component.maxDate = Date().endOfMonth
|
|
||||||
component.onChange = { [weak self] control in
|
|
||||||
self?.label.text = DateFormatter.localizedString(from: control.selectedDate, dateStyle: .short, timeStyle: .none)
|
|
||||||
}
|
|
||||||
minDatePicker.date = component.minDate
|
|
||||||
maxDatePicker.date = component.maxDate
|
|
||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
@ -206,6 +199,13 @@ class CalendarViewController: BaseViewController<CalendarBase> {
|
|||||||
func setupModel() {
|
func setupModel() {
|
||||||
let calendar = Calendar.current
|
let calendar = Calendar.current
|
||||||
let indicatorDate = calendar.startOfDay(for: calendar.date(byAdding: .day, value: 1, to: Date())!)
|
let indicatorDate = calendar.startOfDay(for: calendar.date(byAdding: .day, value: 1, to: Date())!)
|
||||||
|
component.minDate = Date().startOfMonth
|
||||||
|
component.maxDate = Date().endOfMonth
|
||||||
|
component.onChange = { [weak self] control in
|
||||||
|
self?.label.text = DateFormatter.localizedString(from: control.selectedDate, dateStyle: .short, timeStyle: .none)
|
||||||
|
}
|
||||||
|
minDatePicker.date = component.minDate
|
||||||
|
maxDatePicker.date = component.maxDate
|
||||||
component.indicators = indicators
|
component.indicators = indicators
|
||||||
legendOneField.text = "Due Date"
|
legendOneField.text = "Due Date"
|
||||||
legendTwoField.text = "Auto Pay"
|
legendTwoField.text = "Auto Pay"
|
||||||
@ -303,3 +303,11 @@ class CalendarViewController: BaseViewController<CalendarBase> {
|
|||||||
return day
|
return day
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension CalendarViewController: ComponentSampleable {
|
||||||
|
static func makeSample() -> ComponentSample {
|
||||||
|
let c = Self()
|
||||||
|
c.viewDidLoad()
|
||||||
|
return ComponentSample(component: c.component, edgeInset: .init(top: 16, left: 0, bottom: 16, right: 0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -219,3 +219,11 @@ class CarouselViewController: BaseViewController<Carousel> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension CarouselViewController: ComponentSampleable {
|
||||||
|
static func makeSample() -> ComponentSample {
|
||||||
|
let c = Self()
|
||||||
|
c.setupModel()
|
||||||
|
return ComponentSample(component: c.component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -138,6 +138,6 @@ extension CheckboxGroupViewController: ComponentSampleable {
|
|||||||
|
|
||||||
component.selectorModels = [checkbox1, checkbox2]
|
component.selectorModels = [checkbox1, checkbox2]
|
||||||
|
|
||||||
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,6 +110,6 @@ extension CheckboxItemViewController: ComponentSampleable {
|
|||||||
component.childText = "I agree to Verizon's terms and conditions click here"
|
component.childText = "I agree to Verizon's terms and conditions click here"
|
||||||
component.errorText = "Error Text"
|
component.errorText = "Error Text"
|
||||||
|
|
||||||
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -171,6 +171,7 @@ class DatePickerViewController: BaseViewController<DatePicker> {
|
|||||||
widthTextField
|
widthTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
self?.component.width = number?.cgFloatValue
|
self?.component.width = number?.cgFloatValue
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
@ -479,3 +480,12 @@ extension DatePickerViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension DatePickerViewController: ComponentSampleable {
|
||||||
|
static func makeSample() -> ComponentSample {
|
||||||
|
let c = Self()
|
||||||
|
c.setupModel()
|
||||||
|
c.setupCalendar()
|
||||||
|
return ComponentSample(component: c.component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -131,6 +131,7 @@ class DropdownSelectViewController: BaseViewController<DropdownSelect> {
|
|||||||
widthTextField
|
widthTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
self?.component.width = number?.cgFloatValue
|
self?.component.width = number?.cgFloatValue
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class FootnoteGroupViewController: BaseViewController<FootnoteGroup> {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
addContentTopView(view: component, pinTrailing: false)
|
addContentTopView(view: component)
|
||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
@ -31,6 +31,7 @@ class FootnoteGroupViewController: BaseViewController<FootnoteGroup> {
|
|||||||
widthTextField
|
widthTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
if let number {
|
if let number {
|
||||||
self?.component.width = .value(number.cgFloatValue)
|
self?.component.width = .value(number.cgFloatValue)
|
||||||
self?.percentageTextField.text = ""
|
self?.percentageTextField.text = ""
|
||||||
@ -42,6 +43,7 @@ class FootnoteGroupViewController: BaseViewController<FootnoteGroup> {
|
|||||||
percentageTextField
|
percentageTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
if let number, number.intValue > 9 {
|
if let number, number.intValue > 9 {
|
||||||
self?.component.width = .percentage(number.cgFloatValue)
|
self?.component.width = .percentage(number.cgFloatValue)
|
||||||
self?.widthTextField.text = ""
|
self?.widthTextField.text = ""
|
||||||
@ -67,3 +69,11 @@ class FootnoteGroupViewController: BaseViewController<FootnoteGroup> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension FootnoteGroupViewController: ComponentSampleable {
|
||||||
|
static func makeSample() -> ComponentSample {
|
||||||
|
let c = Self()
|
||||||
|
c.setupModel()
|
||||||
|
return ComponentSample(component: c.component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ class FootnoteItemViewController: BaseViewController<FootnoteItem> {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
addContentTopView(view: component, pinTrailing: false)
|
addContentTopView(view: component)
|
||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
@ -92,6 +92,7 @@ class FootnoteItemViewController: BaseViewController<FootnoteItem> {
|
|||||||
widthTextField
|
widthTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
if let number {
|
if let number {
|
||||||
self?.component.width = .value(number.cgFloatValue)
|
self?.component.width = .value(number.cgFloatValue)
|
||||||
self?.percentageTextField.text = ""
|
self?.percentageTextField.text = ""
|
||||||
@ -103,6 +104,7 @@ class FootnoteItemViewController: BaseViewController<FootnoteItem> {
|
|||||||
percentageTextField
|
percentageTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
if let number, number.intValue > 9 {
|
if let number, number.intValue > 9 {
|
||||||
self?.component.width = .percentage(number.cgFloatValue)
|
self?.component.width = .percentage(number.cgFloatValue)
|
||||||
self?.widthTextField.text = ""
|
self?.widthTextField.text = ""
|
||||||
@ -164,3 +166,11 @@ class FootnoteItemViewController: BaseViewController<FootnoteItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension FootnoteItemViewController: ComponentSampleable {
|
||||||
|
static func makeSample() -> ComponentSample {
|
||||||
|
let c = Self()
|
||||||
|
c.setupModel()
|
||||||
|
return ComponentSample(component: c.component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -181,6 +181,7 @@ class InputFieldViewController: BaseViewController<InputField> {
|
|||||||
widthTextField
|
widthTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
self?.component.width = number?.cgFloatValue
|
self?.component.width = number?.cgFloatValue
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
@ -329,14 +330,8 @@ class InputFieldViewController: BaseViewController<InputField> {
|
|||||||
|
|
||||||
extension InputFieldViewController: ComponentSampleable {
|
extension InputFieldViewController: ComponentSampleable {
|
||||||
static func makeSample() -> ComponentSample {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let c = Self()
|
||||||
component.fieldType = .text
|
c.setupModel()
|
||||||
component.width = 328
|
return ComponentSample(component: c.component)
|
||||||
component.labelText = "Street Address"
|
|
||||||
component.helperText = "For example: 123 Verizon St"
|
|
||||||
component.errorText = "Enter a valid address."
|
|
||||||
component.successText = "Good job entering a valid address!"
|
|
||||||
component.tooltipModel = .init(title: "Check the formatting of your address", content: "House/Building number then street name")
|
|
||||||
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -163,6 +163,7 @@ class InputStepperViewController: BaseViewController<InputStepper> {
|
|||||||
widthTextField
|
widthTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
if let number {
|
if let number {
|
||||||
self?.component.widthPercentage = nil
|
self?.component.widthPercentage = nil
|
||||||
self?.component.width = number.cgFloatValue
|
self?.component.width = number.cgFloatValue
|
||||||
@ -175,6 +176,7 @@ class InputStepperViewController: BaseViewController<InputStepper> {
|
|||||||
widthPercentageTextField
|
widthPercentageTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
if let number, number.intValue > 10 {
|
if let number, number.intValue > 10 {
|
||||||
self?.component.width = nil
|
self?.component.width = nil
|
||||||
self?.component.widthPercentage = number.cgFloatValue
|
self?.component.widthPercentage = number.cgFloatValue
|
||||||
@ -253,3 +255,11 @@ class InputStepperViewController: BaseViewController<InputStepper> {
|
|||||||
helperTextPlacementPickerSelectorView.text = component.helperTextPlacement.rawValue
|
helperTextPlacementPickerSelectorView.text = component.helperTextPlacement.rawValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension InputStepperViewController: ComponentSampleable {
|
||||||
|
static func makeSample() -> ComponentSample {
|
||||||
|
let c = Self()
|
||||||
|
c.setupModel()
|
||||||
|
return ComponentSample(component: c.component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -145,6 +145,7 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
|
|
||||||
override func setupForm(){
|
override func setupForm(){
|
||||||
super.setupForm()
|
super.setupForm()
|
||||||
|
addFormRow(label: "Current Language", view: Label().with { $0.text = LanguageManager.currentLanguage.description })
|
||||||
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
|
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
|
||||||
addFormRow(label: "Bold", view: boldSwitch, pinTrailing: false)
|
addFormRow(label: "Bold", view: boldSwitch, pinTrailing: false)
|
||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
|
|||||||
@ -128,6 +128,20 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
|
|||||||
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: tooltip)
|
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: tooltip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var useSpanish = Toggle().with {
|
||||||
|
$0.offText = "English"
|
||||||
|
$0.onText = "Spanish"
|
||||||
|
$0.showText = true
|
||||||
|
$0.textPosition = .right
|
||||||
|
}
|
||||||
|
|
||||||
|
useSpanish.isOn = LanguageManager.currentLanguage == .spanish
|
||||||
|
useSpanish.onChange = { control in
|
||||||
|
LanguageManager.currentLanguage = control.isOn ? .spanish : .english
|
||||||
|
}
|
||||||
|
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: useSpanish)
|
||||||
|
|
||||||
|
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
overrideUserInterfaceStyle = .light
|
overrideUserInterfaceStyle = .light
|
||||||
tableView.register(MenuCell.self, forCellReuseIdentifier: "cell")
|
tableView.register(MenuCell.self, forCellReuseIdentifier: "cell")
|
||||||
|
|||||||
@ -142,3 +142,11 @@ class PriceLockupViewController: BaseViewController<PriceLockup> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension PriceLockupViewController: ComponentSampleable {
|
||||||
|
static func makeSample() -> ComponentSample {
|
||||||
|
let c = Self()
|
||||||
|
c.setupModel()
|
||||||
|
return ComponentSample(component: c.component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -140,6 +140,6 @@ extension RadioBoxGroupViewController: ComponentSampleable {
|
|||||||
|
|
||||||
component.selectorModels = [radioBox1, radioBox2]
|
component.selectorModels = [radioBox1, radioBox2]
|
||||||
|
|
||||||
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,6 +133,6 @@ extension RadioButtonGroupViewController: ComponentSampleable {
|
|||||||
|
|
||||||
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
component.selectorModels = [radioButton1, radioButton2, radioButton3]
|
||||||
|
|
||||||
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,6 +105,6 @@ extension RadioButtonItemViewController: ComponentSampleable {
|
|||||||
component.childText = "I agree to Verizon's terms and conditions click here"
|
component.childText = "I agree to Verizon's terms and conditions click here"
|
||||||
component.errorText = "Error Text"
|
component.errorText = "Error Text"
|
||||||
|
|
||||||
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -218,3 +218,11 @@ class TableViewController: BaseViewController<Table> {
|
|||||||
self.component.tableRows = rows
|
self.component.tableRows = rows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension TableViewController: ComponentSampleable {
|
||||||
|
static func makeSample() -> ComponentSample {
|
||||||
|
let c = Self()
|
||||||
|
c.setupModel()
|
||||||
|
return ComponentSample(component: c.component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public struct ComponentSample {
|
|||||||
public enum LessThanPinningType: String {
|
public enum LessThanPinningType: String {
|
||||||
case none, equalTo, lessThanOrEqual
|
case none, equalTo, lessThanOrEqual
|
||||||
}
|
}
|
||||||
|
public var edgeInset: UIEdgeInsets = .uniform(16)
|
||||||
public var top: GreaterThanPinningType = .equalTo
|
public var top: GreaterThanPinningType = .equalTo
|
||||||
public var leading: GreaterThanPinningType = .equalTo
|
public var leading: GreaterThanPinningType = .equalTo
|
||||||
public var trailing: LessThanPinningType = .equalTo
|
public var trailing: LessThanPinningType = .equalTo
|
||||||
@ -30,16 +30,18 @@ public struct ComponentSample {
|
|||||||
topPinningType: GreaterThanPinningType = .equalTo,
|
topPinningType: GreaterThanPinningType = .equalTo,
|
||||||
leadingPinningType: GreaterThanPinningType = .equalTo,
|
leadingPinningType: GreaterThanPinningType = .equalTo,
|
||||||
trailingPinningType: LessThanPinningType = .equalTo,
|
trailingPinningType: LessThanPinningType = .equalTo,
|
||||||
bottomPinningType: LessThanPinningType = .equalTo) {
|
bottomPinningType: LessThanPinningType = .equalTo,
|
||||||
|
edgeInset: UIEdgeInsets = .uniform(16)) {
|
||||||
|
|
||||||
self.component = component
|
self.component = component
|
||||||
self.top = topPinningType
|
self.top = topPinningType
|
||||||
self.leading = leadingPinningType
|
self.leading = leadingPinningType
|
||||||
self.trailing = trailingPinningType
|
self.trailing = trailingPinningType
|
||||||
self.bottom = bottomPinningType
|
self.bottom = bottomPinningType
|
||||||
|
self.edgeInset = edgeInset
|
||||||
}
|
}
|
||||||
|
|
||||||
public func pin(edgeInset: UIEdgeInsets = .zero) {
|
public func pin() {
|
||||||
|
|
||||||
guard let superview = component.superview else { return }
|
guard let superview = component.superview else { return }
|
||||||
switch top {
|
switch top {
|
||||||
@ -126,10 +128,10 @@ public class TableViewTestController: UIViewController, Initable, Surfaceable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let toggleSample = ComponentSample(component: toggle, leadingPinningType: .none)
|
let toggleSample = ComponentSample(component: toggle, leadingPinningType: .none, edgeInset: .init(top: 5, left: 0, bottom: 5, right: 16))
|
||||||
let wrapper = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false }
|
let wrapper = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false }
|
||||||
wrapper.addSubview(toggle)
|
wrapper.addSubview(toggle)
|
||||||
toggleSample.pin(edgeInset: .init(top: 5, left: 0, bottom: 5, right: 16))
|
toggleSample.pin()
|
||||||
|
|
||||||
let stackView = UIStackView(arrangedSubviews: [wrapper, tableView]).with {
|
let stackView = UIStackView(arrangedSubviews: [wrapper, tableView]).with {
|
||||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
@ -193,7 +195,7 @@ extension TableViewTestController : UITableViewDelegate, UITableViewDataSource {
|
|||||||
|
|
||||||
let cell = UITableViewCell()
|
let cell = UITableViewCell()
|
||||||
cell.contentView.addSubview(component)
|
cell.contentView.addSubview(component)
|
||||||
sample.pin(edgeInset: .uniform(16))
|
sample.pin()
|
||||||
cell.backgroundColor = surface.color
|
cell.backgroundColor = surface.color
|
||||||
cell.layoutIfNeeded()
|
cell.layoutIfNeeded()
|
||||||
return cell
|
return cell
|
||||||
|
|||||||
@ -101,11 +101,8 @@ class TextAreaViewController: BaseViewController<TextArea> {
|
|||||||
widthTextField
|
widthTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
guard let number else {
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
self?.component.width = nil
|
self?.component.width = number?.cgFloatValue
|
||||||
return
|
|
||||||
}
|
|
||||||
self?.component.width = number.cgFloatValue
|
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
tooltipTitleTextField
|
tooltipTitleTextField
|
||||||
@ -182,13 +179,8 @@ class TextAreaViewController: BaseViewController<TextArea> {
|
|||||||
|
|
||||||
extension TextAreaViewController: ComponentSampleable {
|
extension TextAreaViewController: ComponentSampleable {
|
||||||
static func makeSample() -> ComponentSample {
|
static func makeSample() -> ComponentSample {
|
||||||
let component = Self.makeComponent()
|
let c = Self()
|
||||||
component.width = 328
|
c.setupModel()
|
||||||
component.labelText = "Street Address"
|
return ComponentSample(component: c.component)
|
||||||
component.helperText = "For example: 123 Verizon St"
|
|
||||||
component.errorText = "Enter a valid address."
|
|
||||||
component.tooltipModel = .init(title: "Check the formatting of your address",
|
|
||||||
content:"House/Building number then street name")
|
|
||||||
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -186,7 +186,7 @@ class TileContainerViewController: BaseViewController<TileContainer> {
|
|||||||
component.color = .secondary
|
component.color = .secondary
|
||||||
component.accessibilityLabel = "Tile Container"
|
component.accessibilityLabel = "Tile Container"
|
||||||
|
|
||||||
addContentTopView(view: component, pinTrailing: false)
|
addContentTopView(view: component)
|
||||||
component.addContentView(mainView)
|
component.addContentView(mainView)
|
||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
@ -290,6 +290,7 @@ class TileContainerViewController: BaseViewController<TileContainer> {
|
|||||||
widthTextField
|
widthTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
guard let self, let number = number?.cgFloatValue else {
|
guard let self, let number = number?.cgFloatValue else {
|
||||||
self?.widthTextField.text = ""
|
self?.widthTextField.text = ""
|
||||||
return
|
return
|
||||||
|
|||||||
@ -317,7 +317,7 @@ class TileletViewController: BaseViewController<Tilelet> {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
addContentTopView(view: component, pinTrailing: false)
|
addContentTopView(view: component)
|
||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
@ -362,9 +362,14 @@ class TileletViewController: BaseViewController<Tilelet> {
|
|||||||
$0.addFormRow(label: "Max Width", view: maxWidthTextField)
|
$0.addFormRow(label: "Max Width", view: maxWidthTextField)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
append(section: .init().with({
|
||||||
|
$0.title = "Text Styles"
|
||||||
|
$0.addFormRow(label: "Title", view: titleStandardStylePickerSelectorView)
|
||||||
|
$0.addFormRow(label: "Eyebrow/Subtitle", view: otherStandardStylePickerSelectorView)
|
||||||
|
}))
|
||||||
|
|
||||||
append(section: .init().with({
|
append(section: .init().with({
|
||||||
$0.title = "Eyebrow"
|
$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, pinTrailing: false)
|
$0.addFormRow(label: "is Bold", view: eyebrowIsBold, pinTrailing: false)
|
||||||
$0.addFormRow(label: "Text", view: eyebrowTextField)
|
$0.addFormRow(label: "Text", view: eyebrowTextField)
|
||||||
$0.addFormRow(label: "Color", view: eyebrowColorPickerSelectorView)
|
$0.addFormRow(label: "Color", view: eyebrowColorPickerSelectorView)
|
||||||
@ -377,11 +382,11 @@ class TileletViewController: BaseViewController<Tilelet> {
|
|||||||
|
|
||||||
append(section: .init().with({
|
append(section: .init().with({
|
||||||
$0.title = "Title"
|
$0.title = "Title"
|
||||||
$0.addFormRow(label: "Text Style", view: titleStandardStylePickerSelectorView)
|
|
||||||
$0.addFormRow(label: "is Bold", view: titleIsBold, pinTrailing: false)
|
$0.addFormRow(label: "is Bold", view: titleIsBold, pinTrailing: false)
|
||||||
$0.addFormRow(label: "Text", view: titleTextField)
|
$0.addFormRow(label: "Text", view: titleTextField)
|
||||||
$0.addFormRow(label: "Color", view: titleColorPickerSelectorView)
|
$0.addFormRow(label: "Color", view: titleColorPickerSelectorView)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
titleTokenFormStackView.addFormRow(label: "Token", view: titleTokenColorView)
|
titleTokenFormStackView.addFormRow(label: "Token", view: titleTokenColorView)
|
||||||
titleColorFormStackView.addFormRow(label: "Custom", view: titleCustomColorView)
|
titleColorFormStackView.addFormRow(label: "Custom", view: titleCustomColorView)
|
||||||
append(section: titleTokenFormStackView)
|
append(section: titleTokenFormStackView)
|
||||||
@ -459,6 +464,7 @@ class TileletViewController: BaseViewController<Tilelet> {
|
|||||||
widthTextField
|
widthTextField
|
||||||
.numberPublisher
|
.numberPublisher
|
||||||
.sink { [weak self] number in
|
.sink { [weak self] number in
|
||||||
|
self?.updateComponentConstraint(pinTrailing: number == nil)
|
||||||
guard let self, let number = number?.cgFloatValue else {
|
guard let self, let number = number?.cgFloatValue else {
|
||||||
self?.widthTextField.text = ""
|
self?.widthTextField.text = ""
|
||||||
return
|
return
|
||||||
|
|||||||
@ -146,9 +146,14 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
|
|||||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||||
addFormRow(label: "Text Alignment", view: textAlignmentPickerSelectorView)
|
addFormRow(label: "Text Alignment", view: textAlignmentPickerSelectorView)
|
||||||
|
|
||||||
|
append(section: .init().with({
|
||||||
|
$0.title = "Text Styles"
|
||||||
|
$0.addFormRow(label: "Title", view: titleStandardStylePickerSelectorView)
|
||||||
|
$0.addFormRow(label: "Eyebrow/Subtitle", view: otherStandardStylePickerSelectorView)
|
||||||
|
}))
|
||||||
|
|
||||||
append(section: .init().with({
|
append(section: .init().with({
|
||||||
$0.title = "\nEyebrow"
|
$0.title = "\nEyebrow"
|
||||||
$0.addFormRow(label: "TextStyle (Subtitle)", view: otherStandardStylePickerSelectorView)
|
|
||||||
$0.addFormRow(label: "is Bold", view: eyebrowIsBold, pinTrailing: false)
|
$0.addFormRow(label: "is Bold", view: eyebrowIsBold, pinTrailing: false)
|
||||||
$0.addFormRow(label: "Text", view: eyebrowTextField)
|
$0.addFormRow(label: "Text", view: eyebrowTextField)
|
||||||
$0.addFormRow(label: "Color", view: eyebrowColorPickerSelectorView)
|
$0.addFormRow(label: "Color", view: eyebrowColorPickerSelectorView)
|
||||||
@ -161,7 +166,6 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
|
|||||||
|
|
||||||
append(section: .init().with({
|
append(section: .init().with({
|
||||||
$0.title = "\nTitle"
|
$0.title = "\nTitle"
|
||||||
$0.addFormRow(label: "TextStyle", view: titleStandardStylePickerSelectorView)
|
|
||||||
$0.addFormRow(label: "is Bold", view: titleIsBold, pinTrailing: false)
|
$0.addFormRow(label: "is Bold", view: titleIsBold, pinTrailing: false)
|
||||||
$0.addFormRow(label: "Text", view: titleTextField)
|
$0.addFormRow(label: "Text", view: titleTextField)
|
||||||
$0.addFormRow(label: "Color", view: titleColorPickerSelectorView)
|
$0.addFormRow(label: "Color", view: titleColorPickerSelectorView)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user