This commit is contained in:
Trey t
2025-11-05 13:52:02 -06:00
parent 2be3a5a3a8
commit 5deac95818
10 changed files with 981 additions and 14 deletions

View File

@@ -8,6 +8,7 @@ struct ResidenceDetailView: View {
@State private var isLoadingTasks = false
@State private var tasksError: String?
@State private var showAddTask = false
@State private var showEditResidence = false
var body: some View {
ZStack {
@@ -47,6 +48,16 @@ struct ResidenceDetailView: View {
.navigationTitle("Property Details")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
if viewModel.selectedResidence != nil {
Button(action: {
showEditResidence = true
}) {
Text("Edit")
}
}
}
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
showAddTask = true
@@ -58,12 +69,23 @@ struct ResidenceDetailView: View {
.sheet(isPresented: $showAddTask) {
AddTaskView(residenceId: residenceId, isPresented: $showAddTask)
}
.sheet(isPresented: $showEditResidence) {
if let residence = viewModel.selectedResidence {
EditResidenceView(residence: residence, isPresented: $showEditResidence)
}
}
.onChange(of: showAddTask) { isShowing in
if !isShowing {
// Refresh tasks when sheet is dismissed
loadResidenceWithTasks()
}
}
.onChange(of: showEditResidence) { isShowing in
if !isShowing {
// Refresh residence data when edit sheet is dismissed
loadResidenceData()
}
}
.onAppear {
loadResidenceData()
}
@@ -296,6 +318,69 @@ struct TaskCard: View {
.font(.caption)
.foregroundColor(.secondary)
}
ForEach(task.completions, id: \.id) { completion in
Spacer().frame(height: 12)
// Card equivalent
VStack(alignment: .leading, spacing: 8) {
// Top row: date + rating badge
HStack {
Text(completion.completionDate.components(separatedBy: "T").first ?? "")
.font(.body.weight(.bold))
.foregroundColor(.accentColor)
Spacer()
if let rating = completion.rating {
Text("\(rating)")
.font(.caption.weight(.bold))
.padding(.horizontal, 8)
.padding(.vertical, 4)
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color(.tertiarySystemFill))
)
}
}
// Completed by
if let name = completion.completedByName {
Text("By: \(name)")
.font(.subheadline.weight(.medium))
.padding(.top, 8)
}
// Cost
if let cost = completion.actualCost {
Text("Cost: $\(cost)")
.font(.subheadline.weight(.medium))
.foregroundColor(.teal) // tertiary equivalent
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(16)
.background(
RoundedRectangle(cornerRadius: 12)
.fill(Color.secondary.opacity(0.15)) // surfaceVariant equivalent
)
}
}
if task.showCompletedButton {
Button(action: {}) {
HStack {
Image(systemName: "checkmark.circle.fill") // SF Symbol
.resizable()
.frame(width: 20, height: 20)
Spacer().frame(width: 8)
Text("Complete Task")
.font(.title3.weight(.semibold)) // Material titleSmall + SemiBold
}
.frame(maxWidth: .infinity, alignment: .center)
}
.buttonStyle(.borderedProminent) // gives filled look
.clipShape(RoundedRectangle(cornerRadius: 12))
}
}
.padding(16)