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/Settings/SettingsScreen.swift10// Module : Settings11// 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 ORIXGeoCore90import SwiftUI9192struct SettingsScreen: View {93 @Environment(AppModel.self) private var app9495 var body: some View {96 @Bindable var s = app.settings97 Form {98 Section("Display") {99 Picker("Appearance", selection: $s.appearance) {100 Text("System").tag(AppSettings.Appearance.system)101 Text("Light").tag(AppSettings.Appearance.light)102 Text("Dark").tag(AppSettings.Appearance.dark)103 }104 Picker("Map labels", selection: $s.labelLanguage) {105 Text("Automatic").tag(AppSettings.LabelLanguage.automatic)106 Text("Local names").tag(AppSettings.LabelLanguage.local)107 Text("English").tag(AppSettings.LabelLanguage.english)108 Text("French").tag(AppSettings.LabelLanguage.french)109 }110 .onChange(of: app.settings.labelLanguage) { _, _ in app.refreshStyle() }111 Toggle("Smoother map motion (uses more battery)", isOn: $s.highFrameRate)112 .onChange(of: app.settings.highFrameRate) { _, _ in app.refreshStyle() }113 }114 Section("Units") {115 Picker("Distances", selection: $s.units) {116 Text("Metric").tag(MeasureFormatter.System.metric)117 Text("Imperial").tag(MeasureFormatter.System.imperial)118 }119 Picker("Coordinates", selection: $s.coordinateStyle) {120 Text("Decimal degrees").tag(CoordinateText.Style.decimalDegrees)121 Text("Degrees and minutes").tag(CoordinateText.Style.degreesDecimalMinutes)122 Text("Degrees, minutes, seconds").tag(CoordinateText.Style.degreesMinutesSeconds)123 Text("UTM").tag(CoordinateText.Style.utm)124 }125 }126 Section {127 Toggle("Avoid tolls", isOn: $s.avoidTolls)128 Toggle("Avoid ferries", isOn: $s.avoidFerries)129 Toggle("Avoid motorways", isOn: $s.avoidMotorways)130 Toggle("Avoid unpaved roads", isOn: $s.avoidUnpaved)131 } header: { Text("Directions") }132 Section {133 Toggle("Spoken instructions", isOn: $s.voiceGuidance)134 if app.settings.voiceGuidance {135 VStack(alignment: .leading) {136 Text("Voice volume").font(.subheadline)137 Slider(value: $s.voiceVolume, in: 0.2...1) { Text("Voice volume") }138 }139 }140 Toggle("Keep the screen on during guidance", isOn: $s.keepScreenOnDuringNavigation)141 } header: { Text("Guidance") } footer: {142 Text("Guidance is an aid. Road data can be wrong or out of date: always follow signs and traffic rules. Not for aviation, marine or emergency use.")143 }144 Section {145 NavigationLink("Privacy") { PrivacyScreen() }.accessibilityIdentifier("settings.privacy")146 NavigationLink("About and data sources") { AboutScreen() }147 }148 }149 .navigationTitle("Settings")150 .navigationBarTitleDisplayMode(.inline)151 }152}153154/// What the application does with data, stated as it behaves, with the controls to turn history off and erase it.155struct PrivacyScreen: View {156 @Environment(AppModel.self) private var app157 @State private var confirmErase = false158159 var body: some View {160 @Bindable var s = app.settings161 Form {162 Section {163 Label("No account, no advertising, no analytics.", systemImage: "person.crop.circle.badge.xmark")164 Label("Search, directions and guidance run on this device, from the maps you downloaded.", systemImage: "iphone")165 Label("The only network requests are the map catalog and the map files you choose to download. They carry no position, no search text and no identifier.", systemImage: "arrow.down.circle")166 Label("Your position is used only for the features you start: showing it on the map, guidance, recording a track.", systemImage: "location")167 } header: { Text("How ORIX Maps treats your data") }168 Section {169 Toggle("Keep recent searches and places", isOn: $s.historyEnabled)170 .accessibilityIdentifier("privacy.history")171 Button("Erase history", role: .destructive) { confirmErase = true }172 .accessibilityIdentifier("privacy.erase")173 .confirmationDialog("Erase recent searches, recent places and the last map position?", isPresented: $confirmErase, titleVisibility: .visible) {174 Button("Erase history", role: .destructive) { app.eraseHistory() }.accessibilityIdentifier("privacy.erase.confirm")175 }176 } footer: {177 Text("History stays on this device. Turning it off stops recording; erasing removes what was kept, including the last map position.")178 }179 Section("Position") {180 LabeledContent("Permission") { Text(permissionText) }181 Button("Open system settings") {182 if let url = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.open(url) }183 }184 }185 }186 .navigationTitle("Privacy")187 .navigationBarTitleDisplayMode(.inline)188 }189190 private var permissionText: LocalizedStringKey {191 switch app.location.authorization {192 case .notDetermined: "Not asked yet"193 case .denied: "Refused"194 case .restricted: "Restricted on this device"195 case .authorized(let precise): precise ? "While using the app" : "While using the app, approximate"196 }197 }198}199200/// Version, licences and the attribution of every data source.201struct AboutScreen: View {202 @Environment(AppModel.self) private var app203204 var body: some View {205 List {206 Section {207 LabeledContent("Version") { Text(verbatim: "\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "?") (\(Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "?"))") }208 LabeledContent("Publisher") { Text(verbatim: "ORIX Labs · Simon-Pierre Boucher") }209 }210 Section {211 source("OpenStreetMap", "Map data © OpenStreetMap contributors, available under the Open Database License (ODbL) 1.0.", "https://www.openstreetmap.org/copyright")212 source("Natural Earth", "World map at low zoom and world place names. Public domain.", "https://www.naturalearthdata.com")213 source("ESA WorldCover", "Land cover at low zoom © ESA WorldCover project, contains modified Copernicus Sentinel data, via Daylight and Overture Maps. CC BY 4.0.", "https://esa-worldcover.org")214 source("Protomaps basemap, Planetiler", "Tile schema (CC0) and tile generator (Apache 2.0, BSD 3-Clause).", "https://github.com/protomaps/basemaps")215 source("MapLibre Native", "Map rendering engine. BSD 2-Clause License.", "https://maplibre.org")216 source("Noto Sans", "Map label fonts. SIL Open Font License 1.1.", "https://fonts.google.com/noto")217 } header: { Text("Data and software") } footer: {218 Text("You are free to copy, distribute and adapt OpenStreetMap data, as long as you credit OpenStreetMap and its contributors and distribute derived databases under the same licence.")219 }220 if !app.regions.isEmpty {221 Section("Installed maps") {222 ForEach(app.regions) { r in223 VStack(alignment: .leading, spacing: 2) {224 Text(r.name(language: app.settings.interfaceLanguageCode))225 if let d = r.dataDate {226 Text("Map data of \(d.formatted(date: .abbreviated, time: .omitted))").font(.footnote).foregroundStyle(.secondary)227 }228 }229 }230 }231 }232 Section {233 Text("Maps can be wrong or out of date. ORIX Maps has no live traffic, no closures and no transit schedules. Do not use it for aviation, marine navigation or emergencies.")234 .font(.footnote).foregroundStyle(.secondary)235 }236 }237 .navigationTitle("About")238 .navigationBarTitleDisplayMode(.inline)239 .accessibilityIdentifier("about.list")240 }241242 private func source(_ name: String, _ text: LocalizedStringKey, _ url: String) -> some View {243 VStack(alignment: .leading, spacing: 4) {244 Text(verbatim: name).font(.subheadline.weight(.semibold))245 Text(text).font(.footnote).foregroundStyle(.secondary)246 Text(verbatim: url).font(.caption).foregroundStyle(.secondary).textSelection(.enabled)247 }248 .accessibilityElement(children: .combine)249 }250}251