Files
swiftapp/swift/Sources/Core/Design/IdPTokens.swift
Jürgen Kunz 61a0cc1f7d
Some checks failed
CI / test (push) Has been cancelled
Overhaul native approval UX and add widget surfaces
Bring the SwiftUI app in line with the Apple-native mock and keep pending approvals actionable from Live Activities and watch complications.
2026-04-19 16:29:13 +02:00

110 lines
2.6 KiB
Swift

import SwiftUI
#if os(macOS)
import AppKit
#elseif canImport(UIKit)
import UIKit
#endif
public enum IdP {
public static let tint = Color("IdPTint")
public static let cardRadius: CGFloat = 22
public static let controlRadius: CGFloat = 14
public static let badgeRadius: CGFloat = 8
static func horizontalPadding(compact: Bool) -> CGFloat {
compact ? 16 : 24
}
static func verticalPadding(compact: Bool) -> CGFloat {
compact ? 16 : 24
}
}
extension Color {
static var idpGroupedBackground: Color {
#if os(macOS)
Color(nsColor: .windowBackgroundColor)
#elseif os(watchOS)
.black
#else
Color(uiColor: .systemGroupedBackground)
#endif
}
static var idpSecondaryGroupedBackground: Color {
#if os(macOS)
Color(nsColor: .controlBackgroundColor)
#elseif os(watchOS)
Color.white.opacity(0.08)
#else
Color(uiColor: .secondarySystemGroupedBackground)
#endif
}
static var idpTertiaryFill: Color {
#if os(macOS)
Color(nsColor: .quaternaryLabelColor).opacity(0.08)
#elseif os(watchOS)
Color.white.opacity(0.12)
#else
Color(uiColor: .tertiarySystemFill)
#endif
}
static var idpSeparator: Color {
#if os(macOS)
Color(nsColor: .separatorColor)
#elseif os(watchOS)
Color.white.opacity(0.14)
#else
Color(uiColor: .separator)
#endif
}
}
extension View {
func idpScreenPadding(compact: Bool) -> some View {
padding(.horizontal, IdP.horizontalPadding(compact: compact))
.padding(.vertical, IdP.verticalPadding(compact: compact))
}
@ViewBuilder
func idpInlineNavigationTitle() -> some View {
#if os(macOS)
self
#else
navigationBarTitleDisplayMode(.inline)
#endif
}
@ViewBuilder
func idpTabBarChrome() -> some View {
#if os(macOS)
self
#else
toolbarBackground(.visible, for: .tabBar)
.toolbarBackground(.regularMaterial, for: .tabBar)
#endif
}
@ViewBuilder
func idpSearchable(text: Binding<String>, isPresented: Binding<Bool>) -> some View {
#if os(macOS)
searchable(text: text, isPresented: isPresented)
#else
searchable(text: text, isPresented: isPresented, placement: .navigationBarDrawer(displayMode: .always))
#endif
}
}
extension ToolbarItemPlacement {
static var idpTrailingToolbar: ToolbarItemPlacement {
#if os(macOS)
.primaryAction
#else
.topBarTrailing
#endif
}
}