Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : SP Drive pour iPhone et iPad9// File : Features/MyDrive/ItemInspector.swift10// Description : The inspector column (iPad, wide windows): a large preview11// of the item, its state and facts, and its main actions,12// next to the browser so the list stays in view. On a narrow13// window the same information is the details sheet.14// Module : Features15// Repository : https://git.spboucher.ai/sp-drive-ios16// Created : 2026-11-1917// Last Modified : 2026-11-1918//19// =============================================================================20// AUTHOR & PROFESSIONAL AFFILIATION21// =============================================================================22//23// Author : Simon-Pierre Boucher24// Position : Professor of Finance25// Institution : Université du Québec en Outaouais (UQO)26// Department : Département des sciences administratives27// Organization : SP Boucher28//29// Website : https://spboucher.ai30// Git : https://git.spboucher.ai31//32// =============================================================================33// OFFICIAL CONTACT DIRECTORY34// =============================================================================35//36// General : info@spboucher.ai37// Professional : contact@spboucher.ai38// Direct : simon@spboucher.ai39// Research : research@spboucher.ai40// Development : dev@spboucher.ai41// Support : support@spboucher.ai42// Security/Admin : admin@spboucher.ai43// Notifications : notifications@spboucher.ai44//45// Preferred Contact: support@spboucher.ai46//47// =============================================================================48// COPYRIGHT & INTELLECTUAL PROPERTY49// =============================================================================50//51// Copyright (c) 202652// Simon-Pierre Boucher53//54// All rights reserved where applicable.55//56// This file is governed by the applicable project license,57// copyright notices, institutional agreements and relevant law.58//59// Unless expressly authorized by the applicable license or60// rights holder, copying, redistribution, sublicensing,61// publication and commercial exploitation are not permitted.62//63// Existing third-party rights and notices remain unaffected.64//65// =============================================================================66// CONFIDENTIALITY & SECURITY67// =============================================================================68//69// Classification : Public70// Distribution : Public repository; use is governed by the project license71// Security Contact : admin@spboucher.ai72//73// Access to this source does not independently grant permission74// to redistribute or disclose confidential materials.75//76// Do not embed credentials, private keys, access tokens,77// certificates or confidential personal information.78//79// =============================================================================80// LICENSE & MAINTENANCE81// =============================================================================82//83// License : None specified (no license file in this repository)84// Maintainer : Simon-Pierre Boucher85// Technical Contact: dev@spboucher.ai86//87// =============================================================================88// END OF SP BOUCHER SOURCE HEADER89// =============================================================================9091import SwiftUI9293struct ItemInspector: View {94 @Environment(AppModel.self) private var model95 private let initial: DriveItem96 let actions: ItemActions9798 init(item: DriveItem, actions: ItemActions) { initial = item; self.actions = actions }99100 var body: some View {101 let _ = model.itemsVersion102 let item = model.store.item(initial.id) ?? initial103 let badge = model.badge(item)104 let pinned = model.store.localState(item.id)?.pinned == true105 ScrollView {106 VStack(alignment: .leading, spacing: SPDTheme.Space.lg) {107 Button { if !item.isFolder { actions.open(item, model: model) } } label: {108 ItemPreviewTile(item: item).aspectRatio(4 / 3, contentMode: .fit)109 .clipShape(RoundedRectangle(cornerRadius: SPDTheme.Radius.xl, style: .continuous))110 .overlay(RoundedRectangle(cornerRadius: SPDTheme.Radius.xl, style: .continuous).strokeBorder(SPDTheme.Palette.hairline, lineWidth: 0.5))111 }112 .buttonStyle(.plain)113 .hoverEffect(.lift)114 .disabled(item.isFolder)115 .accessibilityLabel(Text(item.isFolder ? "Aperçu du dossier" : "Ouvrir l’aperçu en grand"))116 VStack(alignment: .leading, spacing: 6) {117 Text(item.name).font(SPDTheme.Typo.title).fixedSize(horizontal: false, vertical: true).textSelection(.enabled)118 if let chip = badge.chipLabel {119 Label { Text(chip) } icon: { if badge == .none { Image(systemName: "checkmark.icloud") } else { SyncBadgeView(badge: badge) } }120 .font(SPDTheme.Typo.caption.weight(.medium)).padding(.horizontal, 8).padding(.vertical, 4).background(.quaternary.opacity(0.6), in: Capsule())121 }122 }123 HStack(spacing: SPDTheme.Space.sm) {124 if !item.isFolder { tool("Ouvrir", "eye.fill") { actions.open(item, model: model) } }125 if !item.isLocalOnly { tool("Partager", "link") { actions.sheet = .share(item) } }126 tool(item.starred ? "Retirer" : "Favori", item.starred ? "star.slash.fill" : "star.fill") { actions.toggleStar([item], model: model) }127 if !item.isLocalOnly { tool(pinned ? "En ligne" : "Hors ligne", pinned ? "icloud" : "arrow.down.circle.fill") { actions.setOffline(item, !pinned, model: model) } }128 }129 VStack(spacing: 0) {130 fact("Type", item.kind.label)131 if !item.isFolder { fact("Taille", item.size.byteString) }132 fact("Emplacement", model.store.path(to: item.id).dropLast().map { $0.parentID == nil ? String(localized: "Mon Drive") : $0.name }.joined(separator: " › "))133 fact("Modifié", item.updatedAt.formatted(date: .abbreviated, time: .shortened))134 fact("Créé", item.createdAt.formatted(date: .abbreviated, time: .shortened))135 if !item.isFolder { fact("Versions", "\(item.versionCount)") }136 if item.isFolder || pinned {137 let status = model.engine.pinStatus(of: item.id)138 if item.isFolder { fact("Contenu", status.files == 1 ? String(localized: "1 fichier · \(status.bytes.byteString)") : String(localized: "\(status.files) fichiers · \(status.bytes.byteString)")) }139 if pinned || model.engine.isEffectivelyPinned(item.id) { fact("Sur cet appareil", String(localized: "\(status.availableFiles) sur \(status.files) · \(status.availableBytes.byteString)"), last: true) }140 }141 }142 .spdCard()143 Button { actions.sheet = .details(item) } label: { Label("Versions, partage et détails…", systemImage: "clock.arrow.circlepath").frame(maxWidth: .infinity, minHeight: 40) }144 .buttonStyle(.bordered)145 .accessibilityIdentifier("inspector.details")146 }147 .padding(SPDTheme.Space.lg)148 }149 .background(SPDTheme.Palette.surface)150 .accessibilityIdentifier("inspector")151 }152153 private func tool(_ title: LocalizedStringKey, _ symbol: String, action: @escaping () -> Void) -> some View {154 Button(action: action) {155 VStack(spacing: 4) { Image(systemName: symbol).font(.body.weight(.semibold)).frame(height: 22); Text(title).font(SPDTheme.Typo.eyebrow.weight(.medium)).lineLimit(1).minimumScaleFactor(0.7) }156 .frame(maxWidth: .infinity, minHeight: 54)157 }158 .buttonStyle(.plain).foregroundStyle(SPDTheme.Palette.brand).spdCard().hoverEffect(.highlight)159 }160161 private func fact(_ label: LocalizedStringKey, _ value: String, last: Bool = false) -> some View {162 VStack(spacing: 0) {163 HStack(alignment: .firstTextBaseline) {164 Text(label).foregroundStyle(.secondary)165 Spacer(minLength: SPDTheme.Space.md)166 Text(value.isEmpty ? "—" : value).multilineTextAlignment(.trailing).textSelection(.enabled)167 }168 .font(SPDTheme.Typo.caption)169 .padding(.horizontal, SPDTheme.Space.md).padding(.vertical, 10)170 .accessibilityElement(children: .combine)171 if !last { Divider().padding(.leading, SPDTheme.Space.md) }172 }173 }174}175