aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgUI/Views/Blocks/ListItemView.swift
blob: 3429a428c8de3c35378f2f34b7e6b2736548a275 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import NorgKit
import SwiftUI

struct ListItemView: View {
  @Environment(\.norgTheme) private var theme

  let marker: String
  let showsMarkerWithTask: Bool
  let status: TaskStatus?
  let content: [InlineSpan]
  let line: Int
  let onSetStatus: (Int, TaskStatus) -> Void

  var body: some View {
    HStack(alignment: .firstTextBaseline, spacing: 8) {
      if let status {
        if showsMarkerWithTask {
          Text(marker)
            .foregroundStyle(.secondary)
            .monospacedDigit()
        }
        BlockTaskRow(
          status: status, content: content, font: theme.body, line: line, onSetStatus: onSetStatus
        )
      } else {
        Text(marker)
          .foregroundStyle(.secondary)
          .monospacedDigit()
        NorgInlineText(spans: content)
      }
    }
  }
}