Group tasks feature (#3)
This PR contains the work done to implement the **Group Task** feature, and to integrate it into the main content view of the app. Furthermore, an issue related to triggering a view update after inserting the todo tasks into the model container has been fixed. Reviewed-on: rock-n-code/todos-app#3 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #3.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
/// Categorizes todo tasks into groups based on their due dates and completion status.
|
||||
///
|
||||
/// This enumeration provides a semantic grouping mechanism for organizing and filtering todo tasks throughout the application.
|
||||
/// Each case represents a distinct category that helps users manage their tasks based on temporal relevance and completion state.
|
||||
enum TodoGroup {
|
||||
/// Tasks that have been marked as done, regardless of due date.
|
||||
case completed
|
||||
/// Tasks with due dates in the past that remain incomplete.
|
||||
case overdue
|
||||
/// Tasks due on the current day that are not yet completed.
|
||||
case today
|
||||
/// Tasks due in the future that are not yet completed.
|
||||
case upcoming
|
||||
}
|
||||
|
||||
// MARK: - Computed
|
||||
|
||||
extension TodoGroup {
|
||||
|
||||
/// The color associated with the task group.
|
||||
var color: Color {
|
||||
switch self {
|
||||
case .completed: .gray
|
||||
case .overdue: .red
|
||||
case .today: .blue
|
||||
case .upcoming: .green
|
||||
}
|
||||
}
|
||||
|
||||
/// The system icon name for the task group.
|
||||
var iconName: String {
|
||||
switch self {
|
||||
case .completed: "checkmark.circle.fill"
|
||||
case .overdue: "calendar.badge.exclamationmark"
|
||||
case .today: "calendar.badge.clock"
|
||||
case .upcoming: "calendar"
|
||||
}
|
||||
}
|
||||
|
||||
/// The display title for the task group.
|
||||
var title: LocalizedStringKey {
|
||||
switch self {
|
||||
case .completed: "enumeration.todo-group.title.completed"
|
||||
case .overdue: "enumeration.todo-group.title.overdue"
|
||||
case .today: "enumeration.todo-group.title.today"
|
||||
case .upcoming: "enumeration.todo-group.title.upcoming"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - CaseIterable
|
||||
|
||||
extension TodoGroup: CaseIterable {
|
||||
|
||||
static var allCases: [TodoGroup] { [.today, .upcoming, .overdue, .completed] }
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Identifiable
|
||||
|
||||
extension TodoGroup: Identifiable {
|
||||
|
||||
var id: Self { self }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user