[+] Implement add alarm to a family member

This commit is contained in:
Hykilpikonna
2021-01-26 17:39:49 -05:00
parent 98025265a8
commit 3c1c05d40e
+16 -9
View File
@@ -344,6 +344,8 @@ class FamilyVC: UIViewController
*/ */
extension FamilyVC: UITableViewDelegate, UITableViewDataSource extension FamilyVC: UITableViewDelegate, UITableViewDataSource
{ {
static var selectedUser: String = ""
/** /**
Define row count Define row count
*/ */
@@ -368,7 +370,7 @@ extension FamilyVC: UITableViewDelegate, UITableViewDataSource
*/ */
func tableView(_ view: UITableView, didSelectRowAt i: IndexPath) func tableView(_ view: UITableView, didSelectRowAt i: IndexPath)
{ {
print(i.row) FamilyVC.selectedUser = Family.fromLocal()!.membersList[i.row]
view.deselectRow(at: i, animated: true) view.deselectRow(at: i, animated: true)
} }
} }
@@ -465,7 +467,7 @@ class FamilyCreateJoinVC: UIViewController
/** /**
View controller for adding an alarm to a fmaily member View controller for adding an alarm to a fmaily member
*/ */
class FamilyAddAlarmVC: UIViewController class FamilyAddAlarmVC: UIViewController, UITableViewDelegate, UITableViewDataSource
{ {
@IBOutlet weak var table: UITableView! @IBOutlet weak var table: UITableView!
@@ -476,13 +478,7 @@ class FamilyAddAlarmVC: UIViewController
table.delegate = self table.delegate = self
table.dataSource = self table.dataSource = self
} }
}
/**
Table data source
*/
extension FamilyAddAlarmVC: UITableViewDelegate, UITableViewDataSource
{
/** /**
Define row count Define row count
*/ */
@@ -507,5 +503,16 @@ extension FamilyAddAlarmVC: UITableViewDelegate, UITableViewDataSource
func tableView(_ view: UITableView, didSelectRowAt i: IndexPath) func tableView(_ view: UITableView, didSelectRowAt i: IndexPath)
{ {
view.deselectRow(at: i, animated: true) view.deselectRow(at: i, animated: true)
enterPin()
{
self.sendReq(APIs.familyAddAlarm, title: "Adding...", params: ["to": FamilyVC.selectedUser, "pin": $0, "alarm": JSON.stringify(Alarms.fromLocal().list[i.row])!])
{
print($0)
self.msg("Added!", "The member will receive the alarm after opening the app.")
{
self.dismiss()
}
}
}
} }
} }