From 939396d8fb357bf859e6730e19693f81b4504b9b Mon Sep 17 00:00:00 2001 From: W1W1-M Date: Sun, 7 Nov 2021 14:37:10 +0100 Subject: [PATCH] Update readme. Add third party code licenses. Rename app settings & user preferences. Update comments. Adjust default texts --- README.md | 10 +++--- Sources/PackAPrefPane/Views/AppInfo.swift | 33 +++++++++++++++---- Sources/PackAPrefPane/Views/AppSettings.swift | 8 ++--- Sources/PackAPrefPane/Views/Help.swift | 6 ++-- .../PackAPrefPane/Views/PackAPrefPane.swift | 33 +++++++++---------- .../PackAPrefPane/Views/UserPreferences.swift | 8 ++--- 6 files changed, 59 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 4ee9f56..213eee5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# PackAPrefPane +# **PackAPrefPane** -## Reusable & customizable SwiftUI settings sheet as a Swift package +## *Reusable & customizable SwiftUI settings sheet as a Swift package* ## Features -### v1.0 made at November 2021 SwiftUI Jam https://www.swiftuijam.com + * Swift package * 100% Swift * 99% SwiftUI @@ -11,8 +11,10 @@ * Lightweight * Customizable * Nothing exotic -* Open source +* Open source MIT license * Target: iOS 14 > ## Project resources * Mind map in MindNode format + +### Initial version made at November 2021 SwiftUI Jam https://www.swiftuijam.com diff --git a/Sources/PackAPrefPane/Views/AppInfo.swift b/Sources/PackAPrefPane/Views/AppInfo.swift index 6ba7f77..2a748ea 100644 --- a/Sources/PackAPrefPane/Views/AppInfo.swift +++ b/Sources/PackAPrefPane/Views/AppInfo.swift @@ -22,19 +22,19 @@ struct AppInfo: View { VStack { HStack { Spacer() - Text("Designed & Developped in 🇫🇷") + Text("Designed & Developped in 🏴‍☠️") Spacer() } HStack { Spacer() - Text("by William Mead") + Text("by a super dev") Spacer() } }.padding(3) .font(.callout) HStack { Spacer() - Text("Copyright © 2021-2022") + Text("Your app Copyright © 2021-2022") Spacer() }.font(.callout) } @@ -46,9 +46,16 @@ struct AppInfo: View { } Spacer() HStack { - Link("github.com/W1W1-M/PackAPrefPane", destination: URL(string: "https://github.com/W1W1-M/PackAPrefPane")!).foregroundColor(.accentColor) + Link("github.com/W1W1-M/PackAPrefPane", destination: URL(string: "https://github.com/W1W1-M/PackAPrefPane")!) + .font(.callout) + .foregroundColor(.accentColor) Spacer() } + Spacer() + HStack { + Spacer() + Text("MIT license").font(.subheadline) + } } VStack { HStack { @@ -57,8 +64,15 @@ struct AppInfo: View { } Spacer() HStack { - Link("developer.apple.com/fonts", destination: URL(string: "https://developer.apple.com/fonts")!).foregroundColor(.accentColor) + Link("developer.apple.com/fonts", destination: URL(string: "https://developer.apple.com/fonts")!) + .font(.callout) + .foregroundColor(.accentColor) + Spacer() + } + Spacer() + HStack { Spacer() + Text("Copyright © All rights reserved").font(.subheadline) } } VStack { @@ -68,8 +82,15 @@ struct AppInfo: View { } Spacer() HStack { - Link("github.com", destination: URL(string: "https://github.com")!).foregroundColor(.accentColor) + Link("github.com", destination: URL(string: "https://github.com")!) + .font(.callout) + .foregroundColor(.accentColor) + Spacer() + } + Spacer() + HStack { Spacer() + Text("some license").font(.subheadline) } } } diff --git a/Sources/PackAPrefPane/Views/AppSettings.swift b/Sources/PackAPrefPane/Views/AppSettings.swift index 83abfa9..89a2ddb 100644 --- a/Sources/PackAPrefPane/Views/AppSettings.swift +++ b/Sources/PackAPrefPane/Views/AppSettings.swift @@ -1,5 +1,5 @@ // -// UserPreferences.swift +// AppSettings().swift // // // Created by William Mead on 06/11/2021. @@ -7,7 +7,7 @@ // MARK: - Modules import SwiftUI // MARK: - Views -struct UserPreferences: View { +struct AppSettings: View { // Variables @State var someAppSetting: Bool = false // UI @@ -22,8 +22,8 @@ struct UserPreferences: View { } } // MARK: - Previews -struct UserPreferences_Previews: PreviewProvider { +struct AppSettings_Previews: PreviewProvider { static var previews: some View { - Form{UserPreferences()}.previewLayout(.sizeThatFits) + Form{AppSettings()}.previewLayout(.sizeThatFits) } } diff --git a/Sources/PackAPrefPane/Views/Help.swift b/Sources/PackAPrefPane/Views/Help.swift index 6ab11f9..f238935 100644 --- a/Sources/PackAPrefPane/Views/Help.swift +++ b/Sources/PackAPrefPane/Views/Help.swift @@ -16,7 +16,7 @@ struct Help: View { let appVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String // UI var body: some View { - Section(header: Text("⛑ Help")) { // Customize this view + Section(header: Text("🆘 Help")) { // Customize this view Button(action: { PrefPaneHelper.appFeedback() }, label: { @@ -54,12 +54,12 @@ struct Help: View { DisclosureGroup("FAQ", isExpanded: $faqExpanded) { VStack { HStack { - Text("Q.1: How is the thing calculated ?").font(.headline) + Text("Q.1: How is this example calculated ?").font(.headline) Spacer() } Spacer() HStack { - Text("A.1: The thing's percentage is calculated by dividing the combined amount of this from each of that by the total quantity of those.") + Text("A.1: The example's percentage is calculated by dividing the combined amount of this from each of that by the total quantity of those.") Spacer() } } diff --git a/Sources/PackAPrefPane/Views/PackAPrefPane.swift b/Sources/PackAPrefPane/Views/PackAPrefPane.swift index db7cf98..e1b5be9 100644 --- a/Sources/PackAPrefPane/Views/PackAPrefPane.swift +++ b/Sources/PackAPrefPane/Views/PackAPrefPane.swift @@ -9,8 +9,8 @@ import SwiftUI // MARK: - Views @available(iOS 14, *) public struct PackAPrefPane: View { - // MARK: - Variables - public init(settingsSheetPresented: Binding) { + // Variables + public init(settingsSheetPresented: Binding) { // public init for public struct self._settingsSheetPresented = settingsSheetPresented } @Environment(\.managedObjectContext) private var viewContext @@ -23,7 +23,7 @@ public struct PackAPrefPane: View { case specialThanksAlert case supportAlert } - // MARK: - UI + // UI public var body: some View { NavigationView { Form { @@ -44,11 +44,11 @@ public struct PackAPrefPane: View { alertPresented: $alertPresented ) }.navigationTitle("Settings ⚙️") - .toolbar { + .toolbar { // Toolbar with cancel & save buttons ToolbarItem(placement: .cancellationAction) { Button(action: { // Cancel and rollback settings - // Helper.rollbackSettings() + // PrefPaneHelper.rollbackSettings() // Close settings sheet settingsSheetPresented.toggle() }, label: {Text("Cancel")}) @@ -56,24 +56,21 @@ public struct PackAPrefPane: View { ToolbarItem(placement: .confirmationAction) { Button(action: { // Save Settings - // Helper.saveSomeSettings() + // PrefPaneHelper.saveSomeSettings() // Set new app settings & user preferences - // Helper.setSomeAppSettings() - // Helper.setSomeUserPreferences() + // PrefPaneHelper.setSomeAppSettings() + // PrefPaneHelper.setSomeUserPreferences() // Close settings sheet settingsSheetPresented.toggle() }, label: {Text("Save")}) } } - }.onAppear(perform: { + }.onAppear(perform: { // Using onAppear modifier for loading user defaults // Load app settings & user preferences - // HelperClass.loadSomeAppSettings() - // HelperClass.loadSomeUserPreferences() + // PrefPaneHelper.loadSomeAppSettings() + // PrefPaneHelper.loadSomeUserPreferences() // Check if legal disclaimer accepted else show disclaimer alert - if(UserDefaults.standard.bool(forKey: "DisclaimerAccepted") == false) { - alert = .disclaimerAlert - alertPresented.toggle() - } + // PrefPaneHelper.checkLegalDisclaimer() }) // alert switch cases .alert(isPresented: $alertPresented, content: { @@ -84,13 +81,13 @@ public struct PackAPrefPane: View { message: Text("Use of this app is for informational purposes only. You alone are responsable for the usages you make of this app and you use it at your own risk. We accept no responsability for any damage to users or to their belongings as a result of using this app."), dismissButton: .default(Text("OK")) { // Legal disclaimer accepted - UserDefaults.standard.set(true, forKey: "DisclaimerAccepted") + // PrefPaneHelper.disclaimerAccepted() } ) case .privacyAlert: return Alert( title: Text("Privacy policy"), - message: Text("We don't store your data, The End."), + message: Text("We don't store your data."), dismissButton: .default(Text("OK")) ) case .specialThanksAlert: @@ -102,7 +99,7 @@ public struct PackAPrefPane: View { case .supportAlert: return Alert( title: Text("Send us an email"), - message: Text("w1w1_m@icloud.com"), + message: Text("youremail@someappdeveloper.com"), dismissButton: .default(Text("OK")) ) } diff --git a/Sources/PackAPrefPane/Views/UserPreferences.swift b/Sources/PackAPrefPane/Views/UserPreferences.swift index 54445fa..b50e0ea 100644 --- a/Sources/PackAPrefPane/Views/UserPreferences.swift +++ b/Sources/PackAPrefPane/Views/UserPreferences.swift @@ -1,5 +1,5 @@ // -// AppSettings.swift +// UserPreferences.swift // // // Created by William Mead on 06/11/2021. @@ -7,7 +7,7 @@ // MARK: - Modules import SwiftUI // MARK: - Views -struct AppSettings: View { +struct UserPreferences: View { // Variables @State var someUserPreference: Bool = false // UI @@ -22,8 +22,8 @@ struct AppSettings: View { } } // MARK: - Previews -struct AppSettings_Previews: PreviewProvider { +struct UserPreferences_Previews: PreviewProvider { static var previews: some View { - Form{AppSettings()}.previewLayout(.sizeThatFits) + Form{UserPreferences()}.previewLayout(.sizeThatFits) } }