krz/hutch

an ios client for sourcehut

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

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