Added the "canReorder" computed property for the TodoGroup enumeration in the app target.
This commit is contained in:
@@ -5,16 +5,6 @@ import SwiftUI
|
|||||||
///
|
///
|
||||||
/// This enumeration provides a semantic grouping mechanism for organizing and filtering todo tasks throughout the application.
|
/// 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.
|
/// 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 {
|
enum TodoGroup {
|
||||||
/// Tasks that have been marked as done, regardless of due date.
|
/// Tasks that have been marked as done, regardless of due date.
|
||||||
case completed
|
case completed
|
||||||
@@ -33,14 +23,19 @@ extension TodoGroup {
|
|||||||
/// Indicates whether this group supports toggling the visibility of completed tasks.
|
/// 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.
|
/// 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 {
|
var canShowCompleted: Bool {
|
||||||
self != .completed
|
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.
|
/// The color associated with the task group.
|
||||||
var color: Color {
|
var color: Color {
|
||||||
switch self {
|
switch self {
|
||||||
|
|||||||
@@ -28,6 +28,25 @@ struct TodoGroupTests {
|
|||||||
#expect(canShowCompleted == expectation)
|
#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(
|
@Test(
|
||||||
"group color match expected values",
|
"group color match expected values",
|
||||||
arguments: zip(
|
arguments: zip(
|
||||||
|
|||||||
Reference in New Issue
Block a user