102 lines
6.1 KiB
Swift
102 lines
6.1 KiB
Swift
//
|
|
// ModalViewController.swift
|
|
// VDSSample
|
|
//
|
|
// Created by Kanamarlapudi, Vasavi on 05/09/24.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
import VDS
|
|
import VDSCoreTokens
|
|
import Combine
|
|
|
|
class ModalViewController: BaseViewController<Modal> {
|
|
|
|
var showFooterSwitch = Toggle()
|
|
var fullScreenDialogSwitch = Toggle()
|
|
var singleButtonSwitch = Toggle()
|
|
var hideCloseSwitch = Toggle()
|
|
var disableAnimationSwitch = Toggle()
|
|
var disableOutsideSwitch = Toggle()
|
|
var openedSwitch = Toggle()
|
|
var enableBackSwitch = Toggle()
|
|
|
|
var titleTextField = TextField()
|
|
var bodyTextField = TextField()
|
|
var heightTextField = TextField()
|
|
var widthTextField = TextField()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
|
|
|
|
setupPicker()
|
|
setupModel()
|
|
}
|
|
|
|
override func setupForm(){
|
|
super.setupForm()
|
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
|
addFormRow(label: "Show Modal Footer", view: showFooterSwitch, pinTrailing: false)
|
|
addFormRow(label: "Full Screen Dialog", view: fullScreenDialogSwitch, pinTrailing: false)
|
|
addFormRow(label: "Single Button", view: singleButtonSwitch, pinTrailing: false)
|
|
addFormRow(label: "Hide Close Button", view: hideCloseSwitch, pinTrailing: false)
|
|
addFormRow(label: "Disable Animation", view: disableAnimationSwitch, pinTrailing: false)
|
|
addFormRow(label: "Disable Outside Click", view: disableOutsideSwitch, pinTrailing: false)
|
|
addFormRow(label: "Opened", view: openedSwitch, pinTrailing: false)
|
|
addFormRow(label: "Modal Title", view: titleTextField)
|
|
addFormRow(label: "Modal Body", view: bodyTextField)
|
|
addFormRow(label: "Enable Back Button", view: enableBackSwitch, pinTrailing: false)
|
|
addFormRow(label: "Max Height", view: heightTextField)
|
|
addFormRow(label: "Max Width", view: widthTextField)
|
|
|
|
fullScreenDialogSwitch.onChange = { [weak self] sender in
|
|
self?.component.fullScreenDialog = !sender.isOn
|
|
}
|
|
|
|
titleTextField
|
|
.textPublisher
|
|
.sink { [weak self] text in
|
|
self?.component.title = text
|
|
}.store(in: &subscribers)
|
|
|
|
bodyTextField
|
|
.textPublisher
|
|
.sink { [weak self] text in
|
|
self?.component.content = text
|
|
}.store(in: &subscribers)
|
|
|
|
}
|
|
|
|
func setupModel() {
|
|
component.title = "Shipping Options To Deliver Your Order On Time!!!"
|
|
component.content = "Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed."
|
|
let onClick: (ButtonBase) -> Void = { button in print("\(button.text!) clicked")}
|
|
component.contentView = Button().with{ $0.use = .secondary; $0.text = "Secondary"; $0.onClick = onClick}
|
|
|
|
//setup UI
|
|
surfacePickerSelectorView.text = component.surface.rawValue
|
|
titleTextField.text = component.title
|
|
bodyTextField.text = component.content
|
|
}
|
|
|
|
//Picker
|
|
func setupPicker(){
|
|
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
self?.component.surface = item
|
|
self?.contentTopView.backgroundColor = item.color
|
|
}
|
|
}
|
|
}
|
|
|
|
extension ModalViewController: ComponentSampleable {
|
|
static func makeSample() -> ComponentSample {
|
|
let component = Self.makeComponent()
|
|
component.title = "5G Ultra Wideband is available in your area."
|
|
component.content = "$799.99 (128 GB only) "
|
|
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual, bottomPinningType: .lessThanOrEqual)
|
|
}
|
|
}
|
|
|