aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgUI/Views/Blocks/HeadingView.swift
blob: 3b65134c4c3d11ae55a1d9d9c86e74797e455513 (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
import NorgKit
import SwiftUI

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

  let level: Int
  let status: TaskStatus?
  let content: [InlineSpan]
  let line: Int
  let onSetStatus: (Int, TaskStatus) -> Void

  var body: some View {
    let font = theme.heading(level)
    Group {
      if let status {
        BlockTaskRow(
          status: status, content: content, font: font, line: line, onSetStatus: onSetStatus)
      } else {
        Text(AttributedString(norg: content, baseFont: font, theme: theme))
          .font(font)
      }
    }
    .padding(.top, 4)
  }
}