diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index 491ccea..db813fa 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -32,9 +32,12 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 1808BEBE2BA4479500129230 /* CarouselScrollbarViewConttroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1808BEBD2BA4479500129230 /* CarouselScrollbarViewConttroller.swift */; }; + 1832AC5B2BA1347B008AE476 /* BreadcrumbsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1832AC5A2BA1347B008AE476 /* BreadcrumbsViewController.swift */; }; 445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 445BA07929C088470036A7C5 /* NotificationViewController.swift */; }; 44604AD929CE1CF900E62B51 /* LineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD829CE1CF900E62B51 /* LineViewController.swift */; }; 5FC35BE928D5235A004EBEAC /* ButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */; }; + 71B23C312B921D740027F7D9 /* PaginationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71B23C302B921D730027F7D9 /* PaginationViewController.swift */; }; EA0D1C2F2A66CFE900E5C127 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */; }; EA0D1C312A673F3500E5C127 /* RadioButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */; }; EA0D1C332A673FD400E5C127 /* RadioButtonItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */; }; @@ -121,9 +124,12 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 1808BEBD2BA4479500129230 /* CarouselScrollbarViewConttroller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselScrollbarViewConttroller.swift; sourceTree = ""; }; + 1832AC5A2BA1347B008AE476 /* BreadcrumbsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BreadcrumbsViewController.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 = ""; }; 5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonViewController.swift; sourceTree = ""; }; + 71B23C302B921D730027F7D9 /* PaginationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationViewController.swift; sourceTree = ""; }; EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxViewController.swift; sourceTree = ""; }; EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonViewController.swift; sourceTree = ""; }; EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonItemViewController.swift; sourceTree = ""; }; @@ -296,36 +302,39 @@ isa = PBXGroup; children = ( EA89203E28B66CE2006B9984 /* ScrollViewController */, - EA3C3BB228996775000CA526 /* MenuViewController.swift */, - EAD062A22A3913920015965D /* DropShawdowViewController.swift */, EA297A672A02F5320031ED56 /* TableViewTestController.swift */, - EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */, - EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */, + EAD062A22A3913920015965D /* DropShawdowViewController.swift */, + EA3C3BB228996775000CA526 /* MenuViewController.swift */, EAD062AC2A3B86950015965D /* BadgeIndicatorViewController.swift */, - EA81410D2A0ED8DC004F60D2 /* ButtonIconViewController.swift */, + EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */, + EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */, + 1832AC5A2BA1347B008AE476 /* BreadcrumbsViewController.swift */, EAB5FEEE2927E28400998C17 /* ButtonGroupViewController.swift */, + EA81410D2A0ED8DC004F60D2 /* ButtonIconViewController.swift */, 5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */, - EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */, - EAF7F09B2899B92400B287F5 /* CheckboxItemViewController.swift */, + 1808BEBD2BA4479500129230 /* CarouselScrollbarViewConttroller.swift */, EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */, + EAF7F09B2899B92400B287F5 /* CheckboxItemViewController.swift */, + EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */, EA985C00296CC21C00F2FF2E /* IconViewController.swift */, EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */, EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */, 44604AD829CE1CF900E62B51 /* LineViewController.swift */, EAD0688F2A55FC11002E3A2D /* LoaderViewController.swift */, 445BA07929C088470036A7C5 /* NotificationViewController.swift */, + 71B23C302B921D730027F7D9 /* PaginationViewController.swift */, EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */, - EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */, - EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */, EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */, + EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */, + EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */, EA5F86CD2A1E863F00BC83E4 /* TabsContainerViewController.swift */, EA596AB92A16B2ED00300C4B /* TabsViewController.swift */, - EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */, EA985C24296E06EA00F2FF2E /* TextAreaViewController.swift */, + EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */, EAC9257F29119FC400091998 /* TextLinkViewController.swift */, EA5E304F294D11540082B959 /* TileContainerViewController.swift */, - EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */, EA5E305B295111050082B959 /* TileletViewController.swift */, + EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */, EA3C3BB328996775000CA526 /* ToggleViewController.swift */, EAB2375F29E88D5D00AABE9A /* TooltipViewController.swift */, EAB2376B29E9E74900AABE9A /* TrailingTooltipLabelViewController.swift */, @@ -481,6 +490,7 @@ EA89205128B68307006B9984 /* TextField.swift in Sources */, EA297A682A02F5320031ED56 /* TableViewTestController.swift in Sources */, 44604AD929CE1CF900E62B51 /* LineViewController.swift in Sources */, + 1808BEBE2BA4479500129230 /* CarouselScrollbarViewConttroller.swift in Sources */, EA3C3BB528996775000CA526 /* StoryboardInitable.swift in Sources */, EA89201928B56DF5006B9984 /* RadioBoxGroupViewController.swift in Sources */, EA3C3BB628996775000CA526 /* MenuViewController.swift in Sources */, @@ -508,12 +518,14 @@ EAB2376029E88D5D00AABE9A /* TooltipViewController.swift in Sources */, EA89204828B66CE2006B9984 /* ScrollViewKeyboardAvoiding.swift in Sources */, EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */, + 71B23C312B921D740027F7D9 /* PaginationViewController.swift in Sources */, EAF7F09C2899B92400B287F5 /* CheckboxItemViewController.swift in Sources */, EA0D1C2F2A66CFE900E5C127 /* CheckboxViewController.swift in Sources */, EA596ABA2A16B2ED00300C4B /* TabsViewController.swift in Sources */, EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */, EAA5EEAD28EB6924003B3210 /* InputFieldViewController.swift in Sources */, EA985C25296E06EA00F2FF2E /* TextAreaViewController.swift in Sources */, + 1832AC5B2BA1347B008AE476 /* BreadcrumbsViewController.swift in Sources */, EA81410E2A0ED8DC004F60D2 /* ButtonIconViewController.swift in Sources */, EA985C20296DECF600F2FF2E /* IconName.swift in Sources */, EA89204928B66CE2006B9984 /* KeyboardFrameChangeListening.swift in Sources */, @@ -672,7 +684,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 54; + CURRENT_PROJECT_VERSION = 56; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77; GENERATE_INFOPLIST_FILE = YES; @@ -707,7 +719,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 54; + CURRENT_PROJECT_VERSION = 56; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77; GENERATE_INFOPLIST_FILE = YES; diff --git a/VDSSample/ViewControllers/BreadcrumbsViewController.swift b/VDSSample/ViewControllers/BreadcrumbsViewController.swift new file mode 100644 index 0000000..88cc5fe --- /dev/null +++ b/VDSSample/ViewControllers/BreadcrumbsViewController.swift @@ -0,0 +1,92 @@ +// +// BreadcrumbsViewController.swift +// VDSSample +// +// Created by Kanamarlapudi, Vasavi on 05/03/24. +// + +import Foundation +import UIKit +import VDS +import VDSColorTokens +import Combine + +class BreadcrumbsViewController: BaseViewController { + + var selectedSwitch = Toggle() + var sampleSwitch = Toggle() + var selectedCrumbLabel = Label().with { $0.textStyle = .boldBodyMedium } + var allBreadcrumbs: [Breadcrumbs.BreadcrumbItemModel] = [ + .init(text: "Home"), + .init(text: "Support", enabeled: false), + .init(text: "Service & Apps"), + .init(text: "My Verizon"), + .init(text: "Bill"), + .init(text: "Mobile Billing & Payments"), + .init(text: "Billing statement FAQs", selected: true) + ] + + var some: [Breadcrumbs.BreadcrumbItemModel] = [ + .init(text: "Plans"), + .init(text: "Upgrade Plan"), + .init(text: "Billing Statement Frequently Asked Questions About Stuff You don't want to see", selected: true) + ] + + override func viewDidLoad() { + super.viewDidLoad() + let stack = UIStackView(arrangedSubviews: [component, selectedCrumbLabel]).with { + $0.axis = .vertical + $0.spacing = 25 + } + addContentTopView(view: stack) + setupPicker() + setupModel() + } + + override func setupForm(){ + super.setupForm() + addFormRow(label: "Surface", view: surfacePickerSelectorView) + addFormRow(label: "Last Crumb Selected", view: selectedSwitch) + addFormRow(label: "Large Sample", view: sampleSwitch) + + selectedSwitch.onChange = { [weak self] sender in + guard let self else { return } + component.breadcrumbs.last?.isSelected = sender.isOn + } + + sampleSwitch.onChange = { [weak self] sender in + guard let self else { return } + self.component.breadcrumbModels = sender.isOn ? self.allBreadcrumbs : self.some + selectedSwitch.isOn = true + updatedCrumbLabel(crumb: component.breadcrumbs.last ?? nil) + } + } + + func setupPicker(){ + surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.component.surface = item + self?.contentTopView.backgroundColor = item.color + self?.selectedCrumbLabel.surface = item + } + } + + func updatedCrumbLabel(crumb: BreadcrumbItem?) { + selectedCrumbLabel.text = "Selected Crumb : \(crumb?.text ?? "")" + } + + func setupModel() { + //setup UI + component.breadcrumbModels = allBreadcrumbs + selectedSwitch.isOn = true + sampleSwitch.isOn = true + surfacePickerSelectorView.text = component.surface.rawValue + + updatedCrumbLabel(crumb: component.breadcrumbs.last ?? nil) + //test setup to show component was picked + component.onBreadcrumbDidSelect = { [weak self] crumb in + guard let self else { return } + self.updatedCrumbLabel(crumb: crumb) + } + + } +} diff --git a/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift b/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift new file mode 100644 index 0000000..941172f --- /dev/null +++ b/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift @@ -0,0 +1,121 @@ +// +// CarouselScrollbarViewConttroller.swift +// VDSSample +// +// Created by Kanamarlapudi, Vasavi on 15/03/24. +// + +import Foundation +import UIKit +import VDS +import Combine +import VDSColorTokens + +class CarouselScrollbarViewConttroller: BaseViewController { + + lazy var layoutPickerSelectorView = { + PickerSelectorView(title: "1UP", + picker: self.picker, + items: CarouselScrollbar.Layout.allCases) + }() + + var slidesTextField = NumericField() + var positionTextField = NumericField() + var currentPositionLabel = Label().with { $0.textStyle = .boldBodyMedium } + + override func viewDidLoad() { + super.viewDidLoad() + let stack = UIStackView(arrangedSubviews: [component, currentPositionLabel]).with { + $0.axis = .vertical + $0.spacing = 25 + } + addContentTopView(view: stack) + setupPicker() + setupModel() + } + + override func setupForm() { + super.setupForm() + addFormRow(label: "Surface", view: surfacePickerSelectorView) + addFormRow(label: "Layout", view: layoutPickerSelectorView) + addFormRow(label: "Number Of Slides", view: slidesTextField) + addFormRow(label: "Position", view: positionTextField) + + slidesTextField + .numberPublisher + .sink { [weak self] number in + guard let number else { + return + } + self?.component.numberOfSlides = number.intValue + self?.component.position = Int(self?.positionTextField.text ?? "1") ?? 1 + }.store(in: &subscribers) + + positionTextField + .numberPublisher + .sink { [weak self] number in + guard let number else { + return + } + self?.component.position = number.intValue + }.store(in: &subscribers) + } + + func setupModel() { + //setup UI + component.numberOfSlides = 4 + surfacePickerSelectorView.text = component.surface.rawValue + slidesTextField.text = String(component.numberOfSlides) + positionTextField.text = String(component.position) + updatedPositionLabel(position: component.position, callbackText:"") + + //setup test page to show scrubber id was changed + component.onScrubberDrag = { [weak self] scrubberId in + guard let self else { return } + positionTextField.text = String(scrubberId) + updatedPositionLabel(position: component.position, callbackText:"onScrubberDrag") + } + + /// will be called when the thumb move forward. + component.onMoveForward = { [weak self] scrubberId in + guard let self else { return } + updatedPositionLabel(position: component.position, callbackText:"onMoveForward") + } + + /// will be called when the thumb move backward. + component.onMoveBackward = { [weak self] scrubberId in + guard let self else { return } + updatedPositionLabel(position: component.position, callbackText:"onMoveBackward") + } + + /// will be called when the thumb touch start. + component.onThumbTouchStart = { [weak self] scrubberId in + guard let self else { return } + updatedPositionLabel(position: component.position, callbackText:"onThumbTouchStart") + } + + /// will be called when the thumb touch end. + component.onThumbTouchEnd = { [weak self] scrubberId in + guard let self else { return } + updatedPositionLabel(position: component.position, callbackText:"onThumbTouchEnd") + } + + } + + func updatedPositionLabel(position: Int?, callbackText: String) { + currentPositionLabel.text = "\(callbackText) Thumb position : \(position ?? 1)" + } + + func setupPicker() { + surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.component.surface = item + self?.contentTopView.backgroundColor = item.color + self?.currentPositionLabel.surface = item + } + + layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.component.selectedLayout = item + self?.component.position = Int(self?.positionTextField.text ?? "1") ?? 1 + } + } +} diff --git a/VDSSample/ViewControllers/LoaderViewController.swift b/VDSSample/ViewControllers/LoaderViewController.swift index af153fc..8b8c9f3 100644 --- a/VDSSample/ViewControllers/LoaderViewController.swift +++ b/VDSSample/ViewControllers/LoaderViewController.swift @@ -16,7 +16,6 @@ class LoaderViewController: BaseViewController, LoaderLaunchable { override func viewDidLoad() { super.viewDidLoad() - contentTopView.height(constant: 80) addContentTopView(view: component) setupPicker() } diff --git a/VDSSample/ViewControllers/MenuViewController.swift b/VDSSample/ViewControllers/MenuViewController.swift index 5a2f4c0..f54f778 100644 --- a/VDSSample/ViewControllers/MenuViewController.swift +++ b/VDSSample/ViewControllers/MenuViewController.swift @@ -70,9 +70,11 @@ class MenuViewController: UITableViewController, TooltipLaunchable { MenuComponent(title: "TableView Tester", completed: true, viewController: TableViewTestController.self), MenuComponent(title: "Badge", completed: true, viewController: BadgeViewController.self), MenuComponent(title: "Badge Indicator", completed: true, viewController: BadgeIndicatorViewController.self), + MenuComponent(title: "Breadcrumbs", completed: true, viewController: BreadcrumbsViewController.self), MenuComponent(title: "Button", completed: true, viewController: ButtonViewController.self), MenuComponent(title: "ButtonGroup", completed: true, viewController: ButtonGroupViewController.self), MenuComponent(title: "ButtonIcon", completed: true, viewController: ButtonIconViewController.self), + MenuComponent(title: "Carousel Scrollbar", completed: true, viewController: CarouselScrollbarViewConttroller.self), MenuComponent(title: "Checkbox", completed: true, viewController: CheckboxViewController.self), MenuComponent(title: "CheckboxItem", completed: true, viewController: CheckboxItemViewController.self), MenuComponent(title: "CheckboxGroup", completed: true, viewController: CheckboxGroupViewController.self), @@ -82,17 +84,18 @@ class MenuViewController: UITableViewController, TooltipLaunchable { MenuComponent(title: "Line", completed: true, viewController: LineViewController.self), MenuComponent(title: "Loader", completed: true, viewController: LoaderViewController.self), MenuComponent(title: "Notification", completed: true, viewController: NotificationViewController.self), + MenuComponent(title: "Pagination", completed: true, viewController: PaginationViewController.self), MenuComponent(title: "RadioBoxGroup", completed: true, viewController: RadioBoxGroupViewController.self), MenuComponent(title: "RadioButton", completed: true, viewController: RadioButtonViewController.self), MenuComponent(title: "RadioButtonItem", completed: true, viewController: RadioButtonItemViewController.self), MenuComponent(title: "RadioButtonGroup", completed: true, viewController: RadioButtonGroupViewController.self), // //MenuComponent(title: "TabsContainer", completed: false, viewController: TabsContainerViewController.self), MenuComponent(title: "Tabs", completed: true, viewController: TabsViewController.self), - MenuComponent(title: "TextArea", completed: false, viewController: TextAreaViewController.self), + MenuComponent(title: "TextArea", completed: true, viewController: TextAreaViewController.self), MenuComponent(title: "TextLink", completed: true, viewController: TextLinkViewController.self), MenuComponent(title: "TextLinkCaret", completed: true, viewController: TextLinkCaretViewController.self), - MenuComponent(title: "TileContainer", completed: false, viewController: TileContainerViewController.self), - MenuComponent(title: "Tilelet", completed: false, viewController: TileletViewController.self), + MenuComponent(title: "TileContainer", completed: true, viewController: TileContainerViewController.self), + MenuComponent(title: "Tilelet", completed: true, viewController: TileletViewController.self), MenuComponent(title: "TitleLockup", completed: true, viewController: TitleLockupViewController.self), MenuComponent(title: "Toggle", completed: true, viewController: ToggleViewController.self), MenuComponent(title: "Tooltip", completed: true, viewController: TooltipViewController.self), diff --git a/VDSSample/ViewControllers/NotificationViewController.swift b/VDSSample/ViewControllers/NotificationViewController.swift index 76365f5..14e1f14 100644 --- a/VDSSample/ViewControllers/NotificationViewController.swift +++ b/VDSSample/ViewControllers/NotificationViewController.swift @@ -29,21 +29,11 @@ class NotificationViewController: BaseViewController { items: Notification.Style.allCases) }() - lazy var layoutTypePickerSelectorView = { - PickerSelectorView(title: "vertical", picker: self.picker, items: Notification.Layout.allCases) - }() - - var notification = Notification() - override func viewDidLoad() { super.viewDidLoad() - stackView.insertArrangedSubview(notification, at: 0) addContentTopView(view: component) - - notification.title = titleDefaultText - notification.subTitle = subtitleDefaultText - + component.title = titleDefaultText component.subTitle = subtitleDefaultText titleTextField.text = titleDefaultText @@ -60,7 +50,6 @@ class NotificationViewController: BaseViewController { super.setupForm() addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Style", view: notificationTypePickerSelectorView) - addFormRow(label: "Layout", view: layoutTypePickerSelectorView) addFormRow(label: "Title", view: titleTextField) addFormRow(label: "SubTitle", view: subTitleTextField) addFormRow(label: "Hide Button Group", view: buttonGroupToggle) @@ -73,31 +62,29 @@ class NotificationViewController: BaseViewController { print("onCloseClick: \(notification.title)") } - titleTextField.textPublisher.sink { newString in + titleTextField.textPublisher.sink { [weak self] newString in + guard let self else { return } self.component.title = newString - self.notification.title = newString }.store(in: &subscribers) - subTitleTextField.textPublisher.sink { newString in + subTitleTextField.textPublisher.sink { [weak self] newString in + guard let self else { return } self.component.subTitle = newString - self.notification.subTitle = newString }.store(in: &subscribers) buttonGroupToggle.onChange = { [weak self] toggle in + guard let self else { return } if toggle.isOn { - self?.component.primaryButtonModel = nil - self?.component.secondaryButtonModel = nil - self?.notification.primaryButtonModel = nil - self?.notification.secondaryButtonModel = nil - - self?.label.text = "" + self.component.primaryButtonModel = nil + self.component.secondaryButtonModel = nil + self.label.text = "" } else { - self?.setupButtons(with: self?.firstButtonDefaultText, secondButtonText: self?.secondButtonDefaultText) + self.setupButtons(with: self.firstButtonDefaultText, secondButtonText: self.secondButtonDefaultText) } } - firstButtonTextField.textPublisher.sink { newString in - + firstButtonTextField.textPublisher.sink { [weak self] newString in + guard let self else { return } if newString.isEmpty { self.component.primaryButtonModel = nil self.component.secondaryButtonModel = nil @@ -107,38 +94,30 @@ class NotificationViewController: BaseViewController { }.store(in: &subscribers) - secondButtonTextField.textPublisher.sink { newString in + secondButtonTextField.textPublisher.sink { [weak self] newString in + guard let self else { return } if !(self.firstButtonTextField.text?.isEmpty ?? true){ self.setupButtons(secondButtonText: newString) } }.store(in: &subscribers) hideCloseButtonToggle.onChange = { [weak self] toggle in - self?.component.hideCloseButton = toggle.isOn - self?.notification.hideCloseButton = toggle.isOn + guard let self else { return } + self.component.hideCloseButton = toggle.isOn } } func setupPicker() { surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in - self?.component.surface = item - self?.notification.surface = item - self?.contentTopView.backgroundColor = item.color + guard let self else { return } + self.component.surface = item + self.contentTopView.backgroundColor = item.color } notificationTypePickerSelectorView.onPickerDidSelect = { [weak self] item in - self?.component.style = item - self?.notification.style = item - } - - layoutTypePickerSelectorView.onPickerDidSelect = { [weak self] item in guard let self else { return } - self.component.layout = item - self.notification.layout = item - if self.component.layout != item { - self.layoutTypePickerSelectorView.set(item: self.component.layout) - } + self.component.style = item } } @@ -147,18 +126,12 @@ class NotificationViewController: BaseViewController { component.primaryButtonModel = .init(text: firstButtonText, onClick: { [weak self] button in self?.label.text = "\(button.text!) button click" }) - notification.primaryButtonModel = .init(text: firstButtonText, onClick: { [weak self] button in - self?.label.text = "\(button.text!) button click" - }) } if let secondButtonText { component.secondaryButtonModel = .init(text: secondButtonText, onClick: { [weak self] button in self?.label.text = "\(button.text!) button click" }) - notification.secondaryButtonModel = .init(text: secondButtonText, onClick: { [weak self] button in - self?.label.text = "\(button.text!) button click" - }) } } } diff --git a/VDSSample/ViewControllers/PaginationViewController.swift b/VDSSample/ViewControllers/PaginationViewController.swift new file mode 100644 index 0000000..47a5807 --- /dev/null +++ b/VDSSample/ViewControllers/PaginationViewController.swift @@ -0,0 +1,48 @@ +// +// PaginationViewController.swift +// VDSSample +// +// Created by Bandaru, Krishna Kishore on 01/03/24. +// + +import UIKit +import VDS + +final class PaginationViewController: BaseViewController { + + var totalPagesTextField = NumericField() + var selectedPageTextField = NumericField() + + override func viewDidLoad() { + super.viewDidLoad() + + addContentTopView(view: component) + totalPagesTextField.text = "10" + component.total = 10 + } + + override func setupForm(){ + super.setupForm() + addFormRow(label: "Surface", view: surfacePickerSelectorView) + addFormRow(label: "Total pages", view: totalPagesTextField) + addFormRow(label: "Selected page", view: selectedPageTextField) + setUpPublishers() + } + + func setUpPublishers() { + surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.component.surface = item + self?.contentTopView.backgroundColor = item.color + } + totalPagesTextField + .numberPublisher + .sink { [weak self] number in + self?.component.total = number?.intValue ?? 0 + }.store(in: &subscribers) + selectedPageTextField + .numberPublisher + .sink { [weak self] number in + self?.component.selectedPage = number?.intValue ?? 0 + }.store(in: &subscribers) + } +} diff --git a/VDSSample/ViewControllers/TextAreaViewController.swift b/VDSSample/ViewControllers/TextAreaViewController.swift index fea64dd..379ce8b 100644 --- a/VDSSample/ViewControllers/TextAreaViewController.swift +++ b/VDSSample/ViewControllers/TextAreaViewController.swift @@ -5,7 +5,6 @@ // Created by Matt Bruce on 1/10/23. // -import Foundation import Foundation import UIKit import VDS @@ -23,28 +22,38 @@ class TextAreaViewController: BaseViewController