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