-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c41ab2e
commit bee838e
Showing
29 changed files
with
1,203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SwiftUI_Tasks | ||
This is a basic app that lets you create a list of todos with specific date and time by user, mark the todos complete and then delete them.It will also send local notification based on the user preference of each tasks. | ||
|
||
<p align="center"> | ||
<img src="https://github.com/shankarmadeshvaran/SwiftUI_Tasks/blob/master/ToDo-tasks.gif" width="30%"/> | ||
</p> | ||
|
||
This project was made for fun to try out Swift UI and see how it interacts with other layers of the application now that we don't have view controllers. We're all still learning. This project is merely my attempt to put something together based on the ideas put accross in WWDC videos and in the documentation. | ||
|
||
## Platforms | ||
Task app will currently run from iOS 13 beta. | ||
This app is updated for Xcode 11 beta 5. I'll be updating the code for upcoming betas also. | ||
|
||
## Issues | ||
This task app having design issues and I'm still adding features , updating and fixing bugs whenever I came across. | ||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
TodoList SwiftUI.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
TodoList SwiftUI.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+51.9 KB
....xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
TodoList SwiftUI.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
uuid = "BE439ADE-C197-4011-B629-45415FC10896" | ||
type = "1" | ||
version = "2.0"> | ||
</Bucket> |
14 changes: 14 additions & 0 deletions
14
TodoList SwiftUI.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>TodoList SwiftUI.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
|
||
import SwiftUI | ||
|
||
struct AddNewToDoTaskHeaderView: View { | ||
@ObservedObject var toDoStore: ToDoStore | ||
@State var dueDate = Date() | ||
|
||
@State var newToDo: String = "" | ||
@State var textfieldText: String = "" | ||
|
||
@State var isShowAlert: Bool = false | ||
@State var showDatePicker = false | ||
|
||
var dateClosedRange: ClosedRange<Date> { | ||
let min = Calendar.current.date(byAdding: .day, value: 0, to: Date())! | ||
let max = Calendar.current.date(byAdding: .day, value: 7, to: Date())! | ||
return min...max | ||
} | ||
|
||
var alert: Alert { | ||
Alert(title: Text("Please enter the Task name"), message: Text("Next Task to Do"), dismissButton: .default(Text("OK"))) | ||
} | ||
var dateFormatter: DateFormatter { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.timeStyle = .short | ||
dateFormatter.dateStyle = .long | ||
return dateFormatter | ||
} | ||
|
||
var body: some View { | ||
VStack(alignment: .center, spacing: 20) { | ||
TextField("Enter the new task to do",text: $newToDo) | ||
.textFieldStyle(RoundedBorderTextFieldStyle()) | ||
.foregroundColor(.primary) | ||
.font(.system(size: 20)) | ||
.frame(height: 60) | ||
|
||
HStack(alignment: .center, spacing: 10) { | ||
Text("Due Date") | ||
.foregroundColor(.primary) | ||
.font(.system(size: 21)) | ||
.bold() | ||
|
||
Text("\(dueDate, formatter: dateFormatter)") | ||
.foregroundColor(.secondary) | ||
.font(.system(size: 20)) | ||
.bold() | ||
}.onTapGesture { | ||
self.showDatePicker.toggle() | ||
} | ||
if self.showDatePicker { | ||
DatePicker( | ||
selection: $dueDate, | ||
in: dateClosedRange, | ||
displayedComponents: [.hourAndMinute, .date], | ||
label: {Text("")}) | ||
.datePickerStyle(DefaultDatePickerStyle()) | ||
} | ||
Button(action: { | ||
self.addNewTask(dueDate: self.dueDate) | ||
}) { | ||
AddNewTaskButtonView() | ||
.frame(width: 250, height: 45, alignment: .center) | ||
.background(Color.blue) | ||
.cornerRadius(8) | ||
} | ||
} .padding(EdgeInsets(top: 15, leading: 15, bottom: 15, trailing: 15)) | ||
.alert(isPresented: $isShowAlert, content: { | ||
alert | ||
}) | ||
} | ||
|
||
func addNewTask(dueDate: Date) { | ||
if !self.newToDo.isEmpty { | ||
self.toDoStore.toDOData.append(ToDo(title: self.newToDo, due: dueDate, isNotify: true)) | ||
self.newToDo = "" | ||
} else { | ||
self.isShowAlert = true | ||
} | ||
} | ||
} | ||
|
||
struct AddNewTaskButtonView: View { | ||
var body: some View { | ||
Text("Add New Task") | ||
.bold() | ||
.foregroundColor(.white) | ||
.font(.system(size: 22)) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
|
||
|
||
|
||
|
||
import UIKit | ||
import Combine | ||
import SwiftUI | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
@ObservedObject var data = ToDoStore() | ||
let notificationCenter = UNUserNotificationCenter.current() | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
|
||
notificationCenter.delegate = self | ||
|
||
let options: UNAuthorizationOptions = [.alert, .sound, .badge] | ||
notificationCenter.requestAuthorization(options: options) { | ||
(didAllow, error) in | ||
if !didAllow { | ||
print("User has declined notifications") | ||
} | ||
} | ||
return true | ||
} | ||
|
||
// MARK: UISceneSession Lifecycle | ||
|
||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { | ||
// Called when a new scene session is being created. | ||
// Use this method to select a configuration to create the new scene with. | ||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) | ||
} | ||
|
||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { | ||
// Called when the user discards a scene session. | ||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. | ||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return. | ||
} | ||
|
||
} | ||
|
||
extension AppDelegate: UNUserNotificationCenterDelegate { | ||
|
||
func userNotificationCenter(_ center: UNUserNotificationCenter, | ||
willPresent notification: UNNotification, | ||
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { | ||
|
||
completionHandler([.alert, .sound]) | ||
} | ||
|
||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { | ||
|
||
if response.notification.request.identifier == "tasks_remainder" { | ||
print(response.notification.request.content.title) | ||
print(response.notification.request.content.attachments) | ||
print(response.notification.request.content.body) | ||
print(response.notification.request.content.subtitle) | ||
} | ||
completionHandler() | ||
} | ||
|
||
func scheduleNotification(notificationType: ToDo) { | ||
|
||
let content = UNMutableNotificationContent() | ||
let categoryIdentifier = "Delete Notification Type" | ||
|
||
content.title = "Remainder: Task about to Expire" | ||
content.body = "Your task " + notificationType.title + " needs to be completed on or before \(notificationType.due.dateFormatterString())" | ||
content.subtitle = "TASK" | ||
|
||
let imageName = "Swift" | ||
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] | ||
|
||
content.sound = UNNotificationSound.default | ||
content.badge = 1 | ||
content.categoryIdentifier = categoryIdentifier | ||
|
||
let dateComponentsNotify = notificationType.due.dateComponentsToNotify() | ||
|
||
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponentsNotify, repeats: false) | ||
let identifier = "tasks_remainder" | ||
let request = UNNotificationRequest(identifier: identifier, content: content, trigger: trigger) | ||
|
||
notificationCenter.add(request) { (error) in | ||
if let error = error { | ||
print("Error \(error.localizedDescription)") | ||
} | ||
} | ||
|
||
let snoozeAction = UNNotificationAction(identifier: "Complete", title: "Mark as Complete", options: []) | ||
let deleteAction = UNNotificationAction(identifier: "Delete", title: "Delete", options: [.destructive]) | ||
let category = UNNotificationCategory(identifier: categoryIdentifier, | ||
actions: [snoozeAction, deleteAction], | ||
intentIdentifiers: [], | ||
options: []) | ||
|
||
notificationCenter.setNotificationCategories([category]) | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
TodoList SwiftUI/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "20x20", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "20x20", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "83.5x83.5", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ios-marketing", | ||
"size" : "1024x1024", | ||
"scale" : "1x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
TodoList SwiftUI/Assets.xcassets/Swift.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "Swift.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.