Merge branch 'main' of github.com:hykilpikonna/ProjectClock into main
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
4FF0684625A5F18700304E6B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684425A5F18700304E6B /* Main.storyboard */; };
|
4FF0684625A5F18700304E6B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684425A5F18700304E6B /* Main.storyboard */; };
|
||||||
4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684725A5F18800304E6B /* Assets.xcassets */; };
|
4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684725A5F18800304E6B /* Assets.xcassets */; };
|
||||||
4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684925A5F18800304E6B /* LaunchScreen.storyboard */; };
|
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 */; };
|
7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963525AF375B0027A94C /* NotificationLogic.swift */; };
|
||||||
7C83963925AF68980027A94C /* TestingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963825AF68980027A94C /* TestingViewController.swift */; };
|
7C83963925AF68980027A94C /* TestingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963825AF68980027A94C /* TestingViewController.swift */; };
|
||||||
7C83963C25AF6B6B0027A94C /* Alarm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963B25AF6B6B0027A94C /* Alarm.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 = "<group>"; };
|
4FF0684725A5F18800304E6B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
4FF0684A25A5F18800304E6B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
4FF0684A25A5F18800304E6B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||||
4FF0684C25A5F18800304E6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
4FF0684C25A5F18800304E6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
7C5DAE9825AF7DDE00E44C52 /* applelogo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = applelogo.png; path = ../../../Downloads/applelogo.png; sourceTree = "<group>"; };
|
||||||
|
7C5DAE9B25AF812200E44C52 /* clock.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = clock.png; path = ../../../Downloads/clock.png; sourceTree = "<group>"; };
|
||||||
7C83962D25AF34F00027A94C /* ProjectClock.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProjectClock.entitlements; sourceTree = "<group>"; };
|
7C83962D25AF34F00027A94C /* ProjectClock.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProjectClock.entitlements; sourceTree = "<group>"; };
|
||||||
7C83962F25AF34F10027A94C /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; };
|
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 = "<group>"; };
|
7C83963525AF375B0027A94C /* NotificationLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationLogic.swift; sourceTree = "<group>"; };
|
||||||
@@ -85,6 +89,8 @@
|
|||||||
4F8A607425A919E600D88DC3 /* Logic.swift */,
|
4F8A607425A919E600D88DC3 /* Logic.swift */,
|
||||||
7C83963525AF375B0027A94C /* NotificationLogic.swift */,
|
7C83963525AF375B0027A94C /* NotificationLogic.swift */,
|
||||||
4F98955125A9260400F51321 /* Net.swift */,
|
4F98955125A9260400F51321 /* Net.swift */,
|
||||||
|
7C5DAE9825AF7DDE00E44C52 /* applelogo.png */,
|
||||||
|
7C5DAE9B25AF812200E44C52 /* clock.png */,
|
||||||
4F509BD125AE22D100726227 /* Models.swift */,
|
4F509BD125AE22D100726227 /* Models.swift */,
|
||||||
7C83963825AF68980027A94C /* TestingViewController.swift */,
|
7C83963825AF68980027A94C /* TestingViewController.swift */,
|
||||||
7C83963B25AF6B6B0027A94C /* Alarm.swift */,
|
7C83963B25AF6B6B0027A94C /* Alarm.swift */,
|
||||||
@@ -126,6 +132,9 @@
|
|||||||
4FF0683325A5F18700304E6B /* Project object */ = {
|
4FF0683325A5F18700304E6B /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
|
KnownAssetTags = (
|
||||||
|
New,
|
||||||
|
);
|
||||||
LastSwiftUpdateCheck = 1230;
|
LastSwiftUpdateCheck = 1230;
|
||||||
LastUpgradeCheck = 1230;
|
LastUpgradeCheck = 1230;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
@@ -158,8 +167,10 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */,
|
4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */,
|
||||||
|
7C5DAE9C25AF812200E44C52 /* clock.png in Resources */,
|
||||||
4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */,
|
4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */,
|
||||||
4FF0684625A5F18700304E6B /* Main.storyboard in Resources */,
|
4FF0684625A5F18700304E6B /* Main.storyboard in Resources */,
|
||||||
|
7C5DAE9925AF7DDE00E44C52 /* applelogo.png in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -31,34 +31,32 @@ class TestingViewController: UIViewController {
|
|||||||
|
|
||||||
//Sends a test notification
|
//Sends a test notification
|
||||||
@IBAction func sendNotification(_ sender: Any) {
|
@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()
|
let content = UNMutableNotificationContent()
|
||||||
|
|
||||||
//Date formatting to string
|
//Date formatting to string
|
||||||
let today = Date()
|
let today = Date()
|
||||||
let formatter1 = DateFormatter()
|
let formatter1 = DateFormatter()
|
||||||
formatter1.dateStyle = .short
|
formatter1.dateStyle = .long
|
||||||
print(formatter1.string(from: today))
|
|
||||||
|
|
||||||
//Notification content
|
//Notification content
|
||||||
content.title = alarm.text
|
content.title = alarm.text
|
||||||
content.subtitle = formatter1.string(from: today)
|
content.subtitle = formatter1.string(from: today)
|
||||||
content.body = "Wake method: \(alarm.wakeMethod)"
|
content.body = "Wake method: \(alarm.wakeMethod.name)"
|
||||||
|
|
||||||
// 2
|
// Notification image content
|
||||||
let imageName = "applelogo"
|
let imageName = "clock"
|
||||||
guard let imageURL = Bundle.main.url(forResource: imageName, withExtension: "png") else { return }
|
guard let imageURL = Bundle.main.url(forResource: imageName, withExtension: "png") else { return }
|
||||||
|
|
||||||
let attachment = try! UNNotificationAttachment(identifier: imageName, url: imageURL, options: .none)
|
let attachment = try! UNNotificationAttachment(identifier: imageName, url: imageURL, options: .none)
|
||||||
|
|
||||||
content.attachments = [attachment]
|
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)
|
let request = UNNotificationRequest(identifier: "notification.id.01", content: content, trigger: trigger)
|
||||||
|
|
||||||
// 4
|
// Sends notification
|
||||||
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
|
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,46 @@ import UIKit
|
|||||||
|
|
||||||
class ViewController: UIViewController {
|
class ViewController: UIViewController {
|
||||||
|
|
||||||
|
@IBOutlet var table: UITableView!
|
||||||
|
|
||||||
|
var models = [MyAlarm]()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.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
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Reference in New Issue
Block a user