Merge branch 'feature/Clickable' into 'develop'

updated notification

See merge request BPHV_MIPS/vds_ios_sample!28
This commit is contained in:
Bruce, Matt R 2023-03-30 15:13:03 +00:00
commit 7046a58b63
9 changed files with 163 additions and 38 deletions

View File

@ -33,6 +33,7 @@
/* Begin PBXBuildFile section */
44604AD929CE1CF900E62B51 /* LineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD829CE1CF900E62B51 /* LineViewController.swift */; };
445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 445BA07929C088470036A7C5 /* NotificationViewController.swift */; };
5FC35BE928D5235A004EBEAC /* ButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */; };
EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */; };
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9C289966EF000CA526 /* AppDelegate.swift */; };
@ -115,6 +116,7 @@
/* Begin PBXFileReference section */
44604AD829CE1CF900E62B51 /* LineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineViewController.swift; sourceTree = "<group>"; };
445BA07929C088470036A7C5 /* NotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewController.swift; sourceTree = "<group>"; };
5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonViewController.swift; sourceTree = "<group>"; };
EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLinkCaretViewController.swift; sourceTree = "<group>"; };
EA3C3B99289966EF000CA526 /* VDSSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VDSSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -291,6 +293,7 @@
EAC9257F29119FC400091998 /* TextLinkViewController.swift */,
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
44604AD829CE1CF900E62B51 /* LineViewController.swift */,
445BA07929C088470036A7C5 /* NotificationViewController.swift */,
EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */,
EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */,
EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */,
@ -456,6 +459,7 @@
EA3C3BB628996775000CA526 /* MenuViewController.swift in Sources */,
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */,
EA5E3050294D11540082B959 /* TileContainerViewController.swift in Sources */,
445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */,
EAF7F11A28A14A0E00B287F5 /* RadioButtonViewController.swift in Sources */,
EA89204628B66CE2006B9984 /* ScrollViewController.swift in Sources */,
EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */,

View File

@ -26,19 +26,18 @@ extension UIView {
extension ButtonBase {
func labelPublisher(_ label: UILabel){
publisher(for: .touchUpInside)
.sink { control in
let newText = "\(control.text!) clicked - "
if let labelText = label.text {
let components = labelText.components(separatedBy: " - ")
let last: String = (components.last ?? "0").trimmingCharacters(in: .whitespaces)
let count = Int(last)!
label.text = "\(newText)\(count+1)"
} else {
label.text = "\(newText)1"
}
print("clicked me")
}.store(in: &subscribers)
onClick = { control in
let newText = "\(control.text!) clicked - "
if let labelText = label.text {
let components = labelText.components(separatedBy: " - ")
let last: String = (components.last ?? "0").trimmingCharacters(in: .whitespaces)
let count = Int(last)!
label.text = "\(newText)\(count+1)"
} else {
label.text = "\(newText)1"
}
print("clicked me")
}
}
}

View File

@ -74,16 +74,14 @@ public class PickerSelectorView<EnumType: RawRepresentable>: UIStackView, Picker
updateSelectedIndex()
addArrangedSubview(label)
addArrangedSubview(button)
button
.publisher(for: .touchUpInside)
.sink { [weak self] _ in
self?.picker?.delegate = self
self?.picker?.dataSource = self
self?.picker?.reloadAllComponents()
self?.picker?.selectRow(self?.selectedIndex ?? 0, inComponent: 0, animated: false)
self?.picker?.isHidden = false
self?.scrollToBottom?()
}.store(in: &subscribers)
button.onClick = { [weak self] _ in
self?.picker?.delegate = self
self?.picker?.dataSource = self
self?.picker?.reloadAllComponents()
self?.picker?.selectRow(self?.selectedIndex ?? 0, inComponent: 0, animated: false)
self?.picker?.isHidden = false
self?.scrollToBottom?()
}
}
func updateSelectedIndex() {

View File

@ -48,7 +48,7 @@ class ButtonViewController: BaseViewController {
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Use", view: usePickerSelectorView)
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))
addFormRow(label: "Label", view: textField)
addFormRow(label: "Text", view: textField)
addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "Size", view: buttonSizePickerSelectorView)

View File

@ -19,7 +19,7 @@ class CheckboxViewController: BaseViewController {
var errorTextField = TextField()
var showErrorSwitch = Toggle()
var checkbox = SoloCheckbox()
var checkbox = Checkbox()
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -80,6 +80,7 @@ class MenuViewController: UITableViewController {
MenuComponent(title: "InputField", completed: false, viewController: InputFieldViewController.self),
MenuComponent(title: "Label", completed: true, viewController: LabelViewController.self),
MenuComponent(title: "Line", completed: false, viewController: LineViewController.self),
MenuComponent(title: "Notification", completed: false, viewController: NotificationViewController.self),
MenuComponent(title: "RadioBoxGroup", completed: true, viewController: RadioBoxGroupViewController.self),
MenuComponent(title: "RadioButtonGroup", completed: true, viewController: RadioButtonViewController.self),
MenuComponent(title: "RadioSwatchGroup", completed: true, viewController: RadioSwatchGroupViewController.self),

View File

@ -0,0 +1,126 @@
//
// NotificationViewController.swift
// VDSSample
//
// Created by Nadigadda, Sumanth on 14/03/23.
//
import Foundation
import VDS
class NotificationViewController: BaseViewController {
var notificationView = Notification()
let label = Label()
let titleTextField = TextField()
let subTitleTextField = TextField()
let buttonGroupToggle = Toggle()
let firstButtonTextField = TextField()
let secondButtonTextField = TextField()
let titleDefaultText = "This is title"
let subtitleDefaultText = "This is subtitle"
let firstButtonDefaultText = "Button 1"
let secondButtonDefaultText = "Button 2"
lazy var notificationTypePickerSelectorView = {
PickerSelectorView(title: "Info",
picker: self.picker,
items: Notification.NotificationStyle.allCases)
}()
override func viewDidLoad() {
super.viewDidLoad()
notificationView.titleText = titleDefaultText
notificationView.subTitleText = subtitleDefaultText
titleTextField.text = titleDefaultText
subTitleTextField.text = subtitleDefaultText
setupButtons(with: firstButtonDefaultText, secondButtonText: secondButtonDefaultText)
firstButtonTextField.text = firstButtonDefaultText
secondButtonTextField.text = secondButtonDefaultText
addContentTopView(view: notificationView)
setupForm()
setupPicker()
}
func setupForm() {
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Style", view: notificationTypePickerSelectorView)
addFormRow(label: "Title", view: titleTextField)
addFormRow(label: "SubTitle", view: subTitleTextField)
addFormRow(label: "Hide Button Group", view: buttonGroupToggle)
addFormRow(label: "Button Action", view: label)
addFormRow(label: "First Button Text", view: firstButtonTextField)
addFormRow(label: "Second Button Text", view: secondButtonTextField)
notificationView.onCloseClick = { notification in
print("onCloseClick: \(notification.titleText)")
}
titleTextField.textPublisher.sink { newString in
self.notificationView.titleText = newString
}.store(in: &subscribers)
subTitleTextField.textPublisher.sink { newString in
self.notificationView.subTitleText = newString
}.store(in: &subscribers)
buttonGroupToggle.publisher(for: .valueChanged).sink { [weak self] toggle in
if toggle.isOn {
self?.notificationView.primaryButtonModel = nil
self?.notificationView.secondaryButtonModel = nil
self?.label.text = ""
} else {
self?.setupButtons(with: self?.firstButtonDefaultText, secondButtonText: self?.secondButtonDefaultText)
}
}.store(in: &subscribers)
firstButtonTextField.textPublisher.sink { newString in
if newString.isEmpty {
self.notificationView.primaryButtonModel = nil
self.notificationView.secondaryButtonModel = nil
} else {
self.setupButtons(with: newString, secondButtonText: self.secondButtonTextField.text)
}
}.store(in: &subscribers)
secondButtonTextField.textPublisher.sink { newString in
if !(self.firstButtonTextField.text?.isEmpty ?? true){
self.setupButtons(secondButtonText: newString)
}
}.store(in: &subscribers)
}
func setupPicker() {
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.notificationView.surface = item
self?.contentTopView.backgroundColor = item.color
}
notificationTypePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.notificationView.type = item
}
}
func setupButtons(with firstButtonText: String? = nil, secondButtonText: String? = nil) {
if let firstButtonText {
notificationView.primaryButtonModel = .init(text: firstButtonText, onClick: { [weak self] button in
self?.label.text = "\(button.text!) button click"
})
}
if let secondButtonText {
notificationView.secondaryButtonModel = .init(text: secondButtonText, onClick: { [weak self] button in
self?.label.text = "\(button.text!) button click"
})
}
}
}

View File

@ -36,7 +36,6 @@ class TileContainerViewController: BaseViewController {
}()
var clickableSwitch = Toggle()
var clickableCancel: AnyCancellable?
var showBackgroundImageSwitch = Toggle()
var showBorderSwitch = Toggle()
@ -78,15 +77,13 @@ class TileContainerViewController: BaseViewController {
clickableSwitch
.publisher(for: .valueChanged)
.sink { [weak self] sender in
guard let self else { return }
if sender.isOn {
self?.clickableCancel = self?.tileContainer
.publisher(for: .touchUpInside)
.sink(receiveValue: { _ in
print("you click on me!")
})
self.tileContainer.onClick = { _ in
print("you click on me!")
}
} else {
self?.clickableCancel?.cancel()
self?.clickableCancel = nil
self.tileContainer.onClick = nil
}
}.store(in: &subscribers)

View File

@ -79,13 +79,13 @@ class TileletViewController: BaseViewController {
.sink { [weak self] sender in
guard let tilelet = self?.tilelet else { return }
if sender.isOn {
tilelet.onClickSubscriber = tilelet.publisher(for: .touchUpInside)
.sink(receiveValue: { _ in
print("you click on me!")
})
tilelet.onClick = { t in
print("you click on me!")
}
} else {
tilelet.onClick = nil
}
}.store(in: &subscribers)
widthTextField
.textPublisher
.sink { [weak self] text in