From 9c68c5be32a32adcecbf445a8c1d5d4d87aa1458 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Wed, 11 Feb 2026 14:37:23 +0100 Subject: [PATCH] Added the "canReorder" computed property for the TodoGroup enumeration in the app target. --- App/Sources/Enumerations/TodoGroup.swift | 23 ++++++++----------- .../Tests/Enumerations/TodoGroupTests.swift | 19 +++++++++++++++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/App/Sources/Enumerations/TodoGroup.swift b/App/Sources/Enumerations/TodoGroup.swift index cb0b8ea..684624b 100644 --- a/App/Sources/Enumerations/TodoGroup.swift +++ b/App/Sources/Enumerations/TodoGroup.swift @@ -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 { diff --git a/UnitTests/Tests/Enumerations/TodoGroupTests.swift b/UnitTests/Tests/Enumerations/TodoGroupTests.swift index 22116ee..b39933d 100644 --- a/UnitTests/Tests/Enumerations/TodoGroupTests.swift +++ b/UnitTests/Tests/Enumerations/TodoGroupTests.swift @@ -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(