#if os(macOS) import SwiftUI // 桌面根界面:NavigationSplitView 侧栏(传输 / 文件 / 消息 / 设备 / 设置)+ 详情 NavigationStack, // 替代 iOS 的标签栏。当前为脚手架:各区详情为占位(MacPlaceholder),随后续阶段接入复用视图 // 与桌面专属功能。分区标签暂硬编中文;接入 i18n(Shared/I18n)后改走 t()(与 iOS 单一真源一致)。 struct MacRootView: View { @State private var selection: MacSection = .transfers var body: some View { NavigationSplitView { List(selection: $selection) { brandHeader .listRowInsets(EdgeInsets(top: 10, leading: 8, bottom: 14, trailing: 8)) .listRowSeparator(.hidden) .selectionDisabled() Section { ForEach(MacSection.sidebar) { section in Label(section.title, systemImage: section.icon) .tag(section) } } } .navigationSplitViewColumnWidth(min: 200, ideal: 220, max: 280) .navigationTitle("Commilitia Drop") } detail: { NavigationStack { detail } } } @ViewBuilder private var detail: some View { switch selection { case .transfers: MacPlaceholder(section: .transfers) case .files: MacPlaceholder(section: .files) case .messages: MacPlaceholder(section: .messages) case .devices: MacPlaceholder(section: .devices) case .settings: MacPlaceholder(section: .settings) } } private var brandHeader: some View { HStack(spacing: 10) { Image(systemName: "paperplane.fill") .font(.title2) .foregroundStyle(.tint) Text("Commilitia Drop") .font(.title3.weight(.semibold)) .lineLimit(1) } } } // 侧栏分区。与 iOS 标签一致:传输 / 文件 / 消息 / 设备 / 设置。 enum MacSection: Hashable, Identifiable, CaseIterable { case transfers, files, messages, devices, settings var id: Self { self } var title: String { switch self { case .transfers: return "传输" case .files: return "文件" case .messages: return "消息" case .devices: return "设备" case .settings: return "设置" } } var icon: String { switch self { case .transfers: return "arrow.up.arrow.down" case .files: return "folder" case .messages: return "bubble.left.and.bubble.right" case .devices: return "laptopcomputer.and.iphone" case .settings: return "gearshape" } } static var sidebar: [MacSection] { MacSection.allCases } } // 阶段占位详情:标明该区将接入的功能,随后续阶段替换为实际视图。 struct MacPlaceholder: View { let section: MacSection var body: some View { ContentUnavailableView { Label(section.title, systemImage: section.icon) } description: { Text("即将接入(原生数据面复用 iOS 引擎,桌面功能适配中)。") } .navigationTitle(section.title) } } #endif