Repository Public
1// ORIX Docs2// File: App/Sources/Inspector/InspectorView.swift3// Description: The inspector (right-hand panel): a nine-tab icon strip and the scrollable content of the selected tab.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import SwiftUI8import DocModel910struct InspectorView: View {11 @Bindable var session: DocumentSession1213 init(session: DocumentSession) { self.session = session }1415 var body: some View {16 VStack(spacing: 0) {17 InspectorTabStrip(selection: $session.inspectorTab)18 Rectangle().fill(ORIX.Palette.hairline).frame(height: 1)19 ScrollView(.vertical) {20 VStack(spacing: 0) {21 switch session.inspectorTab {22 case .format: TypographyInspector(session: session)23 case .styles: StylesInspector(session: session)24 case .document: DocumentInspector(session: session)25 case .table: TableInspector(session: session)26 case .object: ObjectInspector(session: session)27 case .academic: AcademicInspector(session: session)28 case .publish: PublishInspector(session: session)29 case .audit: AuditInspector(session: session)30 case .intelligence: IntelligenceInspector(session: session)31 }32 }33 .frame(maxWidth: .infinity, alignment: .top)34 }35 .id(session.inspectorTab)36 .scrollIndicators(.automatic)37 }38 .background(ORIX.Palette.chrome)39 .accessibilityElement(children: .contain)40 .accessibilityLabel(Text("Inspector"))41 .accessibilityIdentifier("inspector")42 }43}4445/// Nine icon tabs that share the panel width equally, with the selected tab's name underneath.46struct InspectorTabStrip: View {47 @Binding var selection: InspectorTab4849 var body: some View {50 VStack(spacing: 0) {51 HStack(spacing: 1) {52 ForEach(InspectorTab.allCases) { tab in InspectorTabButton(tab: tab, isOn: selection == tab) { selection = tab } }53 }54 .padding(.horizontal, ORIX.Space.s)55 .padding(.top, 6)56 HStack {57 Text(selection.title).font(.system(size: 12.5, weight: .semibold)).foregroundStyle(ORIX.Palette.text)58 .accessibilityAddTraits(.isHeader)59 Spacer()60 }61 .padding(.horizontal, ORIX.Space.l)62 .frame(height: 30)63 }64 .accessibilityElement(children: .contain)65 .accessibilityLabel(Text("Inspector tabs"))66 }67}6869private struct InspectorTabButton: View {70 let tab: InspectorTab71 let isOn: Bool72 let action: () -> Void73 @State private var hover = false7475 var body: some View {76 Button(action: action) {77 Image(systemName: tab.symbol)78 .font(.system(size: 12.5, weight: .medium))79 .frame(maxWidth: .infinity).frame(height: 26)80 .foregroundStyle(isOn ? ORIX.Palette.accent : ORIX.Palette.text.opacity(0.7))81 .background(RoundedRectangle(cornerRadius: ORIX.Radius.s).fill(isOn ? ORIX.Palette.accent.opacity(0.16) : (hover ? ORIX.Palette.text.opacity(0.07) : .clear)))82 .overlay(alignment: .bottom) {83 // The selected tab is also marked by a bar, not by colour alone.84 Capsule().fill(ORIX.Palette.accent).frame(width: 12, height: 2).offset(y: 4).opacity(isOn ? 1 : 0)85 }86 .contentShape(Rectangle())87 }88 .buttonStyle(.plain)89 .onHover { hover = $0 }90 .help(Text(tab.title))91 .accessibilityLabel(Text(tab.title))92 .accessibilityAddTraits(isOn ? [.isSelected, .isButton] : .isButton)93 .accessibilityIdentifier("inspector-tab-\(tab.rawValue)")94 }95}96