]>
Commit | Line | Data |
---|---|---|
a4e80427 RBR |
1 | import SwiftUI |
2 | ||
3 | struct AdvancedSettings: View { | |
4 | ||
e42019cd RBR |
5 | @AppStorage("backendUrl") var backendUrl: String = "" |
6 | @AppStorage("backendFormat") var backendFormat: OutputFormatSetting = .gifOnly | |
7 | @AppStorage("keepFiles") var keepFiles = true | |
8 | @AppStorage("allowURLAutomation") var allowURLAutomation = false | |
ba17de89 | 9 | @State var showConfirmation = false |
a4e80427 | 10 | |
377442f2 RBR |
11 | private var anyState: String { "\(backendUrl), \(backendFormat), \(keepFiles), \(allowURLAutomation)" } |
12 | ||
c9b9e1d6 RBR |
13 | var parsedBackendUrl: URL? { |
14 | URL(string: backendUrl) | |
15 | } | |
16 | ||
a4e80427 RBR |
17 | var body: some View { |
18 | Form { | |
c9b9e1d6 | 19 | VStack (alignment: .center) { |
ba17de89 RBR |
20 | Section { |
21 | VStack (alignment: .center) { | |
22 | LabeledContent("Backend URL") { | |
23 | TextField("", text: $backendUrl).font(.body) | |
24 | }.font(.headline) | |
25 | .help("The Backend URL to use. If this is empty, no backend will be used and the options below won't have an effect.") | |
377442f2 | 26 | Picker(selection: $backendFormat, label: Text("Backend Format").font(.headline)) { |
ba17de89 RBR |
27 | Text("GIF") |
28 | .tag(OutputFormatSetting.gifOnly) | |
29 | .padding(.horizontal, 4.0) | |
30 | .padding(.vertical, 2.0) | |
31 | Text("MP4") | |
32 | .tag(OutputFormatSetting.mp4Only) | |
33 | .padding(.horizontal, 4.0) | |
34 | .padding(.vertical, 2.0) | |
35 | } | |
36 | .pickerStyle(.radioGroup) | |
37 | .disabled(parsedBackendUrl == nil) | |
38 | .help("The format picked here will be generated regardless of what option you pick in the output settings. It doesn't prevent files from being rendered.") | |
39 | Toggle("Keep Local Files", isOn: $keepFiles) | |
40 | .font(.headline) | |
41 | .disabled(parsedBackendUrl == nil) | |
42 | .padding(.vertical, 8.0) | |
43 | .help("If this is off, locally generated recordings will be deleted immediately after a successful upload.") | |
44 | HStack { | |
45 | Text("These settings can break things! Please make sure you understand how to use them before enabling.") | |
46 | .lineLimit(3...10) | |
47 | Link(destination: URL(string: "https://captura.tranquil.systems")!) { | |
48 | Image(systemName: "info.circle") | |
49 | }.buttonStyle(.borderless) | |
50 | } | |
51 | } | |
c9b9e1d6 | 52 | } |
ba17de89 RBR |
53 | Divider().padding(.vertical, 8.0) |
54 | Section { | |
55 | Toggle("Allow URL Based Automation", isOn: $allowURLAutomation) | |
56 | .font(.headline) | |
57 | .padding(.vertical, 8.0) | |
58 | .help("If this is on, the app can be controlled remotely using the captura: URL scheme.") | |
59 | .confirmationDialog("This may be dangerous and can allow websites to remotely record your computer.", isPresented: $showConfirmation, actions: { | |
60 | Button("I Understand The Risk", role: .destructive) { | |
61 | showConfirmation = false | |
62 | } | |
63 | Button("Cancel", role: .cancel) { | |
64 | showConfirmation = false | |
65 | allowURLAutomation = false | |
66 | } | |
67 | }) | |
68 | .onChange(of: allowURLAutomation, perform: { newValue in | |
69 | if newValue { | |
70 | showConfirmation = true | |
71 | } | |
72 | }) | |
a4e80427 | 73 | } |
c9b9e1d6 | 74 | Spacer() |
a4e80427 RBR |
75 | } |
76 | } | |
377442f2 RBR |
77 | .onChange(of: anyState) { _ in |
78 | NotificationCenter.default.post(name: .reloadConfiguration, object: nil, userInfo: nil) | |
79 | } | |
a4e80427 RBR |
80 | } |
81 | } | |
82 | ||
83 | #Preview { | |
84 | OutputSettings() | |
85 | } |