aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgUI/Views/Blocks/BlockTaskRow.swift
blob: 45255cd332e6ec239bc3df242e89b55c5a27d45f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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) }
    )
  }
}