[+] Implement delete family
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,7 +1075,7 @@
|
||||
<rect key="frame" x="20" y="75" width="374" height="575"/>
|
||||
<subviews>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="vpv-oC-dfU">
|
||||
<rect key="frame" x="0.0" y="0.0" width="374" height="70"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="374" height="110"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="R2H-k5-27v">
|
||||
<rect key="frame" x="0.0" y="0.0" width="374" height="30"/>
|
||||
@@ -1087,12 +1087,21 @@
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="De7-dU-p8j">
|
||||
<rect key="frame" x="0.0" y="40" width="374" height="30"/>
|
||||
<state key="normal" title="Leave Family">
|
||||
<color key="titleColor" systemColor="systemRedColor"/>
|
||||
<color key="titleColor" systemColor="systemOrangeColor"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="btnLeave:" destination="4ss-Ye-Da4" eventType="touchUpInside" id="YMe-ri-xkZ"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" tag="1" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mA7-bI-2hr">
|
||||
<rect key="frame" x="0.0" y="80" width="374" height="30"/>
|
||||
<state key="normal" title="Delete Family">
|
||||
<color key="titleColor" systemColor="systemRedColor"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="btnLeave:" destination="4ss-Ye-Da4" eventType="touchUpInside" id="S6Z-gL-u2U"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</stackView>
|
||||
</subviews>
|
||||
|
||||
Reference in New Issue
Block a user