metatext-app-ios-iphone-ipad/Views/SwiftUI/AboutView.swift

95 lines
3.3 KiB
Swift
Raw Normal View History

2021-01-29 02:08:57 +01:00
// Copyright © 2021 Metabolist. All rights reserved.
import SwiftUI
2021-03-03 07:55:35 +01:00
import ViewModels
2021-01-29 02:08:57 +01:00
struct AboutView: View {
2021-03-03 07:55:35 +01:00
@StateObject var viewModel: NavigationViewModel
2021-01-29 02:08:57 +01: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 07:55:35 +01:00
Section(header: Text("about.made-by-metabolist")) {
Button {
viewModel.navigateToURL(Self.officialAccountURL)
2021-03-03 07:55:35 +01:00
} 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")
}
}
Link(destination: Self.sourceCodeAndIssueTrackerURL) {
Label {
Text("about.source-code-and-issue-tracker").foregroundColor(.primary)
} icon: {
Image(systemName: "wrench.and.screwdriver")
}
}
2021-03-27 07:07:16 +01:00
Link(destination: Self.translationsURL) {
Label {
Text("about.translations").foregroundColor(.primary)
} icon: {
Image(systemName: "globe")
}
}
2021-03-22 00:50:46 +01:00
Link(destination: Self.reviewURL) {
Label {
2021-03-23 19:09:20 +01:00
Text("about.rate-the-app").foregroundColor(.primary)
2021-03-22 00:50:46 +01:00
} icon: {
Image(systemName: "star")
}
}
2021-03-03 07:55:35 +01:00
}
2021-01-29 02:08:57 +01:00
Section {
NavigationLink(
destination: AcknowledgmentsView()) {
Label("about.acknowledgments", systemImage: "curlybraces")
}
}
}
.navigationTitle("about")
}
}
private extension AboutView {
2021-03-03 07:55:35 +01:00
static let websiteURL = URL(string: "https://metabolist.org")!
static let officialAccountURL = URL(string: "https://mastodon.social/@metabolist")!
static let sourceCodeAndIssueTrackerURL = URL(string: "https://github.com/metabolist/metatext")!
2021-03-27 07:07:16 +01:00
static let translationsURL = URL(string: "https://crowdin.com/project/metatext")!
2021-03-22 00:50:46 +01:00
static let reviewURL = URL(string: "https://apps.apple.com/app/metatext/id1523996615?mt=8&action=write-review")!
2021-01-29 02:08:57 +01: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 07:55:35 +01:00
AboutView(viewModel: NavigationViewModel(identityContext: .preview))
2021-01-29 02:08:57 +01:00
}
}
#endif