Adds app version text to setting footer

This commit is contained in:
Stuart Breckenridge 2020-06-30 21:50:53 +08:00
parent 2342ef2b76
commit 6cb4c46e4b
1 changed files with 13 additions and 6 deletions

View File

@ -167,7 +167,7 @@ struct SettingsView: View {
} }
var help: some View { var help: some View {
Section(header: Text("Help"), content: { Section(header: Text("Help"), footer: Text(appVersion()).font(.caption2), content: {
Button("NetNewsWire Help", action: { Button("NetNewsWire Help", action: {
viewModel.selectedWebsite = .netNewsWireHelp viewModel.selectedWebsite = .netNewsWireHelp
}).foregroundColor(.primary) }).foregroundColor(.primary)
@ -195,6 +195,13 @@ struct SettingsView: View {
} }
private func appVersion() -> String {
let dict = NSDictionary(contentsOf: Bundle.main.url(forResource: "Info", withExtension: "plist")!)
let version = dict?.object(forKey: "CFBundleShortVersionString") as? String ?? ""
let build = dict?.object(forKey: "CFBundleVersion") as? String ?? ""
return "NetNewsWire \(version) (Build \(build))"
}
} }
struct SettingsView_Previews: PreviewProvider { struct SettingsView_Previews: PreviewProvider {