diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index 64ec822..7b82798 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -39,6 +39,7 @@ 186D13CD2BBA990800986B53 /* DropdownSelectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 186D13CC2BBA990800986B53 /* DropdownSelectViewController.swift */; }; 18A3F1302BD9332500498E4A /* CalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18A3F12F2BD9332500498E4A /* CalendarViewController.swift */; }; 18AE87522C06FDD60075F181 /* CarouselViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18AE87512C06FDD60075F181 /* CarouselViewController.swift */; }; + 18C0F9482C98177F00E1DD71 /* ModalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18C0F9472C98177F00E1DD71 /* ModalViewController.swift */; }; 440B84CC2BD8E98B004A732A /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440B84CB2BD8E98B004A732A /* TableViewController.swift */; }; 445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 445BA07929C088470036A7C5 /* NotificationViewController.swift */; }; 44604AD929CE1CF900E62B51 /* LineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD829CE1CF900E62B51 /* LineViewController.swift */; }; @@ -139,6 +140,7 @@ 186D13CC2BBA990800986B53 /* DropdownSelectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropdownSelectViewController.swift; sourceTree = ""; }; 18A3F12F2BD9332500498E4A /* CalendarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarViewController.swift; sourceTree = ""; }; 18AE87512C06FDD60075F181 /* CarouselViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselViewController.swift; sourceTree = ""; }; + 18C0F9472C98177F00E1DD71 /* ModalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalViewController.swift; sourceTree = ""; }; 440B84CB2BD8E98B004A732A /* TableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = ""; }; 445BA07929C088470036A7C5 /* NotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewController.swift; sourceTree = ""; }; 44604AD829CE1CF900E62B51 /* LineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineViewController.swift; sourceTree = ""; }; @@ -347,6 +349,7 @@ EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */, 44604AD829CE1CF900E62B51 /* LineViewController.swift */, EAD0688F2A55FC11002E3A2D /* LoaderViewController.swift */, + 18C0F9472C98177F00E1DD71 /* ModalViewController.swift */, 445BA07929C088470036A7C5 /* NotificationViewController.swift */, 71B23C302B921D730027F7D9 /* PaginationViewController.swift */, 184023482C61E9E700A412C8 /* PriceLockupViewController.swift */, @@ -549,6 +552,7 @@ EAB5FEF32928153D00998C17 /* Helper.swift in Sources */, EA89204728B66CE2006B9984 /* KeyboardFrameChangeListener.swift in Sources */, EA4DB30428DCD25B00103EE3 /* BadgeViewController.swift in Sources */, + 18C0F9482C98177F00E1DD71 /* ModalViewController.swift in Sources */, EAB2376029E88D5D00AABE9A /* TooltipViewController.swift in Sources */, EA89204828B66CE2006B9984 /* ScrollViewKeyboardAvoiding.swift in Sources */, EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */, diff --git a/VDSSample/ViewControllers/ModalViewController.swift b/VDSSample/ViewControllers/ModalViewController.swift new file mode 100644 index 0000000..82c5310 --- /dev/null +++ b/VDSSample/ViewControllers/ModalViewController.swift @@ -0,0 +1,103 @@ +// +// ModalViewController.swift +// VDSSample +// +// Created by Kanamarlapudi, Vasavi on 5/09/24. +// + +import Foundation +import UIKit +import VDS +import VDSCoreTokens +import Combine + +class ModalViewController: BaseViewController { + + var disabledSwitch = Toggle() + 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: "Disabled", view: disabledSwitch) + addFormRow(label: "Surface", view: surfacePickerSelectorView) + addFormRow(label: "Show Modal Footer", view: showFooterSwitch) + addFormRow(label: "Full Screen Dialog", view: fullScreenDialogSwitch) + addFormRow(label: "Single Button", view: singleButtonSwitch) + addFormRow(label: "Hide Close Button", view: hideCloseSwitch) + addFormRow(label: "Disable Animation", view: disableAnimationSwitch) + addFormRow(label: "Disable Outside Click", view: disableOutsideSwitch) + addFormRow(label: "Opened", view: openedSwitch) + addFormRow(label: "Modal Title", view: titleTextField) + addFormRow(label: "Modal Body", view: bodyTextField) + addFormRow(label: "Enable Back Button", view: enableBackSwitch) + addFormRow(label: "Max Height", view: heightTextField) + addFormRow(label: "Max Width", view: widthTextField) + + disabledSwitch.onChange = { [weak self] sender in + self?.component.isEnabled = !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 = "5G Ultra Wideband is available in your area." + component.content = "$799.99 (128 GB only) " + //component.contentView = Icon().with { $0.name = .addFolder; $0.size = .medium } + + //setup UI + surfacePickerSelectorView.text = component.surface.rawValue + disabledSwitch.isOn = !component.isEnabled + 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) + } +} +