Repository Public License
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : ORIX Camera9// File : Packages/ORIXCameraKit/Sources/ORIXDesign/Components.swift10// Description : Reusable ORIX components: cards, buttons, chips, section11// headers, empty states, banners, progress, the mark.12// Module : ORIXDesign13// Repository : https://git.spboucher.ai/orix-camera14// Project Website : https://www.orixlab.dev15// Created : 2026-11-2116// Last Modified : 2026-11-2117//18// =============================================================================19// AUTHOR & PROFESSIONAL AFFILIATION20// =============================================================================21//22// Author : Simon-Pierre Boucher23// Position : Professor of Finance24// Institution : Université du Québec en Outaouais (UQO)25// Department : Département des sciences administratives26// Organization : SP Boucher27//28// Website : https://spboucher.ai29// Git : https://git.spboucher.ai30//31// =============================================================================32// OFFICIAL CONTACT DIRECTORY33// =============================================================================34//35// General : info@spboucher.ai36// Professional : contact@spboucher.ai37// Direct : simon@spboucher.ai38// Research : research@spboucher.ai39// Development : dev@spboucher.ai40// Support : support@spboucher.ai41// Security/Admin : admin@spboucher.ai42// Notifications : notifications@spboucher.ai43//44// Preferred Contact: support@spboucher.ai45//46// =============================================================================47// COPYRIGHT & INTELLECTUAL PROPERTY48// =============================================================================49//50// Copyright (c) 202651// Simon-Pierre Boucher52//53// All rights reserved where applicable.54//55// This file is governed by the applicable project license,56// copyright notices, institutional agreements and relevant law.57//58// Unless expressly authorized by the applicable license or59// rights holder, copying, redistribution, sublicensing,60// publication and commercial exploitation are not permitted.61//62// Existing third-party rights and notices remain unaffected.63//64// =============================================================================65// CONFIDENTIALITY & SECURITY66// =============================================================================67//68// Classification : Public69// Distribution : Public repository; use is governed by the project license70// Security Contact : admin@spboucher.ai71//72// Access to this source does not independently grant permission73// to redistribute or disclose confidential materials.74//75// Do not embed credentials, private keys, access tokens,76// certificates or confidential personal information.77//78// =============================================================================79// LICENSE & MAINTENANCE80// =============================================================================81//82// License : Proprietary, all rights reserved (see license file)83// License File : LICENSE84// Maintainer : Simon-Pierre Boucher85// Technical Contact: dev@spboucher.ai86//87// =============================================================================88// END OF SP BOUCHER SOURCE HEADER89// =============================================================================9091import SwiftUI9293// MARK: Surfaces9495public struct ORIXCard: ViewModifier {96 var padding: CGFloat97 public func body(content: Content) -> some View {98 content99 .padding(padding)100 .background(ORIX.Palette.surface, in: RoundedRectangle(cornerRadius: ORIX.Radius.card, style: .continuous))101 .overlay(RoundedRectangle(cornerRadius: ORIX.Radius.card, style: .continuous).strokeBorder(ORIX.Palette.hairline.opacity(0.7), lineWidth: 0.5))102 }103}104105public extension View {106 /// Standard ORIX card surface.107 func orixCard(padding: CGFloat = ORIX.Space.md) -> some View { modifier(ORIXCard(padding: padding)) }108109 /// The soft, low shadow used under document pages and floating controls. One elevation only: ORIX stays flat elsewhere.110 func orixLift(_ enabled: Bool = true) -> some View {111 shadow(color: .black.opacity(enabled ? 0.14 : 0), radius: 10, x: 0, y: 4)112 }113}114115// MARK: Buttons116117/// The primary call to action: accent gradient, large target.118public struct ORIXPrimaryButtonStyle: ButtonStyle {119 @Environment(\.orixAccent) private var accent120 @Environment(\.isEnabled) private var isEnabled121 public init() {}122 public func makeBody(configuration: Configuration) -> some View {123 configuration.label124 .font(.orixHeadline)125 .foregroundStyle(ORIX.Palette.onAccent)126 .frame(maxWidth: .infinity, minHeight: 52)127 .padding(.horizontal, ORIX.Space.md)128 .background(accent.gradient, in: RoundedRectangle(cornerRadius: ORIX.Radius.control, style: .continuous))129 .opacity(isEnabled ? (configuration.isPressed ? 0.85 : 1) : 0.45)130 .scaleEffect(configuration.isPressed ? 0.98 : 1)131 .animation(ORIX.Motion.quick, value: configuration.isPressed)132 }133}134135/// Secondary action: tinted fill.136public struct ORIXSecondaryButtonStyle: ButtonStyle {137 @Environment(\.orixAccent) private var accent138 @Environment(\.isEnabled) private var isEnabled139 public init() {}140 public func makeBody(configuration: Configuration) -> some View {141 configuration.label142 .font(.orixHeadline)143 .foregroundStyle(accent.primary)144 .frame(maxWidth: .infinity, minHeight: 48)145 .padding(.horizontal, ORIX.Space.md)146 .background(accent.primary.opacity(configuration.isPressed ? 0.2 : 0.12), in: RoundedRectangle(cornerRadius: ORIX.Radius.control, style: .continuous))147 .opacity(isEnabled ? 1 : 0.45)148 .animation(ORIX.Motion.quick, value: configuration.isPressed)149 }150}151152/// A square tile with a symbol and a label (home quick actions, tool grids).153public struct ORIXTileButtonStyle: ButtonStyle {154 public init() {}155 public func makeBody(configuration: Configuration) -> some View {156 configuration.label157 .frame(maxWidth: .infinity, minHeight: 84)158 .padding(ORIX.Space.sm)159 .background(ORIX.Palette.surface, in: RoundedRectangle(cornerRadius: ORIX.Radius.card, style: .continuous))160 .overlay(RoundedRectangle(cornerRadius: ORIX.Radius.card, style: .continuous).strokeBorder(ORIX.Palette.hairline.opacity(0.7), lineWidth: 0.5))161 .scaleEffect(configuration.isPressed ? 0.97 : 1)162 .animation(ORIX.Motion.quick, value: configuration.isPressed)163 }164}165166public extension ButtonStyle where Self == ORIXPrimaryButtonStyle { static var orixPrimary: ORIXPrimaryButtonStyle { .init() } }167public extension ButtonStyle where Self == ORIXSecondaryButtonStyle { static var orixSecondary: ORIXSecondaryButtonStyle { .init() } }168public extension ButtonStyle where Self == ORIXTileButtonStyle { static var orixTile: ORIXTileButtonStyle { .init() } }169170/// Symbol on a tinted rounded square: the standard ORIX leading glyph for rows and tiles.171public struct ORIXGlyph: View {172 @Environment(\.orixAccent) private var accent173 let systemName: String174 var tint: Color?175 var size: CGFloat176 public init(_ systemName: String, tint: Color? = nil, size: CGFloat = 36) {177 self.systemName = systemName178 self.tint = tint179 self.size = size180 }181 public var body: some View {182 let color = tint ?? accent.primary183 Image(systemName: systemName)184 .font(.system(size: size * 0.46, weight: .semibold))185 .foregroundStyle(color)186 .frame(width: size, height: size)187 .background(color.opacity(0.13), in: RoundedRectangle(cornerRadius: size * 0.3, style: .continuous))188 .accessibilityHidden(true)189 }190}191192// MARK: Labels193194public struct ORIXSectionHeader<Trailing: View>: View {195 let title: LocalizedStringKey196 let trailing: Trailing197 public init(_ title: LocalizedStringKey, @ViewBuilder trailing: () -> Trailing = { EmptyView() }) {198 self.title = title199 self.trailing = trailing()200 }201 public var body: some View {202 HStack(alignment: .firstTextBaseline) {203 Text(title).font(.orixTitle).foregroundStyle(ORIX.Palette.textPrimary).accessibilityAddTraits(.isHeader)204 Spacer(minLength: ORIX.Space.xs)205 trailing206 }207 }208}209210/// A compact status or metadata chip.211public struct ORIXChip: View {212 let text: Text213 var systemName: String?214 var tint: Color215 public init(_ text: Text, systemName: String? = nil, tint: Color = ORIX.Palette.textSecondary) {216 self.text = text217 self.systemName = systemName218 self.tint = tint219 }220 public var body: some View {221 HStack(spacing: 4) {222 if let systemName { Image(systemName: systemName).imageScale(.small).accessibilityHidden(true) }223 text224 }225 .font(.orixCaption)226 .foregroundStyle(tint)227 .padding(.horizontal, 8)228 .padding(.vertical, 4)229 .background(tint.opacity(0.12), in: Capsule())230 }231}232233// MARK: States234235public struct ORIXEmptyState<Actions: View>: View {236 @Environment(\.orixAccent) private var accent237 let systemName: String238 let title: LocalizedStringKey239 let message: LocalizedStringKey240 let actions: Actions241 public init(systemName: String, title: LocalizedStringKey, message: LocalizedStringKey, @ViewBuilder actions: () -> Actions = { EmptyView() }) {242 self.systemName = systemName243 self.title = title244 self.message = message245 self.actions = actions()246 }247 public var body: some View {248 VStack(spacing: ORIX.Space.md) {249 ZStack {250 Circle().fill(accent.primary.opacity(0.1)).frame(width: 96, height: 96)251 Image(systemName: systemName).font(.system(size: 38, weight: .medium)).foregroundStyle(accent.primary)252 }253 .accessibilityHidden(true)254 VStack(spacing: ORIX.Space.xs) {255 Text(title).font(.orixTitle).foregroundStyle(ORIX.Palette.textPrimary).multilineTextAlignment(.center)256 Text(message).font(.orixCallout).foregroundStyle(ORIX.Palette.textSecondary).multilineTextAlignment(.center)257 }258 actions259 }260 .frame(maxWidth: 420)261 .padding(ORIX.Space.xl)262 .frame(maxWidth: .infinity, maxHeight: .infinity)263 }264}265266public enum ORIXBannerKind: Sendable { case info, success, warning, error }267268/// Inline message with an icon; never colour alone (icon and text carry the meaning).269public struct ORIXBanner<Trailing: View>: View {270 @Environment(\.orixAccent) private var accent271 let kind: ORIXBannerKind272 let title: Text273 let message: Text?274 let trailing: Trailing275 public init(_ kind: ORIXBannerKind, title: Text, message: Text? = nil, @ViewBuilder trailing: () -> Trailing = { EmptyView() }) {276 self.kind = kind277 self.title = title278 self.message = message279 self.trailing = trailing()280 }281 private var tint: Color {282 switch kind { case .info: accent.primary; case .success: ORIX.Palette.success; case .warning: ORIX.Palette.warning; case .error: ORIX.Palette.danger }283 }284 private var symbol: String {285 switch kind {286 case .info: "info.circle.fill"; case .success: "checkmark.circle.fill"287 case .warning: "exclamationmark.triangle.fill"; case .error: "xmark.octagon.fill"288 }289 }290 public var body: some View {291 HStack(alignment: .top, spacing: ORIX.Space.sm) {292 Image(systemName: symbol).foregroundStyle(tint).font(.body.weight(.semibold)).accessibilityHidden(true)293 VStack(alignment: .leading, spacing: 2) {294 title.font(.orixHeadline).foregroundStyle(ORIX.Palette.textPrimary)295 if let message { message.font(.orixCallout).foregroundStyle(ORIX.Palette.textSecondary) }296 }297 Spacer(minLength: 0)298 trailing299 }300 .padding(ORIX.Space.sm)301 .background(tint.opacity(0.1), in: RoundedRectangle(cornerRadius: ORIX.Radius.control, style: .continuous))302 .accessibilityElement(children: .combine)303 }304}305306/// Determinate progress with a label and the ORIX beam colour.307public struct ORIXProgressBar: View {308 @Environment(\.orixAccent) private var accent309 let value: Double310 public init(value: Double) { self.value = value }311 public var body: some View {312 GeometryReader { proxy in313 ZStack(alignment: .leading) {314 Capsule().fill(ORIX.Palette.surfaceRaised)315 Capsule()316 .fill(LinearGradient(colors: [accent.primary, accent.secondary], startPoint: .leading, endPoint: .trailing))317 .frame(width: max(6, proxy.size.width * min(max(value, 0), 1)))318 }319 }320 .frame(height: 6)321 .animation(ORIX.Motion.standard, value: value)322 .accessibilityElement()323 .accessibilityValue(Text(value, format: .percent.precision(.fractionLength(0))))324 }325}326327// MARK: Mark328329/// The ORIX Camera mark drawn in code: the "O" ring opened at the upper right by an amber exposure index, around a lens.330/// Same geometry as the app icon (design/icon/build.py): ring radius 268, stroke 100, lens radius 118 on a 1024 grid.331public struct ORIXMark: View {332 @Environment(\.orixAccent) private var accent333 var ring: Color?334 public init(ring: Color? = nil) { self.ring = ring }335 public var body: some View {336 Canvas { context, size in337 let side = min(size.width, size.height)338 let unit = side / 1024339 let center = CGPoint(x: size.width / 2, y: size.height / 2)340 let radius = 268 * unit341 let style = StrokeStyle(lineWidth: 100 * unit, lineCap: .round)342 // Angles are measured clockwise from 12 o'clock; Canvas measures from 3 o'clock, hence the −90°.343 func arc(_ from: Double, _ to: Double) -> Path {344 var path = Path()345 path.addArc(center: center, radius: radius, startAngle: .degrees(from - 90), endAngle: .degrees(to - 90), clockwise: false)346 return path347 }348 context.stroke(arc(98, 352), with: .color(ring ?? accent.primary), style: style)349 context.stroke(arc(20, 70), with: .color(accent.secondary), style: style)350 let lens = 118 * unit351 context.fill(Path(ellipseIn: CGRect(x: center.x - lens, y: center.y - lens, width: lens * 2, height: lens * 2)), with: .color(ring ?? accent.primary))352 }353 .aspectRatio(1, contentMode: .fit)354 .accessibilityHidden(true)355 }356}357