krz/hutch

an ios client for sourcehut

clone: git clone https://gitbay.org/krz/hutch.git

v2.13.0: Hutch/Views/More/MoreView.swift · raw

 1import SwiftUI
 2
 3struct MoreView: View {
 4    @Environment(AppState.self) private var appState
 5
 6    private let unsupportedLinks: [(title: String, url: URL)] = [
 7        ("chat.sr.ht", SRHTWebURL.chat)
 8    ]
 9
10    @State private var showAccountSwitcher = false
11
12    var body: some View {
13        List {
14            Section("Search") {
15                NavigationLink(value: MoreRoute.lookup) {
16                    Label("Look Up", systemImage: "magnifyingglass")
17                }
18            }
19
20            Section("Other Services") {
21                NavigationLink(value: MoreRoute.lists) {
22                    Label("Mailing Lists", systemImage: "list.bullet.rectangle")
23                }
24
25                NavigationLink(value: MoreRoute.manPageBrowser) {
26                    Label("Man Pages", systemImage: "book")
27                }
28
29                NavigationLink(value: MoreRoute.pastes) {
30                    Label("Pastes", systemImage: "doc.on.clipboard")
31                }
32                
33                NavigationLink(value: MoreRoute.systemStatus) {
34                    Label("System Status", systemImage: "server.rack")
35                }
36            }
37
38            Section("Meta") {
39                NavigationLink(value: MoreRoute.profile) {
40                    Label("Profile", systemImage: "person.text.rectangle")
41                }
42
43                NavigationLink(value: MoreRoute.settings) {
44                    Label("Settings", systemImage: "gear")
45                }
46            }
47
48            Section {
49                ForEach(unsupportedLinks, id: \.title) { item in
50                    Link(destination: item.url) {
51                        Label(item.title, systemImage: "safari")
52                    }
53                }
54            } header: {
55                Text("External Links")
56            } footer: {
57                Text("These SourceHut services are not supported in-app, as the SourceHut API does not support them, and will open in your browser.")
58            }
59        }
60        .navigationTitle("More")
61        .toolbar {
62            ToolbarItem(placement: .topBarTrailing) {
63                Button {
64                    showAccountSwitcher = true
65                } label: {
66                    Image(systemName: "person.crop.circle.badge.plus")
67                }
68            }
69        }
70        .sheet(isPresented: $showAccountSwitcher) {
71            AccountSwitcherView()
72        }
73    }
74}