Merge branch 'vasavk/modal' into 'develop'

VDS Brand 3.0 Modal

See merge request BPHV_MIPS/vds_ios_sample!73
This commit is contained in:
Bruce, Matt R 2024-10-04 18:47:39 +00:00
commit 75246c0f5b
4 changed files with 134 additions and 2 deletions

View File

@ -41,6 +41,7 @@
18926F5F2C76185A00C55BF6 /* FootnoteItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18926F5E2C76185A00C55BF6 /* FootnoteItemViewController.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 */; };
@ -143,6 +144,7 @@
18926F5E2C76185A00C55BF6 /* FootnoteItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FootnoteItemViewController.swift; sourceTree = "<group>"; };
18A3F12F2BD9332500498E4A /* CalendarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarViewController.swift; sourceTree = "<group>"; };
18AE87512C06FDD60075F181 /* CarouselViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselViewController.swift; sourceTree = "<group>"; };
18C0F9472C98177F00E1DD71 /* ModalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalViewController.swift; sourceTree = "<group>"; };
440B84CB2BD8E98B004A732A /* TableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = "<group>"; };
445BA07929C088470036A7C5 /* NotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewController.swift; sourceTree = "<group>"; };
44604AD829CE1CF900E62B51 /* LineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineViewController.swift; sourceTree = "<group>"; };
@ -353,6 +355,7 @@
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
44604AD829CE1CF900E62B51 /* LineViewController.swift */,
EAD0688F2A55FC11002E3A2D /* LoaderViewController.swift */,
18C0F9472C98177F00E1DD71 /* ModalViewController.swift */,
445BA07929C088470036A7C5 /* NotificationViewController.swift */,
71B23C302B921D730027F7D9 /* PaginationViewController.swift */,
184023482C61E9E700A412C8 /* PriceLockupViewController.swift */,
@ -555,6 +558,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 */,

View File

@ -4,10 +4,10 @@
VERSION="2.0"
#Update onces stable
#APITOKEN=AKCp5cbwXBA2Rarq6WagmFFxQxcxsARGxSq5g1H8NaGm7837KTgwdWPqsp7FdgRa13B7AcpGN
#URL=https://oneartifactorycloud.verizon.com/artifactory
#URL=https://oneartifactorycloud.verizon.com/artifactory/
APITOKEN=AKCp5ZmHP8B1dkLtdSh23bMcWHtrWzoB3SfhoCNpEC5e3dKNhiKsn8TPMZQafXzm2qkeXFXE6
URL=https://oneartifactoryprod.verizon.com/artifactory
URL=https://oneartifactoryci.verizon.com/artifactory
LOCALPATH="${1}"
REMOTEPATH="${2}"

View File

@ -90,6 +90,7 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
MenuComponent(title: "Label", completed: true, viewController: LabelViewController.self),
MenuComponent(title: "Line", completed: true, viewController: LineViewController.self),
MenuComponent(title: "Loader", completed: true, viewController: LoaderViewController.self),
MenuComponent(title: "Modal", completed: false, viewController: ModalViewController.self),
MenuComponent(title: "Notification", completed: true, viewController: NotificationViewController.self),
MenuComponent(title: "Pagination", completed: true, viewController: PaginationViewController.self),
MenuComponent(title: "PriceLockup", completed: true, viewController: PriceLockupViewController.self),

View File

@ -0,0 +1,127 @@
//
// 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 titleTextField = TextField()
var bodyTextField = 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: "Modal Title", view: titleTextField)
addFormRow(label: "Modal Body", view: bodyTextField)
fullScreenDialogSwitch.publisher(for: .valueChanged).sink { [weak self] control in
self?.component.fullScreenDialog = control.isOn
}.store(in: &subscribers)
showFooterSwitch.publisher(for: .valueChanged).sink { [weak self] control in
guard let self else { return }
if control.isOn {
showFooter(with: singleButtonSwitch.isOn)
} else {
self.component.buttonData = nil
}
}.store(in: &subscribers)
singleButtonSwitch.publisher(for: .valueChanged).sink { [weak self] control in
guard let self else { return }
if control.isOn {
showFooterSwitch.isOn = true
}
showFooter(with: control.isOn)
}.store(in: &subscribers)
hideCloseSwitch.publisher(for: .valueChanged).sink { [weak self] control in
self?.component.hideCloseButton = control.isOn
}.store(in: &subscribers)
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 showFooter(with singleButton: Bool) {
if singleButton {
component.buttonData = [
Button().with{ $0.use = .secondary; $0.text = "Close"; $0.onClick = { button in self.dismiss(animated: true); print("\(button.text!) clicked")} ; $0.size = .large }
]
} else {
component.buttonData = [
Button().with{ $0.use = .primary; $0.text = "In-store Pickup"; $0.onClick = { button in print("\(button.text!) clicked")}; $0.size = .large },
Button().with{ $0.use = .secondary; $0.text = "Close"; $0.onClick = { button in self.dismiss(animated: true); print("\(button.text!) clicked")} ; $0.size = .large }
]
}
}
func setupModel() {
component.title = "Choose free 2-day shipping or In-store Pickup"
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."
component.contentView = Icon().with { $0.name = .addFolder; $0.size = .medium }
let onClick: (ButtonBase) -> Void = { button in print("\(button.text!) clicked")}
component.buttonData = [
Button().with{ $0.use = .primary; $0.text = "In-store Pickup"; $0.onClick = onClick; $0.size = .large },
Button().with{ $0.use = .secondary; $0.text = "Close"; $0.onClick = { button in self.dismiss(animated: true); print("\(button.text!) clicked")} ; $0.size = .large }
]
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
titleTextField.text = component.title
bodyTextField.text = component.content
showFooterSwitch.isOn = true
}
//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 = "Choose free 2-day shipping or In-store Pickup"
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."
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual, bottomPinningType: .lessThanOrEqual)
}
}