diff --git a/Sources/TripKitUI/views/TKUICardActions.swift b/Sources/TripKitUI/views/TKUICardActions.swift index 61e4d2714b5..a63998e972d 100644 --- a/Sources/TripKitUI/views/TKUICardActions.swift +++ b/Sources/TripKitUI/views/TKUICardActions.swift @@ -18,6 +18,27 @@ public enum TKUICardActionNormalStyle { /// Uses `.tkLabelPrimary` as the foreground colour, `.clear` as the background colour and adds /// an outline around the button of `.tkLabelPrimary` with 0.1 opacity case outline + + /// Uses the accent colour (`.tkAppTintColor` in cards) as the foreground colour, and also as the + /// background colour with an opacity of 0.15 + case fadedTint +} + +extension TKUICardActionNormalStyle { + var foregroundColor: Color { + switch self { + case .monochrome, .outline: Color(uiColor: .tkLabelPrimary) + case .fadedTint: .accentColor + } + } + + var backgroundColor: Color { + switch self { + case .monochrome: Color(uiColor: .tertiarySystemFill) + case .outline: .clear + case .fadedTint: Color.accentColor.opacity(0.15) + } + } } class TKUICardActionHandlerInfo where C: TGCard { @@ -143,12 +164,12 @@ struct TKUICardActionButton: View where C: TGCard { .foregroundColor( action.content.style == .bold ? (UIColor.tkAppTintColor.isDark ? .white : .black) - : Color(uiColor: .tkLabelPrimary) + : normalStyle.foregroundColor ) .background( action.content.style == .bold ? Color.accentColor - : (normalStyle == .monochrome ? Color(uiColor: .tertiarySystemFill) : .clear) + : normalStyle.backgroundColor ) .clipShape(Capsule()) .background( diff --git a/Tests/TripKitUITests/TKUICardActionNormalStyleTest.swift b/Tests/TripKitUITests/TKUICardActionNormalStyleTest.swift new file mode 100644 index 00000000000..09e0b4e813a --- /dev/null +++ b/Tests/TripKitUITests/TKUICardActionNormalStyleTest.swift @@ -0,0 +1,37 @@ +// +// TKUICardActionNormalStyleTest.swift +// TripKitUITests +// +// Created by Adrian Schönig on 30/11/2026. +// Copyright © 2026 SkedGo Pty Ltd. All rights reserved. +// + +import SwiftUI +import Testing + +@testable import TripKit +@testable import TripKitUI + +@MainActor +@Suite("Card action normal styles") +struct TKUICardActionNormalStyleTest { + + @Test("Faded tint uses the accent colour") + func fadedTint() { + #expect(TKUICardActionNormalStyle.fadedTint.foregroundColor == .accentColor) + #expect(TKUICardActionNormalStyle.fadedTint.backgroundColor == Color.accentColor.opacity(0.15)) + } + + @Test("Monochrome uses the label colour on a fill") + func monochrome() { + #expect(TKUICardActionNormalStyle.monochrome.foregroundColor == Color(uiColor: .tkLabelPrimary)) + #expect(TKUICardActionNormalStyle.monochrome.backgroundColor == Color(uiColor: .tertiarySystemFill)) + } + + @Test("Outline uses the label colour without a fill") + func outline() { + #expect(TKUICardActionNormalStyle.outline.foregroundColor == Color(uiColor: .tkLabelPrimary)) + #expect(TKUICardActionNormalStyle.outline.backgroundColor == .clear) + } + +}