krz/hutch
an ios client for sourcehut
clone: git clone https://gitbay.org/krz/hutch.git
v2.12.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 ]
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
34 Section("Meta") {
35 NavigationLink(value: MoreRoute.profile) {
36 Label("Profile", systemImage: "person.text.rectangle")
37 }
38
39 NavigationLink(value: MoreRoute.settings) {
40 Label("Settings", systemImage: "gear")
41 }
42 }
43
44 Section {
45 ForEach(unsupportedLinks, id: \.title) { item in
46 Link(destination: item.url) {
47 Label(item.title, systemImage: "safari")
48 }
49 }
50 } header: {
51 Text("External Links")
52 } footer: {
53 Text("These SourceHut services are not supported in-app, as the SourceHut API does not support them, and will open in your browser.")
54 }
55 }
56 .navigationTitle("More")
57 .toolbar {
58 ToolbarItem(placement: .topBarTrailing) {
59 Button {
60 showAccountSwitcher = true
61 } label: {
62 Image(systemName: "person.crop.circle")
63 }
64 }
65 }
66 .sheet(isPresented: $showAccountSwitcher) {
67 AccountSwitcherView()
68 }
69 }
70}