Bubble/Threaded/Views/Settings/AboutView.swift

67 lines
2.1 KiB
Swift
Raw Normal View History

2023-12-30 20:57:41 +01:00
//Made by Lumaa
import SwiftUI
struct AboutView: View {
@ObservedObject private var userPreferences: UserPreferences = .defaultPreferences
2023-12-30 20:57:41 +01:00
var body: some View {
List {
2024-01-21 13:16:37 +01:00
Section(footer: Text("about.version-\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown")")) {
2024-01-06 03:38:54 +01:00
NavigationLink {
aboutApp
} label: {
Text("about.app")
}
.listRowThreaded()
2024-01-06 03:38:54 +01:00
Toggle("setting.experimental.activate", isOn: $userPreferences.showExperimental)
.listRowThreaded()
.tint(Color(uiColor: UIColor.label))
.onAppear {
do {
let oldPreferences = try UserPreferences.loadAsCurrent() ?? UserPreferences.defaultPreferences
userPreferences.showExperimental = oldPreferences.showExperimental
} catch {
print(error)
}
}
2024-01-06 03:38:54 +01:00
}
}
2024-01-06 03:40:24 +01:00
.listThreaded()
.navigationTitle("about")
.navigationBarTitleDisplayMode(.inline)
.onDisappear {
do {
if !userPreferences.showExperimental {
userPreferences.experimental = .init()
}
try userPreferences.saveAsCurrent()
} catch {
print(error)
}
}
}
var aboutApp: some View {
2024-01-10 17:46:19 +01:00
// TODO: Change this entire ugly thing
ScrollView {
VStack (spacing: 15) {
Text("about.app.details")
.multilineTextAlignment(.leading)
Text("about.app.third-party")
.multilineTextAlignment(.leading)
}
.padding(.horizontal)
}
2024-01-06 03:40:24 +01:00
.listThreaded(tint: Color.blue)
.navigationTitle("about.app")
.navigationBarTitleDisplayMode(.large)
2023-12-30 20:57:41 +01:00
}
}
#Preview {
AboutView()
}