Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions Sources/TripKitUI/views/TKUICardActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<C, M> where C: TGCard {
Expand Down Expand Up @@ -143,12 +164,12 @@ struct TKUICardActionButton<C, M>: 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(
Expand Down
37 changes: 37 additions & 0 deletions Tests/TripKitUITests/TKUICardActionNormalStyleTest.swift
Original file line number Diff line number Diff line change
@@ -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)
}

}
Loading