Bring the SwiftUI app in line with the Apple-native mock and keep pending approvals actionable from Live Activities and watch complications.
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user