diff options
Diffstat (limited to 'Sources/NorgUI/Views/Blocks/BlockTaskRow.swift')
| -rw-r--r-- | Sources/NorgUI/Views/Blocks/BlockTaskRow.swift | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Sources/NorgUI/Views/Blocks/BlockTaskRow.swift b/Sources/NorgUI/Views/Blocks/BlockTaskRow.swift new file mode 100644 index 0000000..45255cd --- /dev/null +++ b/Sources/NorgUI/Views/Blocks/BlockTaskRow.swift @@ -0,0 +1,23 @@ +import NorgKit +import SwiftUI + +/// Adapts any block with status to a NorgTaskView +struct BlockTaskRow: View { + @Environment(\.norgTheme) private var theme + + let status: TaskStatus + let content: [InlineSpan] + let font: Font + let line: Int + let onSetStatus: (Int, TaskStatus) -> Void + + var body: some View { + NorgTaskView( + status: status, + text: AttributedString(norg: content, baseFont: font, theme: theme), + font: font, + onToggle: { onSetStatus(line, status == .done ? .undone : .done) }, + onSetStatus: { onSetStatus(line, $0) } + ) + } +} |