Skip to content

Commit f8bebf3

Browse files
committed
wip
1 parent 7883076 commit f8bebf3

2 files changed

Lines changed: 14 additions & 34 deletions

File tree

Example/Example/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct ContentView: View {
1717
id: \.x,
1818
selectedData: $selectedData
1919
)
20-
.hiddenChart(true)
20+
// .hiddenChart(true)
2121
// .frame(height: 300, alignment: .bottom)
2222
// .hiddenChart(true)
2323
// .minCount(3)

Sources/GraphRangeSlider/GraphRangeSlider.swift

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,8 @@ public struct GraphRangeSlider<Data, ID>: View where Data: RandomAccessCollectio
2626
@Environment(\.isHiddenChart) private var isHiddenChart: Bool
2727

2828
public var body: some View {
29-
Group {
30-
if isHiddenChart {
31-
Group {
32-
if !positions.isEmpty {
33-
Slider(
34-
positions: positions,
35-
onEnded: { builder.onEnded.call(selectedData) },
36-
leftCurrentIndex: $leftCurrentIndex,
37-
rightCurrentIndex: $rightCurrentIndex
38-
)
39-
.frame(height: toggleRadius * 2)
40-
}
41-
}
42-
.onAppear {
43-
if positions.isEmpty {
44-
updatePositions()
45-
updateIndices()
46-
}
47-
}
48-
} else {
29+
VStack(spacing: margin) {
30+
if !isHiddenChart {
4931
Chart(data, id: id) { data in
5032
BarMark(
5133
x: .value(PlottableKeys.x, String(describing: data.x)),
@@ -60,26 +42,24 @@ public struct GraphRangeSlider<Data, ID>: View where Data: RandomAccessCollectio
6042
)
6143
)
6244
}
63-
.padding(.horizontal, toggleRadius * 2)
64-
.padding(.bottom, toggleRadius + sliderBarHeight / 2 + margin)
6545
.chartXAxis(.hidden)
6646
.chartYAxis(.hidden)
6747
.chartLegend(.hidden)
6848
.chartForegroundStyleScale([
6949
Status.active: activeColor,
7050
Status.inactive: inactiveColor
7151
])
72-
.overlay(alignment: .bottom) {
73-
if !positions.isEmpty {
74-
Slider(
75-
positions: positions,
76-
onEnded: { builder.onEnded.call(selectedData) },
77-
leftCurrentIndex: $leftCurrentIndex,
78-
rightCurrentIndex: $rightCurrentIndex
79-
)
80-
.frame(height: toggleRadius * 2)
81-
}
82-
}
52+
.padding(.horizontal, toggleRadius * 2)
53+
}
54+
55+
if !positions.isEmpty {
56+
Slider(
57+
positions: positions,
58+
onEnded: { builder.onEnded.call(selectedData) },
59+
leftCurrentIndex: $leftCurrentIndex,
60+
rightCurrentIndex: $rightCurrentIndex
61+
)
62+
.frame(height: toggleRadius * 2)
8363
}
8464
}
8565
.background(

0 commit comments

Comments
 (0)