-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathAppearanceSettingsView.swift
More file actions
169 lines (164 loc) · 5.64 KB
/
Copy pathAppearanceSettingsView.swift
File metadata and controls
169 lines (164 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import ComposableArchitecture
import SupacodeSettingsShared
import SwiftUI
public struct AppearanceSettingsView: View {
@Bindable var store: StoreOf<SettingsFeature>
public init(store: StoreOf<SettingsFeature>) {
self.store = store
}
public var body: some View {
let openActionOptions = store.installedOpenActions
Form {
Section {
LabeledContent("Appearance") {
HStack(spacing: 12) {
let appearanceMode = $store.appearanceMode
ForEach(AppearanceMode.allCases) { mode in
AppearanceOptionCardView(
mode: mode,
isSelected: mode == appearanceMode.wrappedValue
) {
appearanceMode.wrappedValue = mode
}
}
}
}
Toggle(isOn: $store.terminalThemeSyncEnabled) {
Text("Supacode Terminal Theme")
Text("When off, honors your Ghostty config theme.")
}
}
Section {
Picker(selection: $store.confirmQuitMode) {
ForEach(ConfirmQuitMode.allCases, id: \.self) { mode in
Text(mode.label).tag(mode)
}
} label: {
Text("Confirm before Quitting")
Text(store.confirmQuitMode.subtitle)
}
Toggle(isOn: $store.terminateSessionsOnQuit) {
Text("Terminate Sessions on Quit")
Text(
"""
Close all tabs and stop background shells when quitting.
Terminal persistence is powered by [zmx \u{2197}](https://github.com/neurosnap/zmx).
"""
)
}
Toggle(isOn: $store.remoteSessionPersistenceEnabled) {
Text("Persist Remote Sessions on Host")
Text(
"""
Keeps SSH surfaces alive across disconnects when \
[zmx \u{2197}](https://github.com/neurosnap/zmx) is installed on the host.
"""
)
}
}
Section {
LabeledContent("Visibility") {
HStack(spacing: 12) {
ForEach(AppVisibility.allCases) { visibility in
AppVisibilityOptionCardView(
visibility: visibility,
isSelected: visibility == store.appVisibility
) {
store.send(.setAppVisibility(visibility))
}
}
}
}
}
Section("Editor") {
// The stored id deliberately keeps naming an uninstalled editor, so the choice
// survives a reinstall. No row is tagged with it though, and an untagged
// selection renders blank, so normalize for display and write back raw.
let storedEditorID = $store.defaultEditorID
let defaultEditorID = Binding(
get: {
OpenWorktreeAction.normalizedDefaultEditorID(
storedEditorID.wrappedValue,
installed: openActionOptions
)
},
set: { storedEditorID.wrappedValue = $0 }
)
Picker(
selection: defaultEditorID
) {
Text("Automatic")
.tag(OpenWorktreeAction.automaticSettingsID)
ForEach(openActionOptions) { action in
Text(action.labelTitle)
.tag(action.settingsID)
}
} label: {
Text("Default Editor")
Text("Applies to Worktrees without repository overrides.")
}
}
Section {
Toggle(isOn: $store.analyticsEnabled) {
Text("Share Analytics")
Text("Anonymous usage data helps improve Supacode.")
}
Toggle(isOn: $store.crashReportsEnabled) {
Text("Share Crash Reports")
Text("Anonymous crash reports help improve stability.")
}
} header: {
Text("Analytics")
} footer: {
Text("Changes to Analytics require Supacode to restart before they take effect.")
}
Section("Advanced") {
Toggle(isOn: $store.hideSingleTabBar) {
Text("Hide Tab Bar for Single Tab")
Text("Automatically hides the tab bar when only one tab is open.")
}
Toggle(isOn: $store.confirmCloseSurface) {
Text("Confirm before Closing Terminals")
Text("Ask before closing a terminal that has a running process.")
}
Picker(selection: $store.automatedActionPolicy.sending(\.setAutomatedActionPolicy)) {
ForEach(AutomatedActionPolicy.allCases, id: \.self) { policy in
Text(policy.displayName).tag(policy)
}
} label: {
Text("Allow Arbitrary Actions")
Text("Skip the confirmation dialog for commands and destructive actions.")
}
Toggle(isOn: $store.terminalHibernationEnabled) {
HStack(spacing: 6) {
Text("Hibernate inactive terminals")
BetaBadge()
}
Text(
"Background terminal tabs release their renderer after a few minutes of inactivity "
+ "and reconnect instantly when viewed. Sessions and running agents are unaffected."
)
}
.help("Free memory by suspending the renderer of terminal tabs you are not viewing.")
}
}
.formStyle(.grouped)
.padding(.top, -20)
.padding(.leading, -8)
.padding(.trailing, -6)
.navigationTitle("General")
}
}
/// Small system-styled tag marking a setting as Beta. Uses `.quaternary` fill so
/// it tracks the theme and never introduces a custom color.
private struct BetaBadge: View {
var body: some View {
Text("Beta")
.font(.caption2)
.fontWeight(.semibold)
.foregroundStyle(.secondary)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(.quaternary, in: .capsule)
}
}