Skip to content

Commit

Permalink
Update readme. Add third party code licenses. Rename app settings & u…
Browse files Browse the repository at this point in the history
…ser preferences. Update comments. Adjust default texts
  • Loading branch information
W1W1-M committed Nov 7, 2021
1 parent 00980c4 commit 939396d
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 39 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# 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
* Simple design
* 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
33 changes: 27 additions & 6 deletions Sources/PackAPrefPane/Views/AppInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/PackAPrefPane/Views/AppSettings.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// UserPreferences.swift
// AppSettings().swift
//
//
// Created by William Mead on 06/11/2021.
//
// MARK: - Modules
import SwiftUI
// MARK: - Views
struct UserPreferences: View {
struct AppSettings: View {
// Variables
@State var someAppSetting: Bool = false
// UI
Expand All @@ -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)
}
}
6 changes: 3 additions & 3 deletions Sources/PackAPrefPane/Views/Help.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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()
}
}
Expand Down
33 changes: 15 additions & 18 deletions Sources/PackAPrefPane/Views/PackAPrefPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import SwiftUI
// MARK: - Views
@available(iOS 14, *)
public struct PackAPrefPane: View {
// MARK: - Variables
public init(settingsSheetPresented: Binding<Bool>) {
// Variables
public init(settingsSheetPresented: Binding<Bool>) { // public init for public struct
self._settingsSheetPresented = settingsSheetPresented
}
@Environment(\.managedObjectContext) private var viewContext
Expand All @@ -23,7 +23,7 @@ public struct PackAPrefPane: View {
case specialThanksAlert
case supportAlert
}
// MARK: - UI
// UI
public var body: some View {
NavigationView {
Form {
Expand All @@ -44,36 +44,33 @@ 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")})
}
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: {
Expand All @@ -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:
Expand All @@ -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"))
)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/PackAPrefPane/Views/UserPreferences.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// AppSettings.swift
// UserPreferences.swift
//
//
// Created by William Mead on 06/11/2021.
//
// MARK: - Modules
import SwiftUI
// MARK: - Views
struct AppSettings: View {
struct UserPreferences: View {
// Variables
@State var someUserPreference: Bool = false
// UI
Expand All @@ -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)
}
}

0 comments on commit 939396d

Please sign in to comment.