Repository Public License
1// ORIX Alarm2// File: App/Design/Theme.swift3// Description: Design system: ORIX Alarm palette, typography, aurora background, glass surfaces, buttons and chips.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import SwiftUI89enum Theme {10 // Night11 static let midnight = Color(red: 0.027, green: 0.035, blue: 0.086)12 static let deepIndigo = Color(red: 0.071, green: 0.063, blue: 0.196)13 static let indigo = Color(red: 0.180, green: 0.160, blue: 0.450)14 static let violet = Color(red: 0.478, green: 0.361, blue: 0.980)15 static let azure = Color(red: 0.330, green: 0.560, blue: 1.000)16 // Sunrise17 static let ember = Color(red: 0.980, green: 0.360, blue: 0.290)18 static let sunrise = Color(red: 1.000, green: 0.560, blue: 0.260)19 static let gold = Color(red: 1.000, green: 0.790, blue: 0.420)20 static let peach = Color(red: 1.000, green: 0.870, blue: 0.760)21 // Semantic22 static let success = Color(red: 0.360, green: 0.880, blue: 0.640)23 static let danger = Color(red: 1.000, green: 0.400, blue: 0.450)24 static let textPrimary = Color.white25 static let textSecondary = Color.white.opacity(0.66)26 static let textTertiary = Color.white.opacity(0.42)27 static let hairline = Color.white.opacity(0.10)28 static let surface = Color.white.opacity(0.06)29 static let surfaceRaised = Color.white.opacity(0.11)3031 static let sunriseGradient = LinearGradient(colors: [ember, sunrise, gold], startPoint: .bottomLeading, endPoint: .topTrailing)32 static let nightGradient = LinearGradient(colors: [violet, azure], startPoint: .topLeading, endPoint: .bottomTrailing)33 static let cornerRadius: CGFloat = 2434 static let spacing: CGFloat = 163536 /// Sky colour for a sunrise progress of 0 (night) ... 1 (full daylight): deep blue, then violet, ember, warm gold.37 static func sky(_ progress: Double) -> [Color] {38 let p = min(max(progress, 0), 1)39 func mix(_ a: Color, _ b: Color, _ t: Double) -> Color { a.mix(with: b, by: min(max(t, 0), 1)) }40 let top = p < 0.5 ? mix(midnight, indigo, p * 2) : mix(indigo, Color(red: 0.55, green: 0.62, blue: 0.86), (p - 0.5) * 2)41 let middle = p < 0.5 ? mix(deepIndigo, Color(red: 0.55, green: 0.25, blue: 0.55), p * 2) : mix(Color(red: 0.55, green: 0.25, blue: 0.55), sunrise, (p - 0.5) * 2)42 let bottom = p < 0.4 ? mix(deepIndigo, ember, p / 0.4) : mix(ember, peach, (p - 0.4) / 0.6)43 return [top, middle, bottom]44 }45}4647extension Font {48 /// Large clock digits: rounded, light, monospaced digits.49 static func clock(_ size: CGFloat, weight: Font.Weight = .light) -> Font { .system(size: size, weight: weight, design: .rounded).monospacedDigit() }50 static let orixTitle = Font.system(.title2, design: .rounded, weight: .semibold)51 static let orixHeadline = Font.system(.headline, design: .rounded, weight: .semibold)52 static let orixBody = Font.system(.body, design: .rounded)53 static let orixCaption = Font.system(.caption, design: .rounded, weight: .medium)54 static let orixOverline = Font.system(.caption2, design: .rounded, weight: .bold)55}5657/// Full-screen animated night sky with slow aurora glows. `warmth` (0...1) blends towards sunrise colours.58struct AuroraBackground: View {59 var warmth: Double = 060 @Environment(\.accessibilityReduceMotion) private var reduceMotion6162 var body: some View {63 TimelineView(.animation(minimumInterval: 1 / 20, paused: reduceMotion)) { context in64 let t = reduceMotion ? 0 : context.date.timeIntervalSinceReferenceDate65 Canvas { ctx, size in66 ctx.fill(Path(CGRect(origin: .zero, size: size)), with: .linearGradient(67 Gradient(colors: Theme.sky(warmth * 0.9)), startPoint: .zero, endPoint: CGPoint(x: 0, y: size.height)))68 let glows: [(Color, Double, Double, Double)] = [69 (Theme.violet, 0.22, 0.18, 0.55), (Theme.azure, 0.80, 0.30, 0.45), (warmth > 0.3 ? Theme.sunrise : Theme.indigo, 0.50, 0.92, 0.70),70 ]71 for (i, glow) in glows.enumerated() {72 let phase = t / 14 + Double(i) * 2.173 let x = (glow.1 + 0.08 * sin(phase)) * size.width74 let y = (glow.2 + 0.05 * cos(phase * 0.8)) * size.height75 let radius = glow.3 * size.width76 ctx.fill(Path(ellipseIn: CGRect(x: x - radius, y: y - radius, width: radius * 2, height: radius * 2)),77 with: .radialGradient(Gradient(colors: [glow.0.opacity(0.34), glow.0.opacity(0)]), center: CGPoint(x: x, y: y), startRadius: 0, endRadius: radius))78 }79 }80 }81 .ignoresSafeArea()82 .accessibilityHidden(true)83 }84}8586/// Glass-like layered surface used for cards.87struct GlassCard: ViewModifier {88 var padding: CGFloat = 1889 var radius: CGFloat = Theme.cornerRadius90 var tint: Color? = nil91 func body(content: Content) -> some View {92 content93 .padding(padding)94 .background {95 RoundedRectangle(cornerRadius: radius, style: .continuous)96 .fill((tint ?? .white).opacity(tint == nil ? 0.07 : 0.16))97 .background(.ultraThinMaterial.opacity(0.55), in: RoundedRectangle(cornerRadius: radius, style: .continuous))98 .overlay {99 RoundedRectangle(cornerRadius: radius, style: .continuous)100 .strokeBorder(LinearGradient(colors: [.white.opacity(0.28), .white.opacity(0.04)], startPoint: .topLeading, endPoint: .bottomTrailing), lineWidth: 1)101 }102 }103 }104}105106extension View {107 func glassCard(padding: CGFloat = 18, radius: CGFloat = Theme.cornerRadius, tint: Color? = nil) -> some View {108 modifier(GlassCard(padding: padding, radius: radius, tint: tint))109 }110 /// Standard screen chrome: aurora background, dark scheme, rounded navigation titles.111 func orixScreen(warmth: Double = 0) -> some View {112 self.scrollContentBackground(.hidden)113 .background { AuroraBackground(warmth: warmth) }114 .toolbarBackground(.hidden, for: .navigationBar)115 .preferredColorScheme(.dark)116 }117}118119/// Prominent sunrise-gradient button.120struct PrimaryButtonStyle: ButtonStyle {121 var gradient: LinearGradient = Theme.sunriseGradient122 @Environment(\.isEnabled) private var isEnabled123 func makeBody(configuration: Configuration) -> some View {124 configuration.label125 .font(.orixHeadline)126 .foregroundStyle(Theme.midnight)127 .frame(maxWidth: .infinity, minHeight: 54)128 .background(gradient, in: Capsule())129 .opacity(isEnabled ? 1 : 0.4)130 .scaleEffect(configuration.isPressed ? 0.97 : 1)131 .animation(.snappy(duration: 0.18), value: configuration.isPressed)132 }133}134135struct SecondaryButtonStyle: ButtonStyle {136 func makeBody(configuration: Configuration) -> some View {137 configuration.label138 .font(.orixHeadline)139 .foregroundStyle(Theme.textPrimary)140 .frame(maxWidth: .infinity, minHeight: 54)141 .background(Theme.surfaceRaised, in: Capsule())142 .overlay(Capsule().strokeBorder(Theme.hairline))143 .scaleEffect(configuration.isPressed ? 0.97 : 1)144 .animation(.snappy(duration: 0.18), value: configuration.isPressed)145 }146}147148/// Selectable capsule chip (weekdays, options).149struct Chip: View {150 let title: String151 var symbol: String? = nil152 let isSelected: Bool153 let action: () -> Void154 var body: some View {155 Button(action: action) {156 HStack(spacing: 6) {157 if let symbol { Image(systemName: symbol).imageScale(.small) }158 Text(title)159 }160 .font(.orixCaption)161 .padding(.horizontal, 14).frame(minHeight: 36)162 .foregroundStyle(isSelected ? Theme.midnight : Theme.textPrimary)163 .background(isSelected ? AnyShapeStyle(Theme.sunriseGradient) : AnyShapeStyle(Theme.surfaceRaised), in: Capsule())164 .overlay(Capsule().strokeBorder(isSelected ? .clear : Theme.hairline))165 }166 .buttonStyle(.plain)167 .accessibilityAddTraits(isSelected ? .isSelected : [])168 }169}170171/// Small uppercase section label.172struct Overline: View {173 let text: String174 init(_ text: String) { self.text = text }175 var body: some View {176 Text(text.uppercased()).font(.orixOverline).kerning(1.2).foregroundStyle(Theme.textTertiary)177 .frame(maxWidth: .infinity, alignment: .leading).accessibilityAddTraits(.isHeader)178 }179}180