]> git.r.bdr.sh - rbdr/captura/blob - Captura/Data/CapturaSettings.swift
01ef78c56bf222a1ec2f960e284cff28134094e9
[rbdr/captura] / Captura / Data / CapturaSettings.swift
1 import Foundation
2
3 struct CapturaSettings {
4 static var frameRate: Int {
5 UserDefaults.standard.integer(forKey: "frameRate")
6 }
7
8 static var outputFormats: OutputFormatSetting {
9 OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "outputFormats")) ?? .all
10 }
11
12 static var shouldSaveMp4: Bool {
13 outputFormats.shouldSaveMp4() || (shouldUseBackend && shouldUploadMp4)
14 }
15
16 static var shouldSaveGif: Bool {
17 outputFormats.shouldSaveGif() || (shouldUseBackend && shouldUploadGif)
18 }
19
20 static var shouldUploadGif: Bool {
21 backendFormat.shouldSaveGif()
22 }
23
24 static var shouldUploadMp4: Bool {
25 backendFormat.shouldSaveMp4()
26 }
27
28 static var shouldUseBackend: Bool {
29 backend != nil
30 }
31
32 static var backend: URL? {
33 if let url = UserDefaults.standard.string(forKey: "backendUrl") {
34 return URL(string: url)
35 }
36 return nil
37 }
38
39 static var backendFormat: OutputFormatSetting {
40 OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "backendFormat")) ?? .all
41 }
42
43 static var shouldKeepLocalFiles: Bool {
44 UserDefaults.standard.bool(forKey: "keepFiles")
45 }
46 }