krz/hutch

an ios client for sourcehut

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

v2.8.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", URL(string: "https://chat.sr.ht")!),
 8        ("man.sr.ht", URL(string: "https://man.sr.ht")!),
 9        ("srht.site", URL(string: "https://srht.site")!)
10    ]
11
12    @State private var showAccountSwitcher = false
13
14    var body: some View {
15        List {
16            Section {
17                NavigationLink(value: MoreRoute.lookup) {
18                    Label("Look Up", systemImage: "magnifyingglass")
19                }
20
21                NavigationLink(value: MoreRoute.lists) {
22                    Label("Mailing Lists", systemImage: "list.bullet.rectangle")
23                }
24
25                NavigationLink(value: MoreRoute.pastes) {
26                    Label("Pastes", systemImage: "doc.on.clipboard")
27                }
28
29                NavigationLink(value: MoreRoute.settings) {
30                    Label("Settings", systemImage: "gear")
31                }
32            }
33
34            Section {
35                ForEach(unsupportedLinks, id: \.title) { item in
36                    Link(destination: item.url) {
37                        Label(item.title, systemImage: "safari")
38                    }
39                }
40            } header: {
41                Text("External Links")
42            } footer: {
43                Text("These SourceHut services are not supported in-app, as the SourceHut API does not support them, and will open in your browser.")
44            }
45        }
46        .navigationTitle("More")
47        .toolbar {
48            ToolbarItem(placement: .topBarTrailing) {
49                Button {
50                    showAccountSwitcher = true
51                } label: {
52                    Image(systemName: "person.crop.circle")
53                }
54            }
55        }
56        .sheet(isPresented: $showAccountSwitcher) {
57            AccountSwitcherView()
58        }
59    }
60}