2026-02-10 02:22:41 +00:00
|
|
|
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 {
|
|
|
|
|
|
2026-02-11 13:00:46 +00:00
|
|
|
/// Indicates whether this group supports toggling the visibility of completed tasks.
|
|
|
|
|
///
|
|
|
|
|
/// This property determines if a show/hide completed tasks action should be available for the group.
|
|
|
|
|
var canShowCompleted: Bool {
|
|
|
|
|
self != .completed
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-11 14:37:23 +01:00
|
|
|
/// Indicates whether tasks in this group can be reordered through drag and drop.
|
|
|
|
|
///
|
|
|
|
|
/// This property determines if the user should be able to manually reorder tasks within the group.
|
|
|
|
|
/// Reordering is useful for temporal groups where users may want to prioritize certain tasks,
|
|
|
|
|
/// but is disabled for completed tasks since they are typically sorted by completion date.
|
|
|
|
|
var canReorder: Bool {
|
|
|
|
|
self != .completed
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-10 02:22:41 +00:00
|
|
|
/// 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"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-11 13:00:46 +00:00
|
|
|
/// The localized display title for the task group.
|
2026-02-10 02:22:41 +00:00
|
|
|
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 {
|
|
|
|
|
|
2026-02-11 13:00:46 +00:00
|
|
|
/// All todo group cases in their display order.
|
|
|
|
|
///
|
|
|
|
|
/// The cases are ordered by priority and temporal relevance:
|
|
|
|
|
/// 1. `.today` - Most immediate tasks
|
|
|
|
|
/// 2. `.upcoming` - Future tasks
|
|
|
|
|
/// 3. `.overdue` - Past due tasks requiring attention
|
|
|
|
|
/// 4. `.completed` - Finished tasks
|
2026-02-10 02:22:41 +00:00
|
|
|
static var allCases: [TodoGroup] { [.today, .upcoming, .overdue, .completed] }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: - Identifiable
|
|
|
|
|
|
|
|
|
|
extension TodoGroup: Identifiable {
|
|
|
|
|
|
2026-02-11 13:00:46 +00:00
|
|
|
/// The unique identifier for the group.
|
|
|
|
|
///
|
|
|
|
|
/// Uses the case itself as the identifier, enabling use in SwiftUI's `ForEach` and other collection views.
|
2026-02-10 02:22:41 +00:00
|
|
|
var id: Self { self }
|
|
|
|
|
|
|
|
|
|
}
|