diff --git a/ProjectClock.xcodeproj/project.pbxproj b/ProjectClock.xcodeproj/project.pbxproj index bcbddf0..8df2802 100644 --- a/ProjectClock.xcodeproj/project.pbxproj +++ b/ProjectClock.xcodeproj/project.pbxproj @@ -17,6 +17,8 @@ 4FF0684625A5F18700304E6B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684425A5F18700304E6B /* Main.storyboard */; }; 4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684725A5F18800304E6B /* Assets.xcassets */; }; 4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684925A5F18800304E6B /* LaunchScreen.storyboard */; }; + 7C5DAE9925AF7DDE00E44C52 /* applelogo.png in Resources */ = {isa = PBXBuildFile; fileRef = 7C5DAE9825AF7DDE00E44C52 /* applelogo.png */; }; + 7C5DAE9C25AF812200E44C52 /* clock.png in Resources */ = {isa = PBXBuildFile; fileRef = 7C5DAE9B25AF812200E44C52 /* clock.png */; }; 7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963525AF375B0027A94C /* NotificationLogic.swift */; }; 7C83963925AF68980027A94C /* TestingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963825AF68980027A94C /* TestingViewController.swift */; }; 7C83963C25AF6B6B0027A94C /* Alarm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963B25AF6B6B0027A94C /* Alarm.swift */; }; @@ -35,6 +37,8 @@ 4FF0684725A5F18800304E6B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4FF0684A25A5F18800304E6B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 4FF0684C25A5F18800304E6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 7C5DAE9825AF7DDE00E44C52 /* applelogo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = applelogo.png; path = ../../../Downloads/applelogo.png; sourceTree = ""; }; + 7C5DAE9B25AF812200E44C52 /* clock.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = clock.png; path = ../../../Downloads/clock.png; sourceTree = ""; }; 7C83962D25AF34F00027A94C /* ProjectClock.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProjectClock.entitlements; sourceTree = ""; }; 7C83962F25AF34F10027A94C /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; }; 7C83963525AF375B0027A94C /* NotificationLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationLogic.swift; sourceTree = ""; }; @@ -85,6 +89,8 @@ 4F8A607425A919E600D88DC3 /* Logic.swift */, 7C83963525AF375B0027A94C /* NotificationLogic.swift */, 4F98955125A9260400F51321 /* Net.swift */, + 7C5DAE9825AF7DDE00E44C52 /* applelogo.png */, + 7C5DAE9B25AF812200E44C52 /* clock.png */, 4F509BD125AE22D100726227 /* Models.swift */, 7C83963825AF68980027A94C /* TestingViewController.swift */, 7C83963B25AF6B6B0027A94C /* Alarm.swift */, @@ -126,6 +132,9 @@ 4FF0683325A5F18700304E6B /* Project object */ = { isa = PBXProject; attributes = { + KnownAssetTags = ( + New, + ); LastSwiftUpdateCheck = 1230; LastUpgradeCheck = 1230; TargetAttributes = { @@ -158,8 +167,10 @@ buildActionMask = 2147483647; files = ( 4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */, + 7C5DAE9C25AF812200E44C52 /* clock.png in Resources */, 4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */, 4FF0684625A5F18700304E6B /* Main.storyboard in Resources */, + 7C5DAE9925AF7DDE00E44C52 /* applelogo.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ProjectClock/Assets.xcassets/applelogo.imageset/Contents.json b/ProjectClock/Assets.xcassets/applelogo.imageset/Contents.json new file mode 100644 index 0000000..5979dd8 --- /dev/null +++ b/ProjectClock/Assets.xcassets/applelogo.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "applelogo.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ProjectClock/Assets.xcassets/applelogo.imageset/applelogo.png b/ProjectClock/Assets.xcassets/applelogo.imageset/applelogo.png new file mode 100644 index 0000000..9eca757 Binary files /dev/null and b/ProjectClock/Assets.xcassets/applelogo.imageset/applelogo.png differ diff --git a/ProjectClock/TestingViewController.swift b/ProjectClock/TestingViewController.swift index 634e77f..c97a9b8 100644 --- a/ProjectClock/TestingViewController.swift +++ b/ProjectClock/TestingViewController.swift @@ -31,34 +31,32 @@ class TestingViewController: UIViewController { //Sends a test notification @IBAction func sendNotification(_ sender: Any) { - var alarm = Alarm(alarmTime: Date(), text: "Hello there!", wakeMethod: WVM(name: "walking", desc: "Walk")) + let alarm = Alarm(alarmTime: Date(), text: "Good morning!", wakeMethod: WVM(name: "walking", desc: "Walk")) let content = UNMutableNotificationContent() //Date formatting to string let today = Date() let formatter1 = DateFormatter() - formatter1.dateStyle = .short - print(formatter1.string(from: today)) + formatter1.dateStyle = .long //Notification content content.title = alarm.text content.subtitle = formatter1.string(from: today) - content.body = "Wake method: \(alarm.wakeMethod)" + content.body = "Wake method: \(alarm.wakeMethod.name)" - // 2 - let imageName = "applelogo" + // Notification image content + let imageName = "clock" guard let imageURL = Bundle.main.url(forResource: imageName, withExtension: "png") else { return } - let attachment = try! UNNotificationAttachment(identifier: imageName, url: imageURL, options: .none) - content.attachments = [attachment] - // 3 - let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0, repeats: false) + + // Readies notification to be sent + let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false) let request = UNNotificationRequest(identifier: "notification.id.01", content: content, trigger: trigger) - // 4 + // Sends notification UNUserNotificationCenter.current().add(request, withCompletionHandler: nil) } diff --git a/ProjectClock/ViewController.swift b/ProjectClock/ViewController.swift index 8967045..1846698 100644 --- a/ProjectClock/ViewController.swift +++ b/ProjectClock/ViewController.swift @@ -9,11 +9,46 @@ import UIKit class ViewController: UIViewController { + @IBOutlet var table: UITableView! + + var models = [MyAlarm]() + override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. + table.delegate = self + table.dataSource = self } +} +extension ViewController: UITableViewDelegate { + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + tableView.deselectRow(at: indexPath, animated: true) + } } +extension ViewController: 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/clock.png b/ProjectClock/clock.png new file mode 100644 index 0000000..1d9651b Binary files /dev/null and b/ProjectClock/clock.png differ