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