3 struct AdvancedSettings: View {
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
9 @State var showConfirmation = false
11 private var anyState: String { "\(backendUrl), \(backendFormat), \(keepFiles), \(allowURLAutomation)" }
13 var parsedBackendUrl: URL? {
14 URL(string: backendUrl)
19 VStack (alignment: .center) {
21 VStack (alignment: .center) {
22 LabeledContent("Backend URL") {
23 TextField("", text: $backendUrl).font(.body)
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.")
26 Picker(selection: $backendFormat, label: Text("Backend Format").font(.headline)) {
28 .tag(OutputFormatSetting.gifOnly)
29 .padding(.horizontal, 4.0)
30 .padding(.vertical, 2.0)
32 .tag(OutputFormatSetting.mp4Only)
33 .padding(.horizontal, 4.0)
34 .padding(.vertical, 2.0)
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)
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.")
45 Text("These settings can break things! Please make sure you understand how to use them before enabling.")
47 Link(destination: URL(string: "https://captura.tranquil.systems")!) {
48 Image(systemName: "info.circle")
49 }.buttonStyle(.borderless)
53 Divider().padding(.vertical, 8.0)
55 Toggle("Allow URL Based Automation", isOn: $allowURLAutomation)
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
63 Button("Cancel", role: .cancel) {
64 showConfirmation = false
65 allowURLAutomation = false
68 .onChange(of: allowURLAutomation, perform: { newValue in
70 showConfirmation = true
77 .onChange(of: anyState) { _ in
78 NotificationCenter.default.post(name: .reloadConfiguration, object: nil, userInfo: nil)