[+] Display local alarms in Alarm table

This commit is contained in:
Hykilpikonna
2021-01-17 13:01:17 -05:00
parent bbd1520f5d
commit 0571645df7
3 changed files with 5 additions and 9 deletions
+2 -2
View File
@@ -10,8 +10,7 @@ import Foundation
/** /**
Class to activate alarms when the user is inside the app Class to activate alarms when the user is inside the app
Note: This will not run when app is switched to the background, Note: This will not run when app is switched to the background or when the display is turned off, but it will run right after the user switched back to the app.
but it will run right after the user switched back to the app.
*/ */
class AlarmActivator class AlarmActivator
{ {
@@ -44,6 +43,7 @@ class AlarmActivator
*/ */
@objc func check() @objc func check()
{ {
NSLog("Check") NSLog("Check")
} }
} }
+2 -5
View File
@@ -4,9 +4,6 @@ class AlarmViewController: UIViewController
{ {
@IBOutlet weak var table: UITableView! @IBOutlet weak var table: UITableView!
// TODO: Remove example and use localStorage
var data: [Alarm] = [Alarm(alarmTime: Date(), text: "Wake up lol", wakeMethod: wvms[0])]
override func viewDidLoad() override func viewDidLoad()
{ {
super.viewDidLoad() super.viewDidLoad()
@@ -26,7 +23,7 @@ extension AlarmViewController: UITableViewDelegate, UITableViewDataSource
func numberOfSections(in: UITableView) -> Int { return 1 } func numberOfSections(in: UITableView) -> Int { return 1 }
/// How many rows are there /// How many rows are there
func tableView(_ v: UITableView, numberOfRowsInSection s: Int) -> Int { return data.count } func tableView(_ v: UITableView, numberOfRowsInSection s: Int) -> Int { return getLocalAlarms().count }
/// Configure each cell /// Configure each cell
func tableView(_ v: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell func tableView(_ v: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell
@@ -34,7 +31,7 @@ extension AlarmViewController: UITableViewDelegate, UITableViewDataSource
// Get the cell and item at index i // Get the cell and item at index i
let rawCell = v.dequeueReusableCell(withIdentifier: "alarm", for: i) let rawCell = v.dequeueReusableCell(withIdentifier: "alarm", for: i)
guard let cell = rawCell as? AlarmTableCell else { return rawCell } guard let cell = rawCell as? AlarmTableCell else { return rawCell }
let item = data[i.row] let item = getLocalAlarms()[i.row]
// Set the content of the cell to the content of the item. // Set the content of the cell to the content of the item.
cell.setData(item) cell.setData(item)
+1 -2
View File
@@ -64,7 +64,7 @@
<rect key="frame" x="345" y="26" width="51" height="31"/> <rect key="frame" x="345" y="26" width="51" height="31"/>
</switch> </switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="(Going off in 23 hr 22 m)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EPJ-eL-Kek"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="(Going off in 23 hr 22 m)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EPJ-eL-Kek">
<rect key="frame" x="179" y="68" width="215" height="21"/> <rect key="frame" x="179" y="74.5" width="215" height="14.5"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/> <fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" systemColor="secondaryLabelColor"/> <color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
@@ -79,7 +79,6 @@
<constraint firstItem="mjO-SX-f31" firstAttribute="leading" secondItem="Wl6-IQ-lVM" secondAttribute="leadingMargin" constant="10" id="VOR-Go-oCw"/> <constraint firstItem="mjO-SX-f31" firstAttribute="leading" secondItem="Wl6-IQ-lVM" secondAttribute="leadingMargin" constant="10" id="VOR-Go-oCw"/>
<constraint firstItem="EPJ-eL-Kek" firstAttribute="baseline" secondItem="YhV-X3-y1v" secondAttribute="firstBaseline" id="ilR-ei-lE6"/> <constraint firstItem="EPJ-eL-Kek" firstAttribute="baseline" secondItem="YhV-X3-y1v" secondAttribute="firstBaseline" id="ilR-ei-lE6"/>
<constraint firstItem="dWq-jh-9Ue" firstAttribute="leading" secondItem="mjO-SX-f31" secondAttribute="trailing" constant="8" symbolic="YES" id="ocx-bN-3M8"/> <constraint firstItem="dWq-jh-9Ue" firstAttribute="leading" secondItem="mjO-SX-f31" secondAttribute="trailing" constant="8" symbolic="YES" id="ocx-bN-3M8"/>
<constraint firstItem="EPJ-eL-Kek" firstAttribute="top" secondItem="4hj-fb-FF3" secondAttribute="bottom" constant="11" id="oon-Hl-9Jj"/>
<constraint firstItem="EPJ-eL-Kek" firstAttribute="leading" secondItem="YhV-X3-y1v" secondAttribute="trailing" constant="8" symbolic="YES" id="po7-2V-fZ6"/> <constraint firstItem="EPJ-eL-Kek" firstAttribute="leading" secondItem="YhV-X3-y1v" secondAttribute="trailing" constant="8" symbolic="YES" id="po7-2V-fZ6"/>
<constraint firstItem="4hj-fb-FF3" firstAttribute="top" secondItem="Wl6-IQ-lVM" secondAttribute="topMargin" constant="25" id="r6f-mB-n9x"/> <constraint firstItem="4hj-fb-FF3" firstAttribute="top" secondItem="Wl6-IQ-lVM" secondAttribute="topMargin" constant="25" id="r6f-mB-n9x"/>
<constraint firstAttribute="trailingMargin" secondItem="4hj-fb-FF3" secondAttribute="trailing" id="rvF-yI-tOC"/> <constraint firstAttribute="trailingMargin" secondItem="4hj-fb-FF3" secondAttribute="trailing" id="rvF-yI-tOC"/>