Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task status feature added (mark as done)) #42

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Application/To-Do/Controller/TodoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class TodoViewController: UITableViewController {
updateTask()
}

func checkTask(at index : Int){
//TODO: write star login
todoList[index].isDone = todoList[index].isDone ? false : true
updateTask()
}

///Delete task
/// function called when `Delete Task` tapped
func deleteTask(at index : Int){
Expand Down Expand Up @@ -164,6 +170,7 @@ class TodoViewController: UITableViewController {
cell.title.text = task.title
cell.subtitle.text = task.dueDate
cell.starImage.isHidden = todoList[indexPath.row].isFavourite ? false : true
cell.checkImage.isHidden = todoList[indexPath.row].isDone ? false : true
return cell
}

Expand All @@ -179,15 +186,25 @@ class TodoViewController: UITableViewController {

/// `UISwipeActionsConfiguration` for delete and star buttons
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

let delete = UIContextualAction(style: .destructive, title: "Delete") { (_, _, _) in
self.deleteTask(at: indexPath.row)
}


let star = UIContextualAction(style: .normal, title: todoList[indexPath.row].isFavourite ? "Unstar" : "Star"){ (_, _, _) in
self.starTask(at: indexPath.row)
}
star.backgroundColor = .orange

let swipeActions = UISwipeActionsConfiguration(actions: [delete,star])

let status = UIContextualAction(style: .normal, title: todoList[indexPath.row].isDone ? "Ongoing" : "Done"){ (_, _, _) in
self.checkTask(at: indexPath.row)
}
status.backgroundColor = UIColor.systemBlue


let swipeActions = UISwipeActionsConfiguration(actions: [delete,star,status])

return swipeActions
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="15702" systemVersion="19E287" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="16119" systemVersion="19G2021" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Label" representedClassName="Label" syncable="YES" codeGenerationType="class">
<attribute name="color" optional="YES" attributeType="String"/>
<attribute name="title" optional="YES" attributeType="String"/>
Expand All @@ -8,13 +8,14 @@
<entity name="Task" representedClassName="Task" syncable="YES" codeGenerationType="class">
<attribute name="dueDate" optional="YES" attributeType="String"/>
<attribute name="dueDateTimeStamp" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
<attribute name="isDone" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="isFavourite" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="subTasks" optional="YES" attributeType="String"/>
<attribute name="title" optional="YES" attributeType="String"/>
<relationship name="labels" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="Label" inverseName="relationship" inverseEntity="Label"/>
</entity>
<elements>
<element name="Label" positionX="-54" positionY="18" width="128" height="88"/>
<element name="Task" positionX="-63" positionY="-18" width="128" height="133"/>
<element name="Task" positionX="-63" positionY="-18" width="128" height="148"/>
</elements>
</model>
Loading