This commit is contained in:
Trey t
2025-11-05 18:02:34 -06:00
parent 194bac1a86
commit b2b8cc62de
4 changed files with 125 additions and 9 deletions

View File

@@ -12,6 +12,7 @@ struct ResidenceDetailView: View {
@State private var showEditResidence = false
@State private var showEditTask = false
@State private var selectedTaskForEdit: TaskDetail?
@State private var showCompletedTasks = false
@State private var showCancelledTasks = false
var body: some View {
@@ -37,6 +38,7 @@ struct ResidenceDetailView: View {
if let tasksResponse = tasksResponse {
TasksSection(
tasksResponse: tasksResponse,
showCompletedTasks: $showCompletedTasks,
showCancelledTasks: $showCancelledTasks,
onEditTask: { task in
selectedTaskForEdit = task

View File

@@ -3,6 +3,7 @@ import ComposeApp
struct TasksSection: View {
let tasksResponse: TasksByResidenceResponse
@Binding var showCompletedTasks: Bool
@Binding var showCancelledTasks: Bool
let onEditTask: (TaskDetail) -> Void
let onCancelTask: (TaskDetail) -> Void
@@ -24,7 +25,7 @@ struct TasksSection: View {
}
}
if tasksResponse.tasks.isEmpty && tasksResponse.cancelledTasks.isEmpty {
if tasksResponse.tasks.isEmpty && tasksResponse.completedTasks.isEmpty && tasksResponse.cancelledTasks.isEmpty {
EmptyTasksView()
} else {
ForEach(tasksResponse.tasks, id: \.id) { task in
@@ -36,6 +37,38 @@ struct TasksSection: View {
)
}
if !tasksResponse.completedTasks.isEmpty {
VStack(alignment: .leading, spacing: 12) {
HStack {
Label("Completed Tasks (\(tasksResponse.completedTasks.count))", systemImage: "checkmark.circle")
.font(.headline)
.foregroundColor(.green)
Spacer()
Image(systemName: showCompletedTasks ? "chevron.up" : "chevron.down")
.foregroundColor(.secondary)
.font(.caption)
}
.padding(.top, 8)
.contentShape(Rectangle())
.onTapGesture {
showCompletedTasks.toggle()
}
if showCompletedTasks {
ForEach(tasksResponse.completedTasks, id: \.id) { task in
TaskCard(
task: task,
onEdit: { onEditTask(task) },
onCancel: nil,
onUncancel: nil
)
}
}
}
}
if !tasksResponse.cancelledTasks.isEmpty {
VStack(alignment: .leading, spacing: 12) {
HStack {
@@ -45,12 +78,15 @@ struct TasksSection: View {
Spacer()
Button(showCancelledTasks ? "Hide" : "Show") {
showCancelledTasks.toggle()
}
.font(.subheadline)
Image(systemName: showCancelledTasks ? "chevron.up" : "chevron.down")
.foregroundColor(.secondary)
.font(.caption)
}
.padding(.top, 8)
.contentShape(Rectangle())
.onTapGesture {
showCancelledTasks.toggle()
}
if showCancelledTasks {
ForEach(tasksResponse.cancelledTasks, id: \.id) { task in
@@ -101,8 +137,30 @@ struct TasksSection: View {
completions: []
)
],
completedTasks: [
TaskDetail(
id: 2,
residence: 1,
title: "Fix Leaky Faucet",
description: "Kitchen sink fixed",
category: TaskCategory(id: 2, name: "plumbing", description: "Plumbing tasks"),
priority: TaskPriority(id: 3, name: "high", displayName: "High", description: "High priority"),
frequency: TaskFrequency(id: 6, name: "once", displayName: "One Time"),
status: TaskStatus(id: 3, name: "completed", displayName: "Completed", description: "Task completed"),
dueDate: "2024-11-01",
estimatedCost: "200.00",
actualCost: "185.00",
notes: nil,
createdAt: "2024-10-01T00:00:00Z",
updatedAt: "2024-11-05T00:00:00Z",
nextScheduledDate: nil,
showCompletedButton: false,
completions: []
)
],
cancelledTasks: []
),
showCompletedTasks: .constant(true),
showCancelledTasks: .constant(true),
onEditTask: { _ in },
onCancelTask: { _ in },