From 2bda42b36dca648b107b17c2e41a96eb4bdeb96b Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 24 Jan 2021 21:12:24 -0500 Subject: [PATCH] [+] Implement delete family --- ProjectClock/AccountViewController.swift | 17 ++++++++++++----- ProjectClock/Base.lproj/Main.storyboard | 13 +++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ProjectClock/AccountViewController.swift b/ProjectClock/AccountViewController.swift index fbcd201..75f5497 100644 --- a/ProjectClock/AccountViewController.swift +++ b/ProjectClock/AccountViewController.swift @@ -262,16 +262,23 @@ class FamilyVC: UIViewController } /** - Called when the user clicks the leave family button + Called when the user clicks the leave or delete family button */ - @IBAction func btnLeave(_ sender: Any) + @IBAction func btnLeave(_ sender: UIButton) { + let i = sender.tag + let action = ["Leave", "Delete"][i] + let title = ["Leaving...", "Deleting..."][i] + let msg = ["You left the family.", "You deleted the family."][i] + enterPin() { - self.sendReq(APIs.familyChangePin, title: "Leaving...", params: ["pin": $0]) { it in + self.sendReq(APIs.familyAction, title: title, params: ["pin": $0, "action": action]) { it in - localStorage.removeObject(forKey: "family") - self.msg("Leave Success!", "You left the family.") + // Leave or delete, clear local storage's family section + if i == 0 || i == 1 { localStorage.removeObject(forKey: "family") } + + self.msg("\(action) Success!", msg) } } } diff --git a/ProjectClock/Base.lproj/Main.storyboard b/ProjectClock/Base.lproj/Main.storyboard index ebd3215..5c90cdc 100644 --- a/ProjectClock/Base.lproj/Main.storyboard +++ b/ProjectClock/Base.lproj/Main.storyboard @@ -1075,7 +1075,7 @@ - + +