[O] Add comments to table view classes
This commit is contained in:
@@ -1,10 +1,3 @@
|
|||||||
//
|
|
||||||
// AlarmViewController.swift
|
|
||||||
// ProjectClock
|
|
||||||
//
|
|
||||||
// Created by Hykilpikonna on 1/13/21.
|
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
class AlarmViewController: UIViewController
|
class AlarmViewController: UIViewController
|
||||||
@@ -18,17 +11,24 @@ class AlarmViewController: UIViewController
|
|||||||
{
|
{
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
// Assign table delegate and data source
|
||||||
table.delegate = self
|
table.delegate = self
|
||||||
table.dataSource = self
|
table.dataSource = self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alarm table controller
|
||||||
|
*/
|
||||||
extension AlarmViewController: UITableViewDelegate, UITableViewDataSource
|
extension AlarmViewController: UITableViewDelegate, UITableViewDataSource
|
||||||
{
|
{
|
||||||
|
/// How many sections are there
|
||||||
func numberOfSections(in: UITableView) -> Int { return 1 }
|
func numberOfSections(in: UITableView) -> Int { return 1 }
|
||||||
|
|
||||||
|
/// 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 data.count }
|
||||||
|
|
||||||
|
/// Configure each cell
|
||||||
func tableView(_ v: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell
|
func tableView(_ v: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell
|
||||||
{
|
{
|
||||||
// Get the cell and item at index i
|
// Get the cell and item at index i
|
||||||
@@ -37,17 +37,21 @@ extension AlarmViewController: UITableViewDelegate, UITableViewDataSource
|
|||||||
let item = data[i.row]
|
let item = data[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.descriptionText.text = item.text
|
cell.setData(item)
|
||||||
|
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This defines the height
|
/// Define cell height
|
||||||
func tableView(_ v: UITableView, heightForRowAt i: IndexPath) -> CGFloat { return 120 }
|
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) }
|
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
|
class AlarmTableCell: UITableViewCell
|
||||||
{
|
{
|
||||||
@IBOutlet weak var time: UILabel!
|
@IBOutlet weak var time: UILabel!
|
||||||
@@ -56,4 +60,10 @@ class AlarmTableCell: UITableViewCell
|
|||||||
@IBOutlet weak var enable: UISwitch!
|
@IBOutlet weak var enable: UISwitch!
|
||||||
@IBOutlet weak var repeatText: UILabel!
|
@IBOutlet weak var repeatText: UILabel!
|
||||||
@IBOutlet weak var goingOffText: 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
<nil key="textColor"/>
|
<nil key="textColor"/>
|
||||||
<nil key="highlightedColor"/>
|
<nil key="highlightedColor"/>
|
||||||
</label>
|
</label>
|
||||||
<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="70" width="215" height="21"/>
|
<rect key="frame" x="179" y="70" width="215" height="21"/>
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
<nil key="textColor"/>
|
<nil key="textColor"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user