Added the "canReorder" computed property for the TodoGroup enumeration in the app target.

This commit is contained in:
2026-02-11 14:37:23 +01:00
parent 91edf100d4
commit 9c68c5be32
2 changed files with 28 additions and 14 deletions
+9 -14
View File
@@ -5,16 +5,6 @@ import SwiftUI
///
/// 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.
///
/// ## Features
/// - Provides localized titles and icons for each group
/// - Supports filtering of completed tasks within temporal groups
/// - Enables color-coded visual categorization
///
/// ## Groups
/// Groups are categorized into two types:
/// - **Temporal groups** (`.today`, `.upcoming`, `.overdue`): Time-based categorization that can optionally include completed tasks
/// - **Status group** (`.completed`): Contains all completed tasks regardless of due date
enum TodoGroup {
/// Tasks that have been marked as done, regardless of due date.
case completed
@@ -33,14 +23,19 @@ extension TodoGroup {
/// 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.
///
/// - Returns: `true` for temporal groups (`.today`, `.upcoming`, `.overdue`) that can optionally
/// show or hide completed tasks. Returns `false` for the `.completed` group since it exclusively
/// displays completed tasks.
var canShowCompleted: Bool {
self != .completed
}
/// 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
}
/// The color associated with the task group.
var color: Color {
switch self {
@@ -28,6 +28,25 @@ struct TodoGroupTests {
#expect(canShowCompleted == expectation)
}
@Test(
"canReorder returns correct values",
arguments: zip(
TodoGroup.allCases,
[true, true, true, false]
)
)
func canReorder(
for group: TodoGroup,
expects expectation: Bool
) {
// GIVEN
// WHEN
let canReorder = group.canReorder
// THEN
#expect(canReorder == expectation)
}
@Test(
"group color match expected values",
arguments: zip(