Class
MainVC
class MainVC: UIViewController
The main view controlller of the app. Users often see this view controller as a default. This is where all the alarms are fetched from firebase and alarm requests are made to the OS.
Relationships
Conforms To
AlarmVCDelegate
UITableViewDataSource
UITableViewDelegate
UIViewController
UNUserNotificationCenterDelegate
Properties
welcomeTextView
let welcomeTextView
clockLabel
let clockLabel
topBar
let topBar
timeLabel
let timeLabel
timer
var timer
date
var date
calendar
let calendar
dateFormatter
let dateFormatter
logoutButton
let logoutButton
refreshControl
var refreshControl
summaryLabel
let summaryLabel
ref
var ref: DatabaseReference!
alarmTable
let alarmTable
Methods
reloadTableDelegate()
func reloadTableDelegate()
viewDidLoad()
override func viewDidLoad()
This is tha main function where all the important tasks are called, such as loading the UI, Fetching from firebase and loading data into array
updateTimeLabel()
@objc func updateTimeLabel()
Updates the time label for the clock shown on screen. Also refreshes the table view after certain time period
reloadTable()
@objc func reloadTable()
Reloads data in the table view
summaryLabelSetup()
func summaryLabelSetup()
Sets up the summary label. This label shows how many alarms are remaining to be completed for the day.
logoutButtonClicked()
@objc func logoutButtonClicked()
Logout button action. Logout the user from the app
fetchFromFirebase()
func fetchFromFirebase()
Fetches data from firebase and loads them in an array to be supplied to table view
tableView(_:numberOfRowsInSection:)
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
Built in tablie view function. Determines how many rows to be shown in the table
Parameters
Name | Type | Description |
---|---|---|
tableView | UITableView |
table view class |
section | Int |
number of rows |
tableView(_:cellForRowAt:)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
Sorts out the data to be shown in each row of the table
tableView(_:didSelectRowAt:)
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
Action to be done when a row is tapped
userNotificationCenter(_:willPresent:withCompletionHandler:)
@available(iOS 10.0, *) func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
userNotificationCenter(_:didReceive:withCompletionHandler:)
@available(iOS 10.0, *) func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
logoutButtonSetup()
func logoutButtonSetup()
Sets up the size/location/shape and style of the logout button
alarmTableSetup()
func alarmTableSetup()
Sets up the size/location/shape and style of the alarm table
topViewSetup()
func topViewSetup()
Sets up the size/location/shape and style of the top view
timeLabelSetup()
func timeLabelSetup()
Sets up the size/location/shape and style of the time label
welcomeTextViewSetup()
func welcomeTextViewSetup()
Sets up the size/location/shape and style of the welcome text
clockLabelSetup()
func clockLabelSetup()
Sets up the size/location/shape and style of the clock label
viewWillAppear(_:)
override func viewWillAppear(_ animated: Bool)
Refreshes the data in the alarm table when the view is loaded