diff --git a/VDSSample/ViewControllers/ButtonIconViewController.swift b/VDSSample/ViewControllers/ButtonIconViewController.swift index 1fae6a2..971c45a 100644 --- a/VDSSample/ViewControllers/ButtonIconViewController.swift +++ b/VDSSample/ViewControllers/ButtonIconViewController.swift @@ -49,7 +49,10 @@ class ButtonIconViewController: BaseViewController { items: ButtonIcon.Size.allCases) }() - var customSizeField = NumericField() + var customContainerSizeField = NumericField() + var customIconSizeField = NumericField() + var customBadgeIndicatorXField = NumericField() + var customBadgeIndicatorYField = NumericField() var centerX = NumericField() var centerY = NumericField() var fitToIcon = Toggle() @@ -123,8 +126,17 @@ class ButtonIconViewController: BaseViewController { addFormRow(label: "Show Badge Indicator", view: badgeIndicatorSwitch) badgeIndicatorFormStackView.addFormRow(label: "Expand Direction", view: badgeIndicatorExpandDirectionPickerSelectorView) 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) + //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 self?.setBadgeIndicatorModel() } @@ -158,12 +170,30 @@ class ButtonIconViewController: BaseViewController { self?.component.fitToIcon = sender.isOn } - customSizeField + customContainerSizeField .numberPublisher .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) + centerX .numberPublisher .sink { [weak self] _ in @@ -177,6 +207,15 @@ class ButtonIconViewController: BaseViewController { }.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() { let name = Icon.Name.addToFavorite