Repository Public
1import MCCCore2import SwiftUI34/// Settings: account panes for everyone, administration panes according to the permissions the server granted.5struct SettingsView: View {6 @Environment(AppModel.self) private var app7 @Environment(\.mccTheme) private var theme8 @SceneStorage("mcc.settings.pane") private var stored = SettingsPane.profile.rawValue9 @State private var selection: SettingsPane = .profile1011 var body: some View {12 let panes = SettingsPane.visible(permissions: app.session.permissions)13 HStack(spacing: 0) {14 List {15 Section(tr("settings.group.account")) {16 ForEach(panes.filter { !$0.isAdministration }) { row($0) }17 }18 if panes.contains(where: \.isAdministration) {19 Section(tr("settings.group.administration")) {20 ForEach(panes.filter(\.isAdministration)) { row($0) }21 }22 }23 }24 .listStyle(.inset)25 .frame(width: 230)26 .accessibilityLabel(tr("settings.panes"))27 Divider()28 pane(panes.contains(selection) ? selection : .profile)29 .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)30 }31 .background(theme.canvas)32 .onAppear { if let p = SettingsPane(rawValue: stored), panes.contains(p) { selection = p } }33 .onChange(of: selection) { _, new in stored = new.rawValue }34 }3536 private func row(_ p: SettingsPane) -> some View {37 SelectableRow(isSelected: selection == p, identifier: "settings-\(p.rawValue)") { selection = p } label: {38 Label(p.title, systemImage: p.symbol)39 }40 }4142 @ViewBuilder43 private func pane(_ p: SettingsPane) -> some View {44 switch p {45 case .profile: ProfilePane()46 case .passkeys: PasskeysPane()47 case .sessions: SessionsDevicesPane()48 case .security: SecurityPane()49 case .shortcuts: ShortcutsPane()50 case .about: AboutPane()51 case .users: AdminUsersPane()52 case .invitations: AdminInvitationsPane()53 case .grants: AdminGrantsPane()54 case .agents: AdminAgentsPane()55 case .system: AdminSystemPane()56 case .serverSettings: AdminServerSettingsPane()57 case .freeze: AdminFreezePane()58 }59 }60}61