From ac8d4e707ba6ba4c672240a10fdebb2f55878caa Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 29 Mar 2023 13:48:09 -0500 Subject: [PATCH] updated buttonbase other buttons Signed-off-by: Matt Bruce --- VDS/Components/Buttons/Button/Button.swift | 4 +++- VDS/Components/Buttons/Button/ButtonBase.swift | 2 +- VDS/Components/Buttons/TextLink/TextLink.swift | 4 +++- VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/VDS/Components/Buttons/Button/Button.swift b/VDS/Components/Buttons/Button/Button.swift index 0b52e0fe..13823178 100644 --- a/VDS/Components/Buttons/Button/Button.swift +++ b/VDS/Components/Buttons/Button/Button.swift @@ -17,7 +17,7 @@ public enum ButtonSize: String, CaseIterable { } @objc(VDSButton) -open class Button: ButtonBase, Useable { +open class Button: ButtonBase, Useable, Clickable { //-------------------------------------------------- // MARK: - Private Properties @@ -30,6 +30,8 @@ open class Button: ButtonBase, Useable { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var onClick: ((Button) -> ())? { didSet { setupOnClick() } } + open override var availableSizes: [ButtonSize] { [.large, .small] } open var use: Use = .primary { didSet { didChange() }} diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index 61b628ce..b8f2d098 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -29,7 +29,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab //-------------------------------------------------- public var subject = PassthroughSubject() public var subscribers = Set() - open var onClickSubscriber: AnyCancellable? { + internal var onClickSubscriber: AnyCancellable? { willSet { if let onClickSubscriber { onClickSubscriber.cancel() diff --git a/VDS/Components/Buttons/TextLink/TextLink.swift b/VDS/Components/Buttons/TextLink/TextLink.swift index a253a406..3d0ec706 100644 --- a/VDS/Components/Buttons/TextLink/TextLink.swift +++ b/VDS/Components/Buttons/TextLink/TextLink.swift @@ -12,7 +12,7 @@ import VDSFormControlsTokens import Combine @objc(VDSTextLink) -open class TextLink: ButtonBase { +open class TextLink: ButtonBase, Clickable { //-------------------------------------------------- // MARK: - Private Properties @@ -22,6 +22,8 @@ open class TextLink: ButtonBase { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var onClick: ((TextLink) -> ())? { didSet { setupOnClick() } } + open var size: ButtonSize = .large { didSet { didChange() }} open override var availableSizes: [ButtonSize] { [.large, .small] } diff --git a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift index f6ba09a0..a5521a4e 100644 --- a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift +++ b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift @@ -12,7 +12,7 @@ import VDSFormControlsTokens import Combine @objc(VDSTextLinkCaret) -open class TextLinkCaret: ButtonBase { +open class TextLinkCaret: ButtonBase, Clickable { //-------------------------------------------------- // MARK: - Enums @@ -24,6 +24,8 @@ open class TextLinkCaret: ButtonBase { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- + open var onClick: ((TextLinkCaret) -> ())? { didSet { setupOnClick() } } + open override var textStyle: TextStyle { TextStyle.boldBodyLarge }