From 4766cf415a6f200b12f0248fd5d15cff647af900 Mon Sep 17 00:00:00 2001 From: Adrian Schoenig Date: Mon, 30 Nov 2026 21:08:43 +1100 Subject: [PATCH] feat(card-actions): bring back the faded-tint style for normal actions #414 replaced .fadedTint with .monochrome. MyWay+ and NT Bus Tracker shipped the tinted look and need to keep it, so re-add the style with its pre-#414 colours: accent-coloured text on a 15% accent fill. The normal-style colours now live on the enum, where a test covers them. Defaults are unchanged. Co-Authored-By: Claude Opus 5.5 --- Sources/TripKitUI/views/TKUICardActions.swift | 25 ++++++++++++- .../TKUICardActionNormalStyleTest.swift | 37 +++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 Tests/TripKitUITests/TKUICardActionNormalStyleTest.swift 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) + } + +}