updated smaple

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-06-13 11:19:24 -05:00
parent 5795b87b37
commit f0fb6c063c

View File

@ -49,7 +49,10 @@ class ButtonIconViewController: BaseViewController<ButtonIcon> {
items: ButtonIcon.Size.allCases) items: ButtonIcon.Size.allCases)
}() }()
var customSizeField = NumericField() var customContainerSizeField = NumericField()
var customIconSizeField = NumericField()
var customBadgeIndicatorXField = NumericField()
var customBadgeIndicatorYField = NumericField()
var centerX = NumericField() var centerX = NumericField()
var centerY = NumericField() var centerY = NumericField()
var fitToIcon = Toggle() var fitToIcon = Toggle()
@ -123,8 +126,17 @@ class ButtonIconViewController: BaseViewController<ButtonIcon> {
addFormRow(label: "Show Badge Indicator", view: badgeIndicatorSwitch) addFormRow(label: "Show Badge Indicator", view: badgeIndicatorSwitch)
badgeIndicatorFormStackView.addFormRow(label: "Expand Direction", view: badgeIndicatorExpandDirectionPickerSelectorView) badgeIndicatorFormStackView.addFormRow(label: "Expand Direction", view: badgeIndicatorExpandDirectionPickerSelectorView)
badgeIndicatorFormStackView.addFormRow(label: "Badge Variants", view: variantOneSwitch) badgeIndicatorFormStackView.addFormRow(label: "Badge Variants", view: variantOneSwitch)
badgeIndicatorFormStackView.addFormRow(label: "Custom X offset", view: customBadgeIndicatorXField)
badgeIndicatorFormStackView.addFormRow(label: "Custom Y offset", view: customBadgeIndicatorYField)
append(section: badgeIndicatorFormStackView) append(section: badgeIndicatorFormStackView)
//custom section
let custom = FormSection().with { $0.title = "Custom Settings"}
custom.addFormRow(label: "Container Size", view: customContainerSizeField)
custom.addFormRow(label: "Icon Size", view: customIconSizeField)
append(section: custom)
variantOneSwitch.onChange = { [weak self] sender in variantOneSwitch.onChange = { [weak self] sender in
self?.setBadgeIndicatorModel() self?.setBadgeIndicatorModel()
} }
@ -158,10 +170,28 @@ class ButtonIconViewController: BaseViewController<ButtonIcon> {
self?.component.fitToIcon = sender.isOn self?.component.fitToIcon = sender.isOn
} }
customSizeField customContainerSizeField
.numberPublisher .numberPublisher
.sink { [weak self] number in .sink { [weak self] number in
self?.component.customSize = number?.intValue self?.component.customContainerSize = number?.intValue
}.store(in: &subscribers)
customIconSizeField
.numberPublisher
.sink { [weak self] number in
self?.component.customIconSize = number?.intValue
}.store(in: &subscribers)
customBadgeIndicatorXField
.numberPublisher
.sink { [weak self] number in
self?.updateCustomBadgeIndicator()
}.store(in: &subscribers)
customBadgeIndicatorYField
.numberPublisher
.sink { [weak self] number in
self?.updateCustomBadgeIndicator()
}.store(in: &subscribers) }.store(in: &subscribers)
centerX centerX
@ -177,6 +207,15 @@ class ButtonIconViewController: BaseViewController<ButtonIcon> {
}.store(in: &subscribers) }.store(in: &subscribers)
} }
func updateCustomBadgeIndicator() {
if let x = customBadgeIndicatorXField.floatValue, let y = customBadgeIndicatorYField.floatValue {
component.customBadgeIndicatorOffset = .init(x: x, y: y)
} else {
component.customBadgeIndicatorOffset = nil
}
}
func setupModel() { func setupModel() {
let name = Icon.Name.addToFavorite let name = Icon.Name.addToFavorite