Repository Public BSD-3-Clause
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : ORIX Maps9// File : Apps/ORIXMaps/Sources/Panel/PanelHost.swift10// Module : Panel11// Repository : https://git.spboucher.ai/orix-maps12// Created : 2026-11-2513// Last Modified : 2026-11-2514//15// =============================================================================16// AUTHOR & PROFESSIONAL AFFILIATION17// =============================================================================18//19// Author : Simon-Pierre Boucher20// Position : Professor of Finance21// Institution : Université du Québec en Outaouais (UQO)22// Department : Département des sciences administratives23// Organization : SP Boucher24//25// Website : https://spboucher.ai26// Git : https://git.spboucher.ai27//28// =============================================================================29// OFFICIAL CONTACT DIRECTORY30// =============================================================================31//32// General : info@spboucher.ai33// Professional : contact@spboucher.ai34// Direct : simon@spboucher.ai35// Research : research@spboucher.ai36// Development : dev@spboucher.ai37// Support : support@spboucher.ai38// Security/Admin : admin@spboucher.ai39// Notifications : notifications@spboucher.ai40//41// Preferred Contact: support@spboucher.ai42//43// =============================================================================44// COPYRIGHT & INTELLECTUAL PROPERTY45// =============================================================================46//47// Copyright (c) 202648// Simon-Pierre Boucher49//50// All rights reserved where applicable.51//52// This file is governed by the applicable project license,53// copyright notices, institutional agreements and relevant law.54//55// Unless expressly authorized by the applicable license or56// rights holder, copying, redistribution, sublicensing,57// publication and commercial exploitation are not permitted.58//59// Existing third-party rights and notices remain unaffected.60//61// =============================================================================62// CONFIDENTIALITY & SECURITY63// =============================================================================64//65// Classification : Public66// Distribution : Public repository; use is governed by the project license67// Security Contact : admin@spboucher.ai68//69// Access to this source does not independently grant permission70// to redistribute or disclose confidential materials.71//72// Do not embed credentials, private keys, access tokens,73// certificates or confidential personal information.74//75// =============================================================================76// LICENSE & MAINTENANCE77// =============================================================================78//79// License : Proprietary, all rights reserved (see license file)80// License File : LICENSE81// Maintainer : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import ORIXDesignSystem89import SwiftUI9091/// Content of the panel for the current route.92struct PanelHost: View {93 @Environment(AppModel.self) private var app94 @Binding var detent: PresentationDetent9596 var body: some View {97 Group {98 switch app.route {99 case .home: HomePanel(detent: $detent)100 case .place(let place): PlaceCard(place: place)101 case .measure: MeasurePanel()102 case .trackRecording: TrackPanel()103 case .directions: DirectionsPanel()104 case .navigation: NavigationPanel()105 }106 }107 .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)108 }109}110111/// Sheets opened from the menu.112struct ModalHost: View {113 @Environment(AppModel.self) private var app114 let route: ModalRoute115116 var body: some View {117 NavigationStack {118 Group {119 switch route {120 case .layers: LayersScreen()121 case .downloads: DownloadsScreen()122 case .collections: CollectionsScreen()123 case .tracks: TracksScreen()124 case .explorer: ExplorerScreen()125 case .planner: PlannerScreen()126 case .settings: SettingsScreen()127 case .about: AboutScreen()128 case .compass: CompassScreen()129 case .studio: ThemeListScreen()130 }131 }132 .toolbar {133 ToolbarItem(placement: .confirmationAction) {134 Button("Done") { app.modal = nil }.accessibilityIdentifier("modal.done")135 }136 }137 }138 .presentationDetents(route == .layers ? [.medium, .large] : [.large])139 }140}141142/// Fills of the buttons that carry white text. They are the same in light and dark: the bright accent of the dark143/// appearance is right for text and icons on dark surfaces, but white text on it is not readable.144enum AppColor {145 static let primaryFill = Color("PrimaryFill")146 static let dangerFill = Color("DangerFill")147}148149/// A row that becomes a column at accessibility text sizes, where side-by-side items no longer fit.150struct AdaptiveStack<Content: View>: View {151 @Environment(\.dynamicTypeSize) private var size152 var spacing: CGFloat = ORIX.Spacing.s153 @ViewBuilder var content: Content154155 var body: some View {156 let layout = size.isAccessibilitySize ? AnyLayout(VStackLayout(alignment: .leading, spacing: spacing)) : AnyLayout(HStackLayout(spacing: spacing))157 layout { content }158 }159}160161/// Header of every card: title, optional subtitle and a close button.162struct PanelHeader: View {163 let title: String164 var subtitle: String?165 let onClose: () -> Void166167 var body: some View {168 HStack(alignment: .top, spacing: ORIX.Spacing.m) {169 VStack(alignment: .leading, spacing: 2) {170 Text(title).font(.title2.weight(.bold)).lineLimit(2).accessibilityAddTraits(.isHeader).accessibilityIdentifier("panel.title")171 if let subtitle, !subtitle.isEmpty { Text(subtitle).font(.subheadline).foregroundStyle(.secondary).lineLimit(2).accessibilityIdentifier("panel.subtitle") }172 }173 Spacer(minLength: 0)174 Button(action: onClose) {175 Image(systemName: "xmark")176 .font(.system(size: 13, weight: .bold))177 .foregroundStyle(.secondary)178 .frame(width: 32, height: 32)179 .background(.quaternary, in: .circle)180 .frame(width: ORIX.minimumTarget, height: ORIX.minimumTarget)181 .contentShape(.rect)182 }183 .buttonStyle(.plain)184 .accessibilityLabel("Close")185 .accessibilityIdentifier("panel.close")186 }187 }188}189