From b910afe671ffcc270d95489c1eca68706b10c42f Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Thu, 28 Jan 2021 17:08:57 -0800 Subject: [PATCH] Add about and acknowledgements --- Localizations/Localizable.strings | 4 + Metatext.xcodeproj/project.pbxproj | 8 ++ Views/AboutView.swift | 46 ++++++++ Views/AcknowledgmentsView.swift | 163 ++++++++++++++++++++++++++++ Views/SecondaryNavigationView.swift | 5 + 5 files changed, 226 insertions(+) create mode 100644 Views/AboutView.swift create mode 100644 Views/AcknowledgmentsView.swift diff --git a/Localizations/Localizable.strings b/Localizations/Localizable.strings index 9003aa6..e0a6a92 100644 --- a/Localizations/Localizable.strings +++ b/Localizations/Localizable.strings @@ -1,5 +1,7 @@ // Copyright © 2020 Metabolist. All rights reserved. +"about" = "About"; +"about.acknowledgments" = "Acknowledgments"; "account.%@-followers" = "%@'s Followers"; "account.block" = "Block"; "account.block.confirm-%@" = "Block %@?"; @@ -85,6 +87,7 @@ "registration.terms-of-service" = "Terms of service"; "registration.agree-to-server-rules-and-terms-of-service" = "I agree to the server rules and terms of service"; "registration.password-confirmation-mismatch" = "Password and password confirmation do not match"; +"secondary-navigation.about" = "About This App"; "secondary-navigation.accounts" = "Accounts"; "secondary-navigation.lists" = "Lists"; "secondary-navigation.my-profile" = "My Profile"; @@ -98,6 +101,7 @@ "main-navigation.explore" = "Explore"; "main-navigation.notifications" = "Notifications"; "main-navigation.conversations" = "Messages"; +"metatext" = "Metatext"; "notifications.all" = "All"; "notifications.mentions" = "Mentions"; "ok" = "OK"; diff --git a/Metatext.xcodeproj/project.pbxproj b/Metatext.xcodeproj/project.pbxproj index cabc51a..bbb06f3 100644 --- a/Metatext.xcodeproj/project.pbxproj +++ b/Metatext.xcodeproj/project.pbxproj @@ -26,6 +26,8 @@ D021A60A25C36B32008A0C0D /* IdentityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D021A60925C36B32008A0C0D /* IdentityTableViewCell.swift */; }; D021A61425C36BFB008A0C0D /* IdentityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D021A61325C36BFB008A0C0D /* IdentityView.swift */; }; D021A61A25C36C1A008A0C0D /* IdentityContentConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = D021A61925C36C1A008A0C0D /* IdentityContentConfiguration.swift */; }; + D021A62C25C38570008A0C0D /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D021A62B25C38570008A0C0D /* AboutView.swift */; }; + D021A63625C38ADB008A0C0D /* AcknowledgmentsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D021A63525C38ADB008A0C0D /* AcknowledgmentsView.swift */; }; D02E1F95250B13210071AD56 /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D02E1F94250B13210071AD56 /* SafariView.swift */; }; D035F86925B7F2ED00DC75ED /* MainNavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D035F86825B7F2ED00DC75ED /* MainNavigationViewController.swift */; }; D035F86F25B7F30E00DC75ED /* MainNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D035F86E25B7F30E00DC75ED /* MainNavigationView.swift */; }; @@ -223,6 +225,8 @@ D021A60925C36B32008A0C0D /* IdentityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityTableViewCell.swift; sourceTree = ""; }; D021A61325C36BFB008A0C0D /* IdentityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityView.swift; sourceTree = ""; }; D021A61925C36C1A008A0C0D /* IdentityContentConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityContentConfiguration.swift; sourceTree = ""; }; + D021A62B25C38570008A0C0D /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = ""; }; + D021A63525C38ADB008A0C0D /* AcknowledgmentsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcknowledgmentsView.swift; sourceTree = ""; }; D02E1F94250B13210071AD56 /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = ""; }; D035F86825B7F2ED00DC75ED /* MainNavigationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainNavigationViewController.swift; sourceTree = ""; }; D035F86E25B7F30E00DC75ED /* MainNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainNavigationView.swift; sourceTree = ""; }; @@ -506,11 +510,13 @@ D0C7D42024F76169001EBDBB /* Views */ = { isa = PBXGroup; children = ( + D021A62B25C38570008A0C0D /* AboutView.swift */, D0F0B112251A86A000942152 /* AccountContentConfiguration.swift */, D0070251255921B100F38136 /* AccountFieldView.swift */, D01EF22325182B1F00650C6B /* AccountHeaderView.swift */, D0F0B125251A90F400942152 /* AccountListCell.swift */, D0F0B10D251A868200942152 /* AccountView.swift */, + D021A63525C38ADB008A0C0D /* AcknowledgmentsView.swift */, D0C7D42424F76169001EBDBB /* AddIdentityView.swift */, D01F41E224F8889700D55A2D /* AttachmentsView.swift */, D0CE9F86258B076900E3A6B6 /* AttachmentUploadView.swift */, @@ -863,6 +869,7 @@ buildActionMask = 2147483647; files = ( D02E1F95250B13210071AD56 /* SafariView.swift in Sources */, + D021A63625C38ADB008A0C0D /* AcknowledgmentsView.swift in Sources */, D07EC7CF25B13921006DF726 /* PickerEmoji+Extensions.swift in Sources */, D00702292555E51200F38136 /* ConversationListCell.swift in Sources */, D03B1B2A253818F3008F964B /* MediaPreferencesView.swift in Sources */, @@ -921,6 +928,7 @@ D07EC7F225B13E57006DF726 /* EmojiView.swift in Sources */, D05936CF25A8D79800754FDF /* EditAttachmentViewController.swift in Sources */, D0C7D4A224F7616A001EBDBB /* NotificationTypesPreferencesView.swift in Sources */, + D021A62C25C38570008A0C0D /* AboutView.swift in Sources */, D00702362555F4C500F38136 /* ConversationContentConfiguration.swift in Sources */, D0BEB1F724F9A84B001B0F04 /* LoadingTableFooterView.swift in Sources */, D021A61425C36BFB008A0C0D /* IdentityView.swift in Sources */, diff --git a/Views/AboutView.swift b/Views/AboutView.swift new file mode 100644 index 0000000..1857981 --- /dev/null +++ b/Views/AboutView.swift @@ -0,0 +1,46 @@ +// Copyright © 2021 Metabolist. All rights reserved. + +import SwiftUI + +struct AboutView: View { + 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) + Section { + NavigationLink( + destination: AcknowledgmentsView()) { + Label("about.acknowledgments", systemImage: "curlybraces") + } + } + } + .navigationTitle("about") + } +} + +private extension AboutView { + 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 { + AboutView() + } +} +#endif diff --git a/Views/AcknowledgmentsView.swift b/Views/AcknowledgmentsView.swift new file mode 100644 index 0000000..c1cfacf --- /dev/null +++ b/Views/AcknowledgmentsView.swift @@ -0,0 +1,163 @@ +// Copyright © 2021 Metabolist. All rights reserved. + +import SwiftUI + +struct AcknowledgmentsView: View { + var body: some View { + ScrollView { + VStack(alignment: .leading) { + ForEach(Acknowledgment.allCases) { acknowledgment in + Link(acknowledgment.name, destination: acknowledgment.url) + .font(.headline) + .padding([.top, .bottom]) + Text(verbatim: acknowledgment.license) + Divider() + } + } + .padding() + } + .navigationTitle("about.acknowledgments") + } +} + +private extension AcknowledgmentsView { + enum Acknowledgment: CaseIterable { + case combineExpectations + case grdb + case kingfisher + case sqlcipher + } +} + +extension AcknowledgmentsView.Acknowledgment { + var name: String { + switch self { + case .combineExpectations: + return "CombineExpectations" + case .grdb: + return "GRDB" + case .kingfisher: + return "Kingfisher" + case .sqlcipher: + return "SQLCipher" + } + } + + var url: URL { + switch self { + case .combineExpectations: + return URL(string: "https://github.com/groue/CombineExpectations")! + case .grdb: + return URL(string: "https://github.com/groue/GRDB.swift")! + case .kingfisher: + return URL(string: "https://github.com/onevcat/Kingfisher")! + case .sqlcipher: + return URL(string: "https://www.zetetic.net/sqlcipher")! + } + } + +// swiftlint:disable line_length + var license: String { + switch self { + case .combineExpectations: + return """ +Copyright (C) 2019 Gwendal Roué + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +""" + case .grdb: + return """ +Copyright (C) 2015-2020 Gwendal Roué + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +""" + case .kingfisher: + return """ +The MIT License (MIT) + +Copyright (c) 2019 Wei Wang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + case .sqlcipher: + return """ +Copyright (c) 2008-2020 Zetetic LLC +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the ZETETIC LLC nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +""" + } + } + // swiftlint:enable line_length +} + +extension AcknowledgmentsView.Acknowledgment: Identifiable { + var id: Self { self } +} + +#if DEBUG +import PreviewViewModels + +struct AcknowledgmentsView_Previews: PreviewProvider { + static var previews: some View { + AcknowledgmentsView() + } +} +#endif diff --git a/Views/SecondaryNavigationView.swift b/Views/SecondaryNavigationView.swift index 7dfc5d5..90fce3f 100644 --- a/Views/SecondaryNavigationView.swift +++ b/Views/SecondaryNavigationView.swift @@ -68,6 +68,11 @@ struct SecondaryNavigationView: View { .environmentObject(rootViewModel)) { Label("secondary-navigation.preferences", systemImage: "gear") } + NavigationLink( + destination: AboutView() + .environmentObject(rootViewModel)) { + Label("secondary-navigation.about", systemImage: "info.circle") + } } } }