Skip to content

Commit

Permalink
Merge pull request #49 from kumpeapps/Development
Browse files Browse the repository at this point in the history
Release 2.2.0
  • Loading branch information
justinkumpe authored Jul 10, 2021
2 parents 79ef4da + 3cd9966 commit f6832aa
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 51 deletions.
8 changes: 4 additions & 4 deletions KKid.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -835,15 +835,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = KKid/KKid.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.1.2.4;
CURRENT_PROJECT_VERSION = 2.2.0.1;
DEVELOPMENT_TEAM = 2T42Z3DM34;
INFOPLIST_FILE = KKid/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.kumpeapps.ios.KKid;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -858,15 +858,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = KKid/KKid.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.1.2.4;
CURRENT_PROJECT_VERSION = 2.2.0.1;
DEVELOPMENT_TEAM = 2T42Z3DM34;
INFOPLIST_FILE = KKid/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.kumpeapps.ios.KKid;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
8 changes: 8 additions & 0 deletions KKid/Controller/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import DeviceKit
import KumpeHelpers
import Snowflake
import AVFoundation
import WhatsNew

class HomeViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, PrivacyKitDelegate {

Expand All @@ -40,6 +41,12 @@ class HomeViewController: UIViewController, UICollectionViewDelegate, UICollecti
var choreCount: Int = 0
let iconCache = ImageCache(name: "iconCache")

// MARK: WhatsNew Parameters
let whatsNew = WhatsNewViewController(items: [
WhatsNewItem.text(title: "Notifications Management", subtitle: "Users now have the ability to manage push notifications subscriptions in the Edit Profile screen!"),
WhatsNewItem.text(title: "What's New Banner", subtitle: "Well this one is self explanatory. This banner telling you what is new when updates are released is new.")
])

// MARK: viewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -109,6 +116,7 @@ class HomeViewController: UIViewController, UICollectionViewDelegate, UICollecti
}

self.requirePrivacy()
whatsNew.presentIfNeeded(on: self)
}

// MARK: viewWillDisappear
Expand Down
32 changes: 31 additions & 1 deletion KKid/Controller/UserEditProfileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class UserEditProfileViewController: FormViewController {
enableAllowance.value = selectedUser.enableAllowance
enableAdmin.value = selectedUser.isAdmin
enableTmdb.value = selectedUser.enableTmdb
pushChoresNew.value = selectedUser.pushChoresNew
pushChoresReminders.value = selectedUser.pushChoresReminders
pushAllowanceNew.value = selectedUser.pushAllowanceNew
}

// MARK: loadView
Expand All @@ -47,11 +50,20 @@ class UserEditProfileViewController: FormViewController {
builder += lastName
builder += emoji
if LoggedInUser.user!.isAdmin {
builder += SectionHeaderTitleFormItem().title("Module Access Permissions")
builder += enableChores
builder += enableAllowance
builder += enableAdmin
builder += enableTmdb
}
builder += SectionHeaderTitleFormItem().title("Push Notifications")
if selectedUser.enableChores {
builder += pushChoresNew
builder += pushChoresReminders
}
if selectedUser.enableAllowance {
builder += pushAllowanceNew
}
builder += SectionHeaderTitleFormItem().title("Link Accounts")
builder += tmdbButton
}
Expand Down Expand Up @@ -121,6 +133,24 @@ class UserEditProfileViewController: FormViewController {
return instance
}()

// MARK: pushChoresNew Field
lazy var pushChoresNew: SwitchFormItem = {
let instance = SwitchFormItem().title("New Chore Notifications")
return instance
}()

// MARK: pushChoresReminders Field
lazy var pushChoresReminders: SwitchFormItem = {
let instance = SwitchFormItem().title("Chore Reminders")
return instance
}()

// MARK: pushAllowanceNew Field
lazy var pushAllowanceNew: SwitchFormItem = {
let instance = SwitchFormItem().title("New Allowance Notifications")
return instance
}()

// MARK: tmdbButton
lazy var tmdbButton: ButtonFormItem = {
let instance = ButtonFormItem()
Expand Down Expand Up @@ -157,7 +187,7 @@ class UserEditProfileViewController: FormViewController {
return
}

KKidClient.updateUser(username: username.value, email: email.value, firstName: firstName.value, lastName: lastName.value, user: selectedUser, emoji: emoji.value, enableAllowance: enableAllowance.value, enableChores: enableChores.value, enableAdmin: enableAdmin.value, enableTmdb: enableTmdb.value, tmdbKey: nil) { (success, error) in
KKidClient.updateUser(username: username.value, email: email.value, firstName: firstName.value, lastName: lastName.value, user: selectedUser, emoji: emoji.value, enableAllowance: enableAllowance.value, enableChores: enableChores.value, enableAdmin: enableAdmin.value, enableTmdb: enableTmdb.value, tmdbKey: nil, pushChoresNew: pushChoresNew.value, pushChoresReminders: pushChoresReminders.value, pushAllowanceNew: pushAllowanceNew.value) { (success, error) in
if success {
dispatchOnMain {
self.navigationController?.popViewController(animated: true)
Expand Down
16 changes: 0 additions & 16 deletions KKid/Model/KKid Client/KKidClient+DELETE.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,6 @@ extension KKidClient {
}
}

// MARK: unsubscribeAPNS
class func unsubscribeAPNS(user: User, section: String) {
let parameters = [
"apiUsername": KKidClient.username,
"apiPassword": KKidClient.apiPassword,
"apiKey":"\(UserDefaults.standard.value(forKey: "apiKey") ?? "null")",
"kidUserId":"\(user.userID)",
"appName":"com.kumpeapps.ios.kkid",
"masterID":"\(user.masterID)",
"section":"\(section)",
"tool":"unsubscribe"
]
apiDelete(silent: true, module: "apns", parameters: parameters) { (_, _) in
}
}

// MARK: apiDelete
class func apiDelete(silent: Bool = false, module: String, parameters: [String: Any], blockInterface: Bool = false, completion: @escaping (Bool, String?) -> Void) {
apiMethod(silent: silent, method: .delete, module: module, parameters: parameters, blockInterface: blockInterface) { (success, error) in
Expand Down
16 changes: 16 additions & 0 deletions KKid/Model/KKid Client/KKidClient+POST.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ extension KKidClient {
}
}

// MARK: unsubscribeAPNS
class func unsubscribeAPNS(user: User, section: String) {
let parameters = [
"apiUsername": KKidClient.username,
"apiPassword": KKidClient.apiPassword,
"apiKey":"\(UserDefaults.standard.value(forKey: "apiKey") ?? "null")",
"kidUserId":"\(user.userID)",
"appName":"com.kumpeapps.ios.kkid",
"masterID":"\(user.masterID)",
"section":"\(section)",
"tool":"unsubscribe"
]
apiPost(silent: true, module: "apns", parameters: parameters) { (_, _) in
}
}

// MARK: apiPost
class func apiPost(silent: Bool = false, module: String, parameters: [String: Any], blockInterface: Bool = false, completion: @escaping (Bool, String?) -> Void) {
apiMethod(silent: silent, method: .post, module: module, parameters: parameters, blockInterface: blockInterface) { (success, error) in
Expand Down
35 changes: 34 additions & 1 deletion KKid/Model/KKid Client/KKidClient+PUT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extension KKidClient {
}

// MARK: updateUser
class func updateUser(username: String, email: String, firstName: String, lastName: String, user: User, emoji: String, enableAllowance: Bool, enableChores: Bool, enableAdmin: Bool, enableTmdb: Bool, tmdbKey: String?, completion: @escaping (Bool, String?) -> Void) {
class func updateUser(username: String, email: String, firstName: String, lastName: String, user: User, emoji: String, enableAllowance: Bool, enableChores: Bool, enableAdmin: Bool, enableTmdb: Bool, tmdbKey: String?, pushChoresNew: Bool = true, pushChoresReminders: Bool = true, pushAllowanceNew: Bool = true, completion: @escaping (Bool, String?) -> Void) {
var parameters = [
"apiUsername": KKidClient.username,
"apiPassword": KKidClient.apiPassword,
Expand Down Expand Up @@ -82,10 +82,43 @@ extension KKidClient {

let module = "userlist"
apiPut(module: module, parameters: parameters, blockInterface: true) { (success, error) in
if success {
updatePushNotifications(user: user, pushChoresNew: pushChoresNew, pushChoresReminders: pushChoresReminders, pushAllowanceNew: pushAllowanceNew)
}
completion(success, error)
}
}

// MARK: updatePushNotifications
class func updatePushNotifications(user: User, pushChoresNew: Bool, pushChoresReminders: Bool, pushAllowanceNew: Bool) {
if user.pushChoresNew != pushChoresNew {
switch pushChoresNew {
case false:
unsubscribeAPNS(user: user, section: "Chores-New")
default:
subscribeAPNS(user: user, section: "Chores-New")
}
}

if user.pushChoresReminders != pushChoresReminders {
switch pushChoresReminders {
case false:
unsubscribeAPNS(user: user, section: "Chores-Reminders")
default:
subscribeAPNS(user: user, section: "Chores-Remidners")
}
}

if user.pushAllowanceNew != pushAllowanceNew {
switch pushAllowanceNew {
case false:
unsubscribeAPNS(user: user, section: "Allowance-New")
default:
subscribeAPNS(user: user, section: "Allowance-New")
}
}
}

// MARK: apiPut
class func apiPut(silent: Bool = false, module: String, parameters: [String: Any], blockInterface: Bool = false, completion: @escaping (Bool, String?) -> Void) {
apiMethod(silent: silent, method: .put, module: module, parameters: parameters, blockInterface: blockInterface) { (success, error) in
Expand Down
1 change: 1 addition & 0 deletions KKid/Model/KKid Client/KKidClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class KKidClient {
guard statusCode >= 200 && statusCode <= 299 else {
Logger.log(.error, "Your request returned a status code other than 2xx! (\(String(describing: dataResponse.response?.statusCode)))")
ShowAlert.dismissStatic(id: alertId)

var errorMessage = "Unknown Error Occurred"
switch statusCode {
case 412: errorMessage = "API Key Not Valid"
Expand Down
9 changes: 7 additions & 2 deletions KKid/Model/KKid.xcdatamodeld/KKid.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17709" systemVersion="20C69" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17709" systemVersion="20E241" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Chore" representedClassName="Chore" syncable="YES" codeGenerationType="class">
<attribute name="aiIcon" optional="YES" attributeType="String"/>
<attribute name="altitude" optional="YES" attributeType="Float" defaultValueString="0.0" usesScalarValueType="YES"/>
Expand Down Expand Up @@ -56,6 +56,11 @@
<attribute name="isMaster" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="lastName" optional="YES" attributeType="String"/>
<attribute name="masterID" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="pushAllowance" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="pushAllowanceNew" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="pushChores" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="pushChoresNew" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="pushChoresReminders" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="tmdbKey" optional="YES" attributeType="String"/>
<attribute name="userID" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES">
<userInfo>
Expand All @@ -67,6 +72,6 @@
</entity>
<elements>
<element name="Chore" positionX="-304.6484375" positionY="-4.40234375" width="128" height="434"/>
<element name="User" positionX="-603.27734375" positionY="2.0703125" width="128" height="374"/>
<element name="User" positionX="-603.27734375" positionY="2.0703125" width="128" height="449"/>
</elements>
</model>
Loading

0 comments on commit f6832aa

Please sign in to comment.