diff --git a/.gitignore b/.gitignore index ff08f71..852dd15 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,7 @@ DerivedData/ .swiftpm/ *Generated/ Package.resolved -.swiftlint/ \ No newline at end of file +.swiftlint/ + +# SwiftLint Remote Config Cache +.swiftlint/RemoteConfigCache \ No newline at end of file diff --git a/Sources/Core/Enum/Public/ButtonIntent.swift b/Sources/Core/Enum/Public/ButtonIntent.swift index efd21f5..9398198 100644 --- a/Sources/Core/Enum/Public/ButtonIntent.swift +++ b/Sources/Core/Enum/Public/ButtonIntent.swift @@ -21,4 +21,5 @@ public enum ButtonIntent: CaseIterable { case success case support case surface + case surfaceInverse } diff --git a/Sources/Core/Extension/ControlStateText+Extension.swift b/Sources/Core/Extension/ControlStateText+Extension.swift new file mode 100644 index 0000000..83534f5 --- /dev/null +++ b/Sources/Core/Extension/ControlStateText+Extension.swift @@ -0,0 +1,16 @@ +// +// ControlStateText+Extension.swift +// SparkComponentButton +// +// Created by robin.lemaire on 18/09/2025. +// Copyright © 2025 Leboncoin. All rights reserved. +// + +@_spi(SI_SPI) import SparkCommon + +extension ControlStateText { + + var isText: Bool { + self.text != nil || self.attributedText != nil + } +} diff --git a/Sources/Core/UseCase/GetBorder/ButtonGetBorderUseCase.swift b/Sources/Core/UseCase/GetBorder/ButtonGetBorderUseCase.swift index c843df5..6688c81 100644 --- a/Sources/Core/UseCase/GetBorder/ButtonGetBorderUseCase.swift +++ b/Sources/Core/UseCase/GetBorder/ButtonGetBorderUseCase.swift @@ -12,9 +12,11 @@ import SparkTheming // sourcery: AutoMockable, AutoMockTest protocol ButtonGetBorderUseCaseable { // sourcery: border = "Identical" - func execute(shape: ButtonShape, - border: any Border, - variant: ButtonVariant) -> ButtonBorder + func execute( + shape: ButtonShape, + border: any Border, + variant: ButtonVariant + ) -> ButtonBorder } struct ButtonGetBorderUseCase: ButtonGetBorderUseCaseable { diff --git a/Sources/Core/UseCase/GetColors/ButtonGetColorsUseCase.swift b/Sources/Core/UseCase/GetColors/ButtonGetColorsUseCase.swift index bd52d37..c91172a 100644 --- a/Sources/Core/UseCase/GetColors/ButtonGetColorsUseCase.swift +++ b/Sources/Core/UseCase/GetColors/ButtonGetColorsUseCase.swift @@ -11,9 +11,11 @@ import SparkTheming // sourcery: AutoMockable, AutoMockTest protocol ButtonGetColorsUseCaseable { // sourcery: theme = "Identical" - func execute(theme: any Theme, - intent: ButtonIntent, - variant: ButtonVariant) -> ButtonColors + func execute( + theme: any Theme, + intent: ButtonIntent, + variant: ButtonVariant + ) -> ButtonColors } struct ButtonGetColorsUseCase: ButtonGetColorsUseCaseable { diff --git a/Sources/Core/UseCase/GetCurrentColors/ButtonGetCurrentColorsUseCase.swift b/Sources/Core/UseCase/GetCurrentColors/ButtonGetCurrentColorsUseCase.swift index 2dedb32..9225867 100644 --- a/Sources/Core/UseCase/GetCurrentColors/ButtonGetCurrentColorsUseCase.swift +++ b/Sources/Core/UseCase/GetCurrentColors/ButtonGetCurrentColorsUseCase.swift @@ -8,8 +8,10 @@ // sourcery: AutoMockable, AutoMockTest protocol ButtonGetCurrentColorsUseCaseable { - func execute(colors: ButtonColors, - isPressed: Bool) -> ButtonCurrentColors + func execute( + colors: ButtonColors, + isPressed: Bool + ) -> ButtonCurrentColors } struct ButtonGetCurrentColorsUseCase: ButtonGetCurrentColorsUseCaseable { diff --git a/Sources/Core/UseCase/GetSizes/ButtonGetSizesUseCase.swift b/Sources/Core/UseCase/GetSizes/ButtonGetSizesUseCase.swift index 858b80c..82a5736 100644 --- a/Sources/Core/UseCase/GetSizes/ButtonGetSizesUseCase.swift +++ b/Sources/Core/UseCase/GetSizes/ButtonGetSizesUseCase.swift @@ -10,8 +10,10 @@ import Foundation // sourcery: AutoMockable, AutoMockTest protocol ButtonGetSizesUseCaseable { - func execute(size: ButtonSize, - type: ButtonType) -> ButtonSizes + func execute( + size: ButtonSize, + type: ButtonType + ) -> ButtonSizes } struct ButtonGetSizesUseCase: ButtonGetSizesUseCaseable { diff --git a/Sources/Core/UseCase/GetState/ButtonGetStateUseCase.swift b/Sources/Core/UseCase/GetState/ButtonGetStateUseCase.swift index 186c436..84eab5b 100644 --- a/Sources/Core/UseCase/GetState/ButtonGetStateUseCase.swift +++ b/Sources/Core/UseCase/GetState/ButtonGetStateUseCase.swift @@ -11,8 +11,10 @@ import SparkTheming // sourcery: AutoMockable, AutoMockTest protocol ButtonGetStateUseCaseable { // sourcery: dims = "Identical" - func execute(isEnabled: Bool, - dims: any Dims) -> ButtonState + func execute( + isEnabled: Bool, + dims: any Dims + ) -> ButtonState } struct ButtonGetStateUseCase: ButtonGetStateUseCaseable { diff --git a/Sources/Core/UseCase/GetVariants/ButtonGetVariantContrastUseCase.swift b/Sources/Core/UseCase/GetVariants/ButtonGetVariantContrastUseCase.swift index 1b4eb07..1b03861 100644 --- a/Sources/Core/UseCase/GetVariants/ButtonGetVariantContrastUseCase.swift +++ b/Sources/Core/UseCase/GetVariants/ButtonGetVariantContrastUseCase.swift @@ -24,65 +24,73 @@ struct ButtonVariantGetContrastUseCase: ButtonGetVariantUseCaseable { switch intent { case .accent: return .init( - foregroundColor: colors.accent.accent, + foregroundColor: colors.accent.onAccentContainer, backgroundColor: backgroundColor, pressedBackgroundColor: colors.states.accentContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) + case .alert: + return .init( + foregroundColor: colors.feedback.onAlertContainer, + backgroundColor: backgroundColor, + pressedBackgroundColor: colors.states.alertContainerPressed, + borderColor: borderColor, + pressedBorderColor: pressedBorderColor + ) case .basic: return .init( - foregroundColor: colors.basic.basic, + foregroundColor: colors.basic.onBasicContainer, backgroundColor: backgroundColor, pressedBackgroundColor: colors.states.basicContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .main: + case .danger: return .init( - foregroundColor: colors.main.main, + foregroundColor: colors.feedback.onErrorContainer, backgroundColor: backgroundColor, - pressedBackgroundColor: colors.states.mainContainerPressed, + pressedBackgroundColor: colors.states.errorContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .support: + case .info: return .init( - foregroundColor: colors.support.support, + foregroundColor: colors.feedback.onInfoContainer, backgroundColor: backgroundColor, - pressedBackgroundColor: colors.states.supportContainerPressed, + pressedBackgroundColor: colors.states.infoContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .neutral: + case .main: return .init( - foregroundColor: colors.feedback.neutral, + foregroundColor: colors.main.onMainContainer, backgroundColor: backgroundColor, - pressedBackgroundColor: colors.states.neutralContainerPressed, + pressedBackgroundColor: colors.states.mainContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .alert: + case .neutral: return .init( - foregroundColor: colors.feedback.alert, + foregroundColor: colors.feedback.onNeutralContainer, backgroundColor: backgroundColor, - pressedBackgroundColor: colors.states.alertContainerPressed, + pressedBackgroundColor: colors.states.neutralContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) case .success: return .init( - foregroundColor: colors.feedback.success, + foregroundColor: colors.feedback.onSuccessContainer, backgroundColor: backgroundColor, pressedBackgroundColor: colors.states.successContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .danger: + case .support: return .init( - foregroundColor: colors.feedback.error, + foregroundColor: colors.support.onSupportContainer, backgroundColor: backgroundColor, - pressedBackgroundColor: colors.states.errorContainerPressed, + pressedBackgroundColor: colors.states.supportContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) @@ -94,11 +102,11 @@ struct ButtonVariantGetContrastUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .info: + case .surfaceInverse: return .init( - foregroundColor: colors.feedback.info, - backgroundColor: backgroundColor, - pressedBackgroundColor: colors.states.infoContainerPressed, + foregroundColor: colors.base.onSurfaceInverse, + backgroundColor: colors.base.surfaceInverse, + pressedBackgroundColor: colors.states.surfaceInversePressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) diff --git a/Sources/Core/UseCase/GetVariants/ButtonGetVariantFilledUseCase.swift b/Sources/Core/UseCase/GetVariants/ButtonGetVariantFilledUseCase.swift index 99b5b01..6219040 100644 --- a/Sources/Core/UseCase/GetVariants/ButtonGetVariantFilledUseCase.swift +++ b/Sources/Core/UseCase/GetVariants/ButtonGetVariantFilledUseCase.swift @@ -29,6 +29,14 @@ struct ButtonGetVariantFilledUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) + case .alert: + return .init( + foregroundColor: colors.feedback.onAlert, + backgroundColor: colors.feedback.alert, + pressedBackgroundColor: colors.states.alertPressed, + borderColor: borderColor, + pressedBorderColor: pressedBorderColor + ) case .basic: return .init( foregroundColor: colors.basic.onBasic, @@ -37,35 +45,35 @@ struct ButtonGetVariantFilledUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .main: + case .danger: return .init( - foregroundColor: colors.main.onMain, - backgroundColor: colors.main.main, - pressedBackgroundColor: colors.states.mainPressed, + foregroundColor: colors.feedback.onError, + backgroundColor: colors.feedback.error, + pressedBackgroundColor: colors.states.errorPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .support: + case .info: return .init( - foregroundColor: colors.support.onSupport, - backgroundColor: colors.support.support, - pressedBackgroundColor: colors.states.supportPressed, + foregroundColor: colors.feedback.onInfo, + backgroundColor: colors.feedback.info, + pressedBackgroundColor: colors.states.infoPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .neutral: + case .main: return .init( - foregroundColor: colors.feedback.onNeutral, - backgroundColor: colors.feedback.neutral, - pressedBackgroundColor: colors.states.neutralPressed, + foregroundColor: colors.main.onMain, + backgroundColor: colors.main.main, + pressedBackgroundColor: colors.states.mainPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .alert: + case .neutral: return .init( - foregroundColor: colors.feedback.onAlert, - backgroundColor: colors.feedback.alert, - pressedBackgroundColor: colors.states.alertPressed, + foregroundColor: colors.feedback.onNeutral, + backgroundColor: colors.feedback.neutral, + pressedBackgroundColor: colors.states.neutralPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) @@ -77,11 +85,11 @@ struct ButtonGetVariantFilledUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .danger: + case .support: return .init( - foregroundColor: colors.feedback.onError, - backgroundColor: colors.feedback.error, - pressedBackgroundColor: colors.states.errorPressed, + foregroundColor: colors.support.onSupport, + backgroundColor: colors.support.support, + pressedBackgroundColor: colors.states.supportPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) @@ -93,11 +101,11 @@ struct ButtonGetVariantFilledUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .info: + case .surfaceInverse: return .init( - foregroundColor: colors.feedback.onInfo, - backgroundColor: colors.feedback.info, - pressedBackgroundColor: colors.states.infoPressed, + foregroundColor: colors.base.onSurfaceInverse, + backgroundColor: colors.base.surfaceInverse, + pressedBackgroundColor: colors.states.surfaceInversePressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) diff --git a/Sources/Core/UseCase/GetVariants/ButtonGetVariantGhostUseCase.swift b/Sources/Core/UseCase/GetVariants/ButtonGetVariantGhostUseCase.swift index ea4f9b5..ccb30ab 100644 --- a/Sources/Core/UseCase/GetVariants/ButtonGetVariantGhostUseCase.swift +++ b/Sources/Core/UseCase/GetVariants/ButtonGetVariantGhostUseCase.swift @@ -25,65 +25,73 @@ struct ButtonGetVariantGhostUseCase: ButtonGetVariantUseCaseable { switch intent { case .accent: return .init( - foregroundColor: colors.accent.accent, + foregroundColor: colors.accent.onAccentContainer, backgroundColor: ColorTokenDefault.clear, pressedBackgroundColor: colors.accent.accent.opacity(dim5), borderColor: borderColor, pressedBorderColor: pressedBorderColor ) + case .alert: + return .init( + foregroundColor: colors.feedback.onAlertContainer, + backgroundColor: ColorTokenDefault.clear, + pressedBackgroundColor: colors.feedback.alert.opacity(dim5), + borderColor: borderColor, + pressedBorderColor: pressedBorderColor + ) case .basic: return .init( - foregroundColor: colors.basic.basic, + foregroundColor: colors.basic.onBasicContainer, backgroundColor: ColorTokenDefault.clear, pressedBackgroundColor: colors.basic.basic.opacity(dim5), borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .main: + case .danger: return .init( - foregroundColor: colors.main.main, + foregroundColor: colors.feedback.onErrorContainer, backgroundColor: ColorTokenDefault.clear, - pressedBackgroundColor: colors.main.main.opacity(dim5), + pressedBackgroundColor: colors.feedback.error.opacity(dim5), borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .support: + case .info: return .init( - foregroundColor: colors.support.support, + foregroundColor: colors.feedback.onInfoContainer, backgroundColor: ColorTokenDefault.clear, - pressedBackgroundColor: colors.support.support.opacity(dim5), + pressedBackgroundColor: colors.feedback.info.opacity(dim5), borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .neutral: + case .main: return .init( - foregroundColor: colors.feedback.neutral, + foregroundColor: colors.main.onMainContainer, backgroundColor: ColorTokenDefault.clear, - pressedBackgroundColor: colors.feedback.neutral.opacity(dim5), + pressedBackgroundColor: colors.main.main.opacity(dim5), borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .alert: + case .neutral: return .init( - foregroundColor: colors.feedback.alert, + foregroundColor: colors.feedback.onNeutralContainer, backgroundColor: ColorTokenDefault.clear, - pressedBackgroundColor: colors.feedback.alert.opacity(dim5), + pressedBackgroundColor: colors.feedback.neutral.opacity(dim5), borderColor: borderColor, pressedBorderColor: pressedBorderColor ) case .success: return .init( - foregroundColor: colors.feedback.success, + foregroundColor: colors.feedback.onSuccessContainer, backgroundColor: ColorTokenDefault.clear, pressedBackgroundColor: colors.feedback.success.opacity(dim5), borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .danger: + case .support: return .init( - foregroundColor: colors.feedback.error, + foregroundColor: colors.support.onSupportContainer, backgroundColor: ColorTokenDefault.clear, - pressedBackgroundColor: colors.feedback.error.opacity(dim5), + pressedBackgroundColor: colors.support.support.opacity(dim5), borderColor: borderColor, pressedBorderColor: pressedBorderColor ) @@ -95,11 +103,11 @@ struct ButtonGetVariantGhostUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .info: + case .surfaceInverse: return .init( - foregroundColor: colors.feedback.info, + foregroundColor: colors.base.surfaceInverse, backgroundColor: ColorTokenDefault.clear, - pressedBackgroundColor: colors.feedback.info.opacity(dim5), + pressedBackgroundColor: colors.base.surfaceInverse.opacity(dim5), borderColor: borderColor, pressedBorderColor: pressedBorderColor ) diff --git a/Sources/Core/UseCase/GetVariants/ButtonGetVariantOutlinedUseCase.swift b/Sources/Core/UseCase/GetVariants/ButtonGetVariantOutlinedUseCase.swift index 8ac4977..05db50a 100644 --- a/Sources/Core/UseCase/GetVariants/ButtonGetVariantOutlinedUseCase.swift +++ b/Sources/Core/UseCase/GetVariants/ButtonGetVariantOutlinedUseCase.swift @@ -30,6 +30,14 @@ struct ButtonGetVariantOutlinedUseCase: ButtonGetVariantUseCaseable { borderColor: colors.accent.accent, pressedBorderColor: colors.accent.accent ) + case .alert: + return .init( + foregroundColor: colors.feedback.alert, + backgroundColor: backgroundColor, + pressedBackgroundColor: colors.feedback.alert.opacity(dim5), + borderColor: colors.feedback.alert, + pressedBorderColor: colors.feedback.alert + ) case .basic: return .init( foregroundColor: colors.basic.basic, @@ -38,6 +46,22 @@ struct ButtonGetVariantOutlinedUseCase: ButtonGetVariantUseCaseable { borderColor: colors.basic.basic, pressedBorderColor: colors.basic.basic ) + case .danger: + return .init( + foregroundColor: colors.feedback.error, + backgroundColor: backgroundColor, + pressedBackgroundColor: colors.feedback.error.opacity(dim5), + borderColor: colors.feedback.error, + pressedBorderColor: colors.feedback.error + ) + case .info: + return .init( + foregroundColor: colors.feedback.info, + backgroundColor: backgroundColor, + pressedBackgroundColor: colors.feedback.info.opacity(dim5), + borderColor: colors.feedback.info, + pressedBorderColor: colors.feedback.info + ) case .main: return .init( foregroundColor: colors.main.main, @@ -46,14 +70,6 @@ struct ButtonGetVariantOutlinedUseCase: ButtonGetVariantUseCaseable { borderColor: colors.main.main, pressedBorderColor: colors.main.main ) - case .support: - return .init( - foregroundColor: colors.support.support, - backgroundColor: backgroundColor, - pressedBackgroundColor: colors.support.support.opacity(dim5), - borderColor: colors.support.support, - pressedBorderColor: colors.support.support - ) case .neutral: return .init( foregroundColor: colors.feedback.neutral, @@ -62,14 +78,6 @@ struct ButtonGetVariantOutlinedUseCase: ButtonGetVariantUseCaseable { borderColor: colors.feedback.neutral, pressedBorderColor: colors.feedback.neutral ) - case .alert: - return .init( - foregroundColor: colors.feedback.alert, - backgroundColor: backgroundColor, - pressedBackgroundColor: colors.feedback.alert.opacity(dim5), - borderColor: colors.feedback.alert, - pressedBorderColor: colors.feedback.alert - ) case .success: return .init( foregroundColor: colors.feedback.success, @@ -78,13 +86,13 @@ struct ButtonGetVariantOutlinedUseCase: ButtonGetVariantUseCaseable { borderColor: colors.feedback.success, pressedBorderColor: colors.feedback.success ) - case .danger: + case .support: return .init( - foregroundColor: colors.feedback.error, + foregroundColor: colors.support.support, backgroundColor: backgroundColor, - pressedBackgroundColor: colors.feedback.error.opacity(dim5), - borderColor: colors.feedback.error, - pressedBorderColor: colors.feedback.error + pressedBackgroundColor: colors.support.support.opacity(dim5), + borderColor: colors.support.support, + pressedBorderColor: colors.support.support ) case .surface: return .init( @@ -94,13 +102,13 @@ struct ButtonGetVariantOutlinedUseCase: ButtonGetVariantUseCaseable { borderColor: colors.base.surface, pressedBorderColor: colors.base.surface ) - case .info: + case .surfaceInverse: return .init( - foregroundColor: colors.feedback.info, + foregroundColor: colors.base.surfaceInverse, backgroundColor: backgroundColor, - pressedBackgroundColor: colors.feedback.info.opacity(dim5), - borderColor: colors.feedback.info, - pressedBorderColor: colors.feedback.info + pressedBackgroundColor: colors.base.surfaceInverse.opacity(dim5), + borderColor: colors.base.surfaceInverse, + pressedBorderColor: colors.base.surfaceInverse ) } } diff --git a/Sources/Core/UseCase/GetVariants/ButtonGetVariantTintedUseCase.swift b/Sources/Core/UseCase/GetVariants/ButtonGetVariantTintedUseCase.swift index 8125136..f873da6 100644 --- a/Sources/Core/UseCase/GetVariants/ButtonGetVariantTintedUseCase.swift +++ b/Sources/Core/UseCase/GetVariants/ButtonGetVariantTintedUseCase.swift @@ -29,6 +29,14 @@ struct ButtonGetVariantTintedUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) + case .alert: + return .init( + foregroundColor: colors.feedback.onAlertContainer, + backgroundColor: colors.feedback.alertContainer, + pressedBackgroundColor: colors.states.alertContainerPressed, + borderColor: borderColor, + pressedBorderColor: pressedBorderColor + ) case .basic: return .init( foregroundColor: colors.basic.onBasicContainer, @@ -37,35 +45,35 @@ struct ButtonGetVariantTintedUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .main: + case .danger: return .init( - foregroundColor: colors.main.onMainContainer, - backgroundColor: colors.main.mainContainer, - pressedBackgroundColor: colors.states.mainContainerPressed, + foregroundColor: colors.feedback.onErrorContainer, + backgroundColor: colors.feedback.errorContainer, + pressedBackgroundColor: colors.states.errorContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .support: + case .info: return .init( - foregroundColor: colors.support.onSupportContainer, - backgroundColor: colors.support.supportContainer, - pressedBackgroundColor: colors.states.supportContainerPressed, + foregroundColor: colors.feedback.onInfoContainer, + backgroundColor: colors.feedback.infoContainer, + pressedBackgroundColor: colors.states.infoContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .neutral: + case .main: return .init( - foregroundColor: colors.feedback.onNeutralContainer, - backgroundColor: colors.feedback.neutralContainer, - pressedBackgroundColor: colors.states.neutralContainerPressed, + foregroundColor: colors.main.onMainContainer, + backgroundColor: colors.main.mainContainer, + pressedBackgroundColor: colors.states.mainContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .alert: + case .neutral: return .init( - foregroundColor: colors.feedback.onAlertContainer, - backgroundColor: colors.feedback.alertContainer, - pressedBackgroundColor: colors.states.alertContainerPressed, + foregroundColor: colors.feedback.onNeutralContainer, + backgroundColor: colors.feedback.neutralContainer, + pressedBackgroundColor: colors.states.neutralContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) @@ -77,11 +85,11 @@ struct ButtonGetVariantTintedUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .danger: + case .support: return .init( - foregroundColor: colors.feedback.onErrorContainer, - backgroundColor: colors.feedback.errorContainer, - pressedBackgroundColor: colors.states.errorContainerPressed, + foregroundColor: colors.support.onSupportContainer, + backgroundColor: colors.support.supportContainer, + pressedBackgroundColor: colors.states.supportContainerPressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) @@ -93,11 +101,11 @@ struct ButtonGetVariantTintedUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) - case .info: + case .surfaceInverse: return .init( - foregroundColor: colors.feedback.onInfoContainer, - backgroundColor: colors.feedback.infoContainer, - pressedBackgroundColor: colors.states.infoContainerPressed, + foregroundColor: colors.base.surfaceInverse, + backgroundColor: ColorTokenDefault.clear, + pressedBackgroundColor: colors.states.surfaceInversePressed, borderColor: borderColor, pressedBorderColor: pressedBorderColor ) diff --git a/Sources/Core/View/SwiftUI/Internal/ButtonContainerView.swift b/Sources/Core/View/SwiftUI/Internal/ButtonContainerView.swift index e0a0236..53ba75e 100644 --- a/Sources/Core/View/SwiftUI/Internal/ButtonContainerView.swift +++ b/Sources/Core/View/SwiftUI/Internal/ButtonContainerView.swift @@ -49,8 +49,8 @@ struct ButtonContainerView: if let image = self.image { image.resizable() .aspectRatio(contentMode: .fit) - .scaledFrame( + .sparkFrame( width: self.size, height: self.size, alignment: .center diff --git a/Sources/Core/View/SwiftUI/Public/Button/ButtonView.swift b/Sources/Core/View/SwiftUI/Public/Button/ButtonView.swift index bb3de33..dcfea48 100644 --- a/Sources/Core/View/SwiftUI/Public/Button/ButtonView.swift +++ b/Sources/Core/View/SwiftUI/Public/Button/ButtonView.swift @@ -67,7 +67,7 @@ public struct ButtonView: View { ButtonContainerView( viewModel: self.viewModel, padding: .init( - horizontal: self.horizontalSpacing + horizontal: self.viewModel.controlStateText?.isText == true ? self.horizontalSpacing : .zero ), action: self.action ) { @@ -116,6 +116,8 @@ public struct ButtonView: View { Text(attributedText) .accessibilityIdentifier(ButtonAccessibilityIdentifier.text) .animation(nil, value: attributedText) + } else { + EmptyView() } } diff --git a/Sources/Core/View/UIKit/Button/ButtonUIView.swift b/Sources/Core/View/UIKit/Button/ButtonUIView.swift index ffdbdc7..f851af1 100644 --- a/Sources/Core/View/UIKit/Button/ButtonUIView.swift +++ b/Sources/Core/View/UIKit/Button/ButtonUIView.swift @@ -299,9 +299,16 @@ public final class ButtonUIView: ButtonMainUIView { // MARK: - Data Did Update - private func spacingsDidUpdate(_ spacings: ButtonSpacings) { - self.horizontalSpacing = spacings.horizontalSpacing + private func spacingsDidUpdate(_ spacings: ButtonSpacings? = nil) { + guard let spacings = spacings ?? self.viewModel.spacings else { + return + } + + self.horizontalSpacing = self.titleLabel.isHidden ? .zero : spacings.horizontalSpacing + self._horizontalSpacing.update(traitCollection: self.traitCollection) + self.horizontalPadding = spacings.horizontalPadding + self._horizontalPadding.update(traitCollection: self.traitCollection) self.updateSpacings() } @@ -355,7 +362,9 @@ public final class ButtonUIView: ButtonMainUIView { // ** // Is Text ? self.titleStateLabel.$isText.subscribe(in: &self.subscriptions) { [weak self] isText in - self?.titleLabel.isHidden = !isText + guard let self else { return } + self.titleLabel.isHidden = !isText + self.spacingsDidUpdate() } // ** diff --git a/Sources/Core/View/UIKit/Main/ButtonMainUIView.swift b/Sources/Core/View/UIKit/Main/ButtonMainUIView.swift index 24319cb..6cb8e82 100644 --- a/Sources/Core/View/UIKit/Main/ButtonMainUIView.swift +++ b/Sources/Core/View/UIKit/Main/ButtonMainUIView.swift @@ -256,7 +256,7 @@ public class ButtonMainUIView: UIControl { // MARK: - Update UI private func updateBorderRadius() { - self.setCornerRadius(self.cornerRadius) + self.sparkCornerRadius(self.cornerRadius) } private func updateBorderWidth() { @@ -305,11 +305,13 @@ public class ButtonMainUIView: UIControl { /// This method is internal because it can be overriden by the view that inherits from this class. internal func colorsDidUpdate(_ colors: ButtonCurrentColors) { // Background Color - let isAnimated = self.isAnimated && self.backgroundColor != colors.backgroundColor.uiColor + let backgroundColor: UIColor = colors.backgroundColor.uiColor + + let isAnimated = self.isAnimated && self.backgroundColor != backgroundColor let animationType: UIExecuteAnimationType = isAnimated ? .animated(duration: Animation.fastDuration) : .unanimated UIView.execute(animationType: animationType) { [weak self] in - self?.backgroundColor = colors.backgroundColor.uiColor + self?.backgroundColor = backgroundColor } // Border Color diff --git a/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-dark-medium.1.png b/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-dark-medium.1.png new file mode 100644 index 0000000..b77d4a1 Binary files /dev/null and b/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-dark-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-light-medium.1.png new file mode 100644 index 0000000..7c68ab1 Binary files /dev/null and b/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-contrastVariant-titleContent-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-contrastVariant-titleContent-normalState-light-medium.1.png index 81f6ae9..215cf3f 100644 Binary files a/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-contrastVariant-titleContent-normalState-light-medium.1.png and b/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-contrastVariant-titleContent-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-ghostVariant-titleContent-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-ghostVariant-titleContent-normalState-light-medium.1.png index f20391e..2aece0f 100644 Binary files a/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-ghostVariant-titleContent-normalState-light-medium.1.png and b/Tests/SnapshotTests/.__snapshots__/ButtonUIViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-ghostVariant-titleContent-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-dark-medium.1.png b/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-dark-medium.1.png new file mode 100644 index 0000000..23a8701 Binary files /dev/null and b/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-dark-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-light-medium.1.png new file mode 100644 index 0000000..3d1c66f Binary files /dev/null and b/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test1-surfaceInverse-leadingImageAlignment-roundedShape-mediumSize-filledVariant-titleContent-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-contrastVariant-titleContent-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-contrastVariant-titleContent-normalState-light-medium.1.png index 15cee83..fa81a7a 100644 Binary files a/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-contrastVariant-titleContent-normalState-light-medium.1.png and b/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-contrastVariant-titleContent-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-ghostVariant-titleContent-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-ghostVariant-titleContent-normalState-light-medium.1.png index 38841c2..c74b7be 100644 Binary files a/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-ghostVariant-titleContent-normalState-light-medium.1.png and b/Tests/SnapshotTests/.__snapshots__/ButtonViewSnapshotTests/test5-main-leadingImageAlignment-roundedShape-mediumSize-ghostVariant-titleContent-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-dark-medium.1.png b/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-dark-medium.1.png new file mode 100644 index 0000000..b096d00 Binary files /dev/null and b/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-dark-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-light-medium.1.png new file mode 100644 index 0000000..d68fd96 Binary files /dev/null and b/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test4-main-roundedShape-mediumSize-contrastVariant-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test4-main-roundedShape-mediumSize-contrastVariant-normalState-light-medium.1.png index 6ce7422..2278e89 100644 Binary files a/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test4-main-roundedShape-mediumSize-contrastVariant-normalState-light-medium.1.png and b/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test4-main-roundedShape-mediumSize-contrastVariant-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test4-main-roundedShape-mediumSize-ghostVariant-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test4-main-roundedShape-mediumSize-ghostVariant-normalState-light-medium.1.png index 3034810..4936cee 100644 Binary files a/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test4-main-roundedShape-mediumSize-ghostVariant-normalState-light-medium.1.png and b/Tests/SnapshotTests/.__snapshots__/IconButtonUIViewSnapshotTests/test4-main-roundedShape-mediumSize-ghostVariant-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-dark-medium.1.png b/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-dark-medium.1.png new file mode 100644 index 0000000..eab16cc Binary files /dev/null and b/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-dark-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-light-medium.1.png new file mode 100644 index 0000000..b6c8351 Binary files /dev/null and b/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test1-surfaceInverse-roundedShape-mediumSize-filledVariant-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test4-main-roundedShape-mediumSize-contrastVariant-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test4-main-roundedShape-mediumSize-contrastVariant-normalState-light-medium.1.png index bbbe0e5..49023b4 100644 Binary files a/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test4-main-roundedShape-mediumSize-contrastVariant-normalState-light-medium.1.png and b/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test4-main-roundedShape-mediumSize-contrastVariant-normalState-light-medium.1.png differ diff --git a/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test4-main-roundedShape-mediumSize-ghostVariant-normalState-light-medium.1.png b/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test4-main-roundedShape-mediumSize-ghostVariant-normalState-light-medium.1.png index 84c931d..7b5f79c 100644 Binary files a/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test4-main-roundedShape-mediumSize-ghostVariant-normalState-light-medium.1.png and b/Tests/SnapshotTests/.__snapshots__/IconButtonViewSnapshotTests/test4-main-roundedShape-mediumSize-ghostVariant-normalState-light-medium.1.png differ diff --git a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantContrastUseCaseTests.swift b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantContrastUseCaseTests.swift index 3a53590..9786aa6 100644 --- a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantContrastUseCaseTests.swift +++ b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantContrastUseCaseTests.swift @@ -29,7 +29,7 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.main.main, + [self.theme.colors.main.onMainContainer, self.theme.colors.base.surface, self.theme.colors.states.mainContainerPressed, ColorTokenDefault.clear, @@ -51,7 +51,7 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.support.support, + [self.theme.colors.support.onSupportContainer, self.theme.colors.base.surface, self.theme.colors.states.supportContainerPressed, ColorTokenDefault.clear, @@ -73,7 +73,7 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.neutral, + [self.theme.colors.feedback.onNeutralContainer, self.theme.colors.base.surface, self.theme.colors.states.neutralContainerPressed, ColorTokenDefault.clear, @@ -95,7 +95,7 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.alert, + [self.theme.colors.feedback.onAlertContainer, self.theme.colors.base.surface, self.theme.colors.states.alertContainerPressed, ColorTokenDefault.clear, @@ -117,7 +117,7 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.success, + [self.theme.colors.feedback.onSuccessContainer, self.theme.colors.base.surface, self.theme.colors.states.successContainerPressed, ColorTokenDefault.clear, @@ -139,7 +139,7 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.error, + [self.theme.colors.feedback.onErrorContainer, self.theme.colors.base.surface, self.theme.colors.states.errorContainerPressed, ColorTokenDefault.clear, @@ -169,6 +169,28 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_surfaceInverse_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .surfaceInverse, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.base.onSurfaceInverse, + self.theme.colors.base.surfaceInverse, + self.theme.colors.states.surfaceInversePressed, + ColorTokenDefault.clear, + ColorTokenDefault.clear + ].map(\.color)) + } + func test_info_colors() throws { // Given let sut = self.sut() @@ -183,7 +205,7 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.info, + [self.theme.colors.feedback.onInfoContainer, self.theme.colors.base.surface, self.theme.colors.states.infoContainerPressed, ColorTokenDefault.clear, diff --git a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantFilledUseCaseTests.swift b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantFilledUseCaseTests.swift index 95b8418..fee0e0f 100644 --- a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantFilledUseCaseTests.swift +++ b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantFilledUseCaseTests.swift @@ -169,6 +169,28 @@ final class ButtonGetVariantFilledUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_surfaceInverse_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .surfaceInverse, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.base.onSurfaceInverse, + self.theme.colors.base.surfaceInverse, + self.theme.colors.states.surfaceInversePressed, + ColorTokenDefault.clear, + ColorTokenDefault.clear + ].map(\.color)) + } + func test_info_colors() throws { // Given let sut = self.sut() diff --git a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantGhostUseCaseTests.swift b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantGhostUseCaseTests.swift index ba87b88..1936dbd 100644 --- a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantGhostUseCaseTests.swift +++ b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantGhostUseCaseTests.swift @@ -29,7 +29,7 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.main.main, + [self.theme.colors.main.onMainContainer, ColorTokenDefault.clear, self.theme.colors.main.main.opacity(self.theme.dims.dim5), ColorTokenDefault.clear, @@ -51,7 +51,7 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.support.support, + [self.theme.colors.support.onSupportContainer, ColorTokenDefault.clear, self.theme.colors.support.support.opacity(self.theme.dims.dim5), ColorTokenDefault.clear, @@ -73,7 +73,7 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.neutral, + [self.theme.colors.feedback.onNeutralContainer, ColorTokenDefault.clear, self.theme.colors.feedback.neutral.opacity(self.theme.dims.dim5), ColorTokenDefault.clear, @@ -95,7 +95,7 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.alert, + [self.theme.colors.feedback.onAlertContainer, ColorTokenDefault.clear, self.theme.colors.feedback.alert.opacity(self.theme.dims.dim5), ColorTokenDefault.clear, @@ -117,7 +117,7 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.success, + [self.theme.colors.feedback.onSuccessContainer, ColorTokenDefault.clear, self.theme.colors.feedback.success.opacity(self.theme.dims.dim5), ColorTokenDefault.clear, @@ -139,7 +139,7 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.error, + [self.theme.colors.feedback.onErrorContainer, ColorTokenDefault.clear, self.theme.colors.feedback.error.opacity(self.theme.dims.dim5), ColorTokenDefault.clear, @@ -169,6 +169,28 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_surfaceInverse_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .surfaceInverse, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.base.surfaceInverse, + ColorTokenDefault.clear, + self.theme.colors.base.surfaceInverse.opacity(self.theme.dims.dim5), + ColorTokenDefault.clear, + ColorTokenDefault.clear + ].map(\.color)) + } + func test_info_colors() throws { // Given let sut = self.sut() @@ -183,7 +205,7 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests { colors.pressedBackgroundColor, colors.borderColor, colors.pressedBorderColor].map(\.color), - [self.theme.colors.feedback.info, + [self.theme.colors.feedback.onInfoContainer, ColorTokenDefault.clear, self.theme.colors.feedback.info.opacity(self.theme.dims.dim5), ColorTokenDefault.clear, diff --git a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantOutlinedUseCaseTests.swift b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantOutlinedUseCaseTests.swift index 8a9a427..e9cdd0f 100644 --- a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantOutlinedUseCaseTests.swift +++ b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantOutlinedUseCaseTests.swift @@ -169,6 +169,28 @@ final class ButtonGetVariantOutlinedUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_surfaceInverse_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .surfaceInverse, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.base.surfaceInverse, + ColorTokenDefault.clear, + self.theme.colors.base.surfaceInverse.opacity(self.theme.dims.dim5), + self.theme.colors.base.surfaceInverse, + self.theme.colors.base.surfaceInverse + ].map(\.color)) + } + func test_info_colors() throws { // Given let sut = self.sut() diff --git a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantTintedUseCaseTests.swift b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantTintedUseCaseTests.swift index 1d998c0..77d8e62 100644 --- a/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantTintedUseCaseTests.swift +++ b/Tests/UnitTests/UseCase/GetVariants/ButtonGetVariantTintedUseCaseTests.swift @@ -169,6 +169,28 @@ final class ButtonGetVariantTintedUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_surfaceInverse_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .surfaceInverse, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.base.surfaceInverse, + ColorTokenDefault.clear, + self.theme.colors.states.surfaceInversePressed, + ColorTokenDefault.clear, + ColorTokenDefault.clear + ].map(\.color)) + } + func test_info_colors() throws { // Given let sut = self.sut()