diff --git a/ProjectClock.xcodeproj/project.pbxproj b/ProjectClock.xcodeproj/project.pbxproj index cf29ff6..f2e7999 100644 --- a/ProjectClock.xcodeproj/project.pbxproj +++ b/ProjectClock.xcodeproj/project.pbxproj @@ -11,7 +11,7 @@ 4F8A607125A9160400D88DC3 /* AddAlarmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */; }; 4F8A607525A919E600D88DC3 /* Logic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8A607425A919E600D88DC3 /* Logic.swift */; }; 4F98955225A9260400F51321 /* Net.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F98955125A9260400F51321 /* Net.swift */; }; - 4FA419AF25AF93EC004CE0FC /* AlarmTableTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FA419AE25AF93EC004CE0FC /* AlarmTableTableViewController.swift */; }; + 4FA419AF25AF93EC004CE0FC /* AlarmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FA419AE25AF93EC004CE0FC /* AlarmViewController.swift */; }; 4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0683E25A5F18700304E6B /* AppDelegate.swift */; }; 4FF0684125A5F18700304E6B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684025A5F18700304E6B /* SceneDelegate.swift */; }; 4FF0684325A5F18700304E6B /* AccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684225A5F18700304E6B /* AccountViewController.swift */; }; @@ -29,7 +29,7 @@ 4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAlarmViewController.swift; sourceTree = ""; }; 4F8A607425A919E600D88DC3 /* Logic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logic.swift; sourceTree = ""; }; 4F98955125A9260400F51321 /* Net.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Net.swift; sourceTree = ""; }; - 4FA419AE25AF93EC004CE0FC /* AlarmTableTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmTableTableViewController.swift; sourceTree = ""; }; + 4FA419AE25AF93EC004CE0FC /* AlarmViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmViewController.swift; sourceTree = ""; }; 4FF0683B25A5F18700304E6B /* ProjectClock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ProjectClock.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4FF0683E25A5F18700304E6B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4FF0684025A5F18700304E6B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -81,7 +81,7 @@ 4FF0684025A5F18700304E6B /* SceneDelegate.swift */, 7C83962D25AF34F00027A94C /* ProjectClock.entitlements */, 4FF0684225A5F18700304E6B /* AccountViewController.swift */, - 4FA419AE25AF93EC004CE0FC /* AlarmTableTableViewController.swift */, + 4FA419AE25AF93EC004CE0FC /* AlarmViewController.swift */, 4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */, 4FF0684425A5F18700304E6B /* Main.storyboard */, 4FF0684725A5F18800304E6B /* Assets.xcassets */, @@ -187,7 +187,7 @@ 4FF0684325A5F18700304E6B /* AccountViewController.swift in Sources */, 4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */, 4FF0684125A5F18700304E6B /* SceneDelegate.swift in Sources */, - 4FA419AF25AF93EC004CE0FC /* AlarmTableTableViewController.swift in Sources */, + 4FA419AF25AF93EC004CE0FC /* AlarmViewController.swift in Sources */, 7C83963C25AF6B6B0027A94C /* Alarm.swift in Sources */, 4F509BD225AE22D100726227 /* Models.swift in Sources */, 7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */, diff --git a/ProjectClock/AccountViewController.swift b/ProjectClock/AccountViewController.swift index b42be7c..9af7f40 100644 --- a/ProjectClock/AccountViewController.swift +++ b/ProjectClock/AccountViewController.swift @@ -7,48 +7,10 @@ import UIKit -class AccountViewController: UIViewController { - - @IBOutlet var table: UITableView! - - var models = [MyAlarm]() - - override func viewDidLoad() { +class AccountViewController: UIViewController +{ + override func viewDidLoad() + { super.viewDidLoad() - table.delegate = self - table.dataSource = self } } - -extension AccountViewController: UITableViewDelegate { - - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - tableView.deselectRow(at: indexPath, animated: true) - } - -} - -extension AccountViewController: UITableViewDataSource { - - func numberOfSections(in tableView: UITableView) -> Int { - return 1 - } - - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return models.count - } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) - cell.textLabel?.text = models[indexPath.row].title - - return cell - } -} - -struct MyAlarm { - let title: String - let date: Date - let identifier: String -} - diff --git a/ProjectClock/AlarmTableTableViewController.swift b/ProjectClock/AlarmTableTableViewController.swift index 8f7ec24..94e1107 100644 --- a/ProjectClock/AlarmTableTableViewController.swift +++ b/ProjectClock/AlarmTableTableViewController.swift @@ -7,9 +7,13 @@ import UIKit -class AlarmTableTableViewController: UITableViewController { - - override func viewDidLoad() { +class AlarmViewController: UIViewController +{ + // TODO: Remove example and use localStorage + var data: [Alarm] = [Alarm(alarmTime: Date(), text: "Wake up lol", wakeMethod: wvms[0])] + + override func viewDidLoad() + { super.viewDidLoad() // Uncomment the following line to preserve selection between presentations @@ -21,25 +25,25 @@ class AlarmTableTableViewController: UITableViewController { // MARK: - Table view data source - override func numberOfSections(in tableView: UITableView) -> Int { - // #warning Incomplete implementation, return the number of sections - return 0 - } + override func numberOfSections(in: UITableView) -> Int { return 1 } - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - // #warning Incomplete implementation, return the number of rows - return 0 - } - - /* - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) - - // Configure the cell... + override func tableView(_ v: UITableView, numberOfRowsInSection s: Int) -> Int { return data.count } + override func tableView(_ v: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell + { + // Get the cell and item at index i + let cell = tableView.dequeueReusableCell(withIdentifier: "alarm", for: i) + let item = data[i.row] + + // Set the content of the cell to the content of the item. + cell.textLabel?.text = item.text + return cell } - */ + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + tableView.deselectRow(at: indexPath, animated: true) + } /* // Override to support conditional editing of the table view. diff --git a/ProjectClock/AlarmViewController.swift b/ProjectClock/AlarmViewController.swift new file mode 100644 index 0000000..27c7083 --- /dev/null +++ b/ProjectClock/AlarmViewController.swift @@ -0,0 +1,59 @@ +// +// AlarmViewController.swift +// ProjectClock +// +// Created by Hykilpikonna on 1/13/21. +// + +import UIKit + +class AlarmViewController: UIViewController +{ + @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() + { + super.viewDidLoad() + + table.delegate = self + table.dataSource = self + } +} + +extension AlarmViewController: UITableViewDelegate, UITableViewDataSource +{ + func numberOfSections(in: UITableView) -> Int { return 1 } + + func tableView(_ v: UITableView, numberOfRowsInSection s: Int) -> Int { return data.count } + + func tableView(_ v: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell + { + // Get the cell and item at index i + let rawCell = v.dequeueReusableCell(withIdentifier: "alarm", for: i) + guard let cell = rawCell as? AlarmTableCell else { return rawCell } + let item = data[i.row] + + // Set the content of the cell to the content of the item. + cell.descriptionText.text = item.text + + return cell + } + + /// This defines the height + func tableView(_ v: UITableView, heightForRowAt i: IndexPath) -> CGFloat { return 120 } + + func tableView(_ v: UITableView, didSelectRowAt i: IndexPath) { v.deselectRow(at: i, animated: true) } +} + +class AlarmTableCell: UITableViewCell +{ + @IBOutlet weak var time: UILabel! + @IBOutlet weak var ampm: UILabel! + @IBOutlet weak var descriptionText: UILabel! + @IBOutlet weak var enable: UISwitch! + @IBOutlet weak var repeatText: UILabel! + @IBOutlet weak var goingOffText: UILabel! +} diff --git a/ProjectClock/Base.lproj/Main.storyboard b/ProjectClock/Base.lproj/Main.storyboard index b7545c0..4a8e207 100644 --- a/ProjectClock/Base.lproj/Main.storyboard +++ b/ProjectClock/Base.lproj/Main.storyboard @@ -10,6 +10,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -247,93 +372,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -536,7 +574,7 @@ - +