diff --git a/ProjectClock/AlarmViewController.swift b/ProjectClock/AlarmViewController.swift
index 27c7083..17b0dfd 100644
--- a/ProjectClock/AlarmViewController.swift
+++ b/ProjectClock/AlarmViewController.swift
@@ -1,10 +1,3 @@
-//
-// AlarmViewController.swift
-// ProjectClock
-//
-// Created by Hykilpikonna on 1/13/21.
-//
-
import UIKit
class AlarmViewController: UIViewController
@@ -18,17 +11,24 @@ class AlarmViewController: UIViewController
{
super.viewDidLoad()
+ // Assign table delegate and data source
table.delegate = self
table.dataSource = self
}
}
+/**
+ Alarm table controller
+ */
extension AlarmViewController: UITableViewDelegate, UITableViewDataSource
{
+ /// How many sections are there
func numberOfSections(in: UITableView) -> Int { return 1 }
+ /// How many rows are there
func tableView(_ v: UITableView, numberOfRowsInSection s: Int) -> Int { return data.count }
+ /// Configure each cell
func tableView(_ v: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell
{
// Get the cell and item at index i
@@ -37,17 +37,21 @@ extension AlarmViewController: UITableViewDelegate, UITableViewDataSource
let item = data[i.row]
// Set the content of the cell to the content of the item.
- cell.descriptionText.text = item.text
+ cell.setData(item)
return cell
}
- /// This defines the height
+ /// Define cell height
func tableView(_ v: UITableView, heightForRowAt i: IndexPath) -> CGFloat { return 120 }
+ /// IDK what this does (TODO: Find out what this does)
func tableView(_ v: UITableView, didSelectRowAt i: IndexPath) { v.deselectRow(at: i, animated: true) }
}
+/**
+ Table cell that displays the information of each alarm.
+ */
class AlarmTableCell: UITableViewCell
{
@IBOutlet weak var time: UILabel!
@@ -56,4 +60,10 @@ class AlarmTableCell: UITableViewCell
@IBOutlet weak var enable: UISwitch!
@IBOutlet weak var repeatText: UILabel!
@IBOutlet weak var goingOffText: UILabel!
+
+ /// Update information on the cell to information in the alarm object
+ func setData(_ alarm: Alarm)
+ {
+ descriptionText.text = "- " + alarm.text
+ }
}
diff --git a/ProjectClock/Base.lproj/Main.storyboard b/ProjectClock/Base.lproj/Main.storyboard
index 4a8e207..c30afe5 100644
--- a/ProjectClock/Base.lproj/Main.storyboard
+++ b/ProjectClock/Base.lproj/Main.storyboard
@@ -61,7 +61,7 @@
-