@@ -20,25 +20,37 @@ struct ProgressView<R: CustomRegistry>: View {
20
20
if let timerIntervalStart = element. attributeValue ( for: " timer-interval-start " ) . flatMap ( { try ? ElixirDateParseStrategy ( ) . parse ( $0) } ) ,
21
21
let timerIntervalEnd = element. attributeValue ( for: " timer-interval-end " ) . flatMap ( { try ? ElixirDateParseStrategy ( ) . parse ( $0) } )
22
22
{
23
- // TODO: Note that this variant has a default `currentValueLabel`, which should be used if no current value label slot is used. It seems to only be active when initializing without the `currentValueLabel` argument.
24
- SwiftUI . ProgressView (
25
- timerInterval: timerIntervalStart... timerIntervalEnd,
26
- countsDown: element. attributeValue ( for: " counts-down " ) != " false "
27
- ) {
28
- context. buildChildren ( of: element)
23
+ // SwiftUI's default `currentValueLabel` is not present unless the argument is not included in the initializer.
24
+ // Check if we have it first otherwise use the default.
25
+ if context. hasChild ( of: element, withTagName: " current-value-label " , namespace: " progress-view " ) {
26
+ SwiftUI . ProgressView (
27
+ timerInterval: timerIntervalStart... timerIntervalEnd,
28
+ countsDown: element. attributeValue ( for: " counts-down " ) != " false "
29
+ ) {
30
+ context. buildChildren ( of: element, withTagName: " label " , namespace: " progress-view " , includeDefaultSlot: true )
31
+ } currentValueLabel: {
32
+ context. buildChildren ( of: element, withTagName: " current-value-label " , namespace: " progress-view " )
33
+ }
34
+ } else {
35
+ SwiftUI . ProgressView (
36
+ timerInterval: timerIntervalStart... timerIntervalEnd,
37
+ countsDown: element. attributeValue ( for: " counts-down " ) != " false "
38
+ ) {
39
+ context. buildChildren ( of: element, withTagName: " label " , namespace: " progress-view " , includeDefaultSlot: true )
40
+ }
29
41
}
30
42
} else if let value = element. attributeValue ( for: " value " ) . flatMap ( Double . init) {
31
43
SwiftUI . ProgressView (
32
44
value: value,
33
45
total: element. attributeValue ( for: " total " ) . flatMap ( Double . init) ?? 1
34
46
) {
35
- context. buildChildren ( of: element)
47
+ context. buildChildren ( of: element, withTagName : " label " , namespace : " progress-view " , includeDefaultSlot : true )
36
48
} currentValueLabel: {
37
- EmptyView ( ) // TODO: Implement currentValueLabel once we have a design for multi-body content.
49
+ context . buildChildren ( of : element , withTagName : " current-value-label " , namespace : " progress-view " )
38
50
}
39
51
} else {
40
52
SwiftUI . ProgressView {
41
- context. buildChildren ( of: element)
53
+ context. buildChildren ( of: element, withTagName : " label " , namespace : " progress-view " , includeDefaultSlot : true )
42
54
}
43
55
}
44
56
}
0 commit comments