Make the project TODO list easier to scan
This commit is contained in:
@@ -509,6 +509,7 @@ private struct TodoBlock: View {
|
||||
let todo: Result<Todo, ApiError>?
|
||||
let active: [ByreTask]
|
||||
let filter: String
|
||||
@ViewState private var open: Set<String> = []
|
||||
|
||||
var body: some View {
|
||||
switch todo {
|
||||
@@ -534,7 +535,13 @@ private struct TodoBlock: View {
|
||||
.padding(.top, i == 0 ? 10 : 2)
|
||||
.padding(.bottom, 4)
|
||||
}
|
||||
TodoRow(project: project, item: item, task: active.first { $0.todoItem == item.title })
|
||||
TodoRow(project: project, item: item, task: active.first { $0.todoItem == item.title }, open: open.contains(item.title) || (!filter.isEmpty && matches(item.body, filter))) {
|
||||
if open.contains(item.title) {
|
||||
open.remove(item.title)
|
||||
} else {
|
||||
open.insert(item.title)
|
||||
}
|
||||
}
|
||||
.padding(.bottom, i == items.count - 1 || items[i + 1].section != item.section ? 8 : 0)
|
||||
}
|
||||
}
|
||||
@@ -554,18 +561,31 @@ private struct TodoRow: View {
|
||||
let project: Project
|
||||
let item: TodoItem
|
||||
let task: ByreTask?
|
||||
let open: Bool
|
||||
let toggle: () -> Void
|
||||
@Environment(Store.self) private var store
|
||||
@Environment(Overlays.self) private var overlays
|
||||
@Environment(\.filterQuery) private var query
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
HStack(spacing: 10) {
|
||||
HStack(spacing: 8) {
|
||||
Button(action: toggle) {
|
||||
Image(systemName: open ? "chevron.down" : "chevron.right")
|
||||
.font(Fonts.font(9, weight: 600))
|
||||
.foregroundStyle(Palette.muted)
|
||||
.frame(width: 12)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.opacity(item.body.isEmpty ? 0 : 1)
|
||||
.disabled(item.body.isEmpty)
|
||||
title
|
||||
action
|
||||
}
|
||||
if !item.body.isEmpty {
|
||||
if open && !item.body.isEmpty {
|
||||
MarkdownView(blocks: parseMarkdown(item.body), ctx: MDContext(color: Palette.muted))
|
||||
.padding(.leading, 20)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
@@ -587,6 +607,11 @@ private struct TodoRow: View {
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Open \(task.name)")
|
||||
} else if !item.body.isEmpty {
|
||||
Button(action: toggle) {
|
||||
text.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
} else {
|
||||
text
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user