Files
guangya_client/guangya_mac/AppTheme.swift
T

52 lines
1.9 KiB
Swift

import SwiftUI
enum AppTheme {
static let orange = Color(red: 1.0, green: 0.45, blue: 0.12)
static let orangeDeep = Color(red: 0.86, green: 0.20, blue: 0.04)
}
struct AppBackdrop: View {
@Environment(\.colorScheme) private var colorScheme
var body: some View {
LinearGradient(
colors: colorScheme == .dark
? [Color(red: 0.07, green: 0.09, blue: 0.10), Color(red: 0.09, green: 0.13, blue: 0.13), Color(red: 0.15, green: 0.10, blue: 0.08)]
: [Color(red: 0.93, green: 0.95, blue: 0.96), Color(red: 0.89, green: 0.94, blue: 0.93), Color(red: 0.97, green: 0.92, blue: 0.87)],
startPoint: .topLeading,
endPoint: .bottomTrailing
)
.overlay(alignment: .bottom) {
Rectangle()
.fill(colorScheme == .dark ? Color.orange.opacity(0.05) : Color.orange.opacity(0.08))
.frame(height: 150)
.mask(LinearGradient(colors: [.clear, .black], startPoint: .top, endPoint: .bottom))
}
.ignoresSafeArea()
}
}
private struct SoftCard: ViewModifier {
let requestedRadius: CGFloat
private var radius: CGFloat { min(requestedRadius, 8) }
@ViewBuilder
func body(content: Content) -> some View {
if #available(macOS 26.0, *) {
content
.glassEffect(.regular, in: RoundedRectangle(cornerRadius: radius, style: .continuous))
.overlay { RoundedRectangle(cornerRadius: radius, style: .continuous).stroke(.white.opacity(0.26), lineWidth: 1) }
} else {
content
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: radius, style: .continuous))
.overlay { RoundedRectangle(cornerRadius: radius, style: .continuous).stroke(.white.opacity(0.30), lineWidth: 1) }
}
}
}
extension View {
func softCard(radius: CGFloat = 8) -> some View {
modifier(SoftCard(requestedRadius: radius))
}
}