metatext/Views/SwiftUI/AboutView.swift

69 lines
2.1 KiB
Swift
Raw Normal View History

2021-01-29 01:08:57 +00:00
// Copyright © 2021 Metabolist. All rights reserved.
import SwiftUI
2021-03-03 06:55:35 +00:00
import ViewModels
2021-01-29 01:08:57 +00:00
struct AboutView: View {
2021-03-03 06:55:35 +00:00
@StateObject var viewModel: NavigationViewModel
2021-01-29 01:08:57 +00:00
var body: some View {
Form {
Section {
VStack(spacing: .defaultSpacing) {
Text("metatext")
.font(.largeTitle)
Text(verbatim: "\(Self.version) (\(Self.build))")
}
.padding()
}
.frame(maxWidth: .infinity, alignment: .center)
2021-03-03 06:55:35 +00:00
Section(header: Text("about.made-by-metabolist")) {
Button {
viewModel.navigateToOfficialAccount()
} label: {
Label {
Text("about.official-account").foregroundColor(.primary)
} icon: {
Image(systemName: "checkmark.seal")
}
}
Link(destination: Self.websiteURL) {
Label {
Text("about.website").foregroundColor(.primary)
} icon: {
Image(systemName: "link")
}
}
}
2021-01-29 01:08:57 +00:00
Section {
NavigationLink(
destination: AcknowledgmentsView()) {
Label("about.acknowledgments", systemImage: "curlybraces")
}
}
}
.navigationTitle("about")
}
}
private extension AboutView {
2021-03-03 06:55:35 +00:00
static let websiteURL = URL(string: "https://metabolist.org")!
2021-01-29 01:08:57 +00:00
static var version: String {
Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? ""
}
static var build: String {
Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as? String ?? ""
}
}
#if DEBUG
import PreviewViewModels
struct AboutView_Previews: PreviewProvider {
static var previews: some View {
2021-03-03 06:55:35 +00:00
AboutView(viewModel: NavigationViewModel(identityContext: .preview))
2021-01-29 01:08:57 +00:00
}
}
#endif