@@ -78,6 +78,9 @@ public struct CompactSlider<Value: BinaryFloatingPoint, ValueLabel: View>: View
7878 let handleVisibility : HandleVisibility
7979 let scaleVisibility : ScaleVisibility
8080 let minHeight : CGFloat
81+ // Slider height would at least be 10 pt if we do not set this explicitly since we are using Rectangle/Color in HandleView implementation.
82+ // Explanation: When Color is used as a View, it would at least take 10 * 10 if we do not set its frame(width/height)/frame(maxWidth/maxHeight) explicitly.
83+ let maxHeight : CGFloat ?
8184 let enableDragGestureDelayForiOS : Bool
8285 @Binding var state : CompactSliderState
8386 private let valueLabel : ValueLabel
@@ -106,6 +109,7 @@ public struct CompactSlider<Value: BinaryFloatingPoint, ValueLabel: View>: View
106109 /// - handleVisibility: the handle visibility determines the rules for showing the handle.
107110 /// - scaleVisibility: the scale visibility determines the rules for showing the scale.
108111 /// - minHeight: the slider minimum height.
112+ /// - maxHeight: the slider maximum height (optional).
109113 /// - enableDragGestureDelayForiOS: enables delay for iOS when sliders inside ``ScrollView`` or ``Form``.
110114 /// - state: the state of the slider with tracking information.
111115 /// - valueLabel: a `View` that describes the purpose of the instance.
@@ -118,6 +122,7 @@ public struct CompactSlider<Value: BinaryFloatingPoint, ValueLabel: View>: View
118122 handleVisibility: HandleVisibility = . standard,
119123 scaleVisibility: ScaleVisibility = . hovering,
120124 minHeight: CGFloat = . compactSliderMinHeight,
125+ maxHeight: CGFloat ? = nil ,
121126 enableDragGestureDelayForiOS: Bool = true ,
122127 state: Binding < CompactSliderState > = . constant( . inactive) ,
123128 @ViewBuilder valueLabel: ( ) -> ValueLabel
@@ -131,6 +136,7 @@ public struct CompactSlider<Value: BinaryFloatingPoint, ValueLabel: View>: View
131136 self . handleVisibility = handleVisibility
132137 self . scaleVisibility = scaleVisibility
133138 self . minHeight = minHeight
139+ self . maxHeight = maxHeight
134140 self . enableDragGestureDelayForiOS = enableDragGestureDelayForiOS
135141 _state = state
136142 self . valueLabel = valueLabel ( )
@@ -159,6 +165,7 @@ public struct CompactSlider<Value: BinaryFloatingPoint, ValueLabel: View>: View
159165 /// - handleVisibility: the handle visibility determines the rules for showing the handle.
160166 /// - scaleVisibility: the scale visibility determines the rules for showing the scale.
161167 /// - minHeight: the slider minimum height.
168+ /// - maxHeight: the slider maximum height (optional).
162169 /// - enableDragGestureDelayForiOS: enables delay for iOS when sliders inside ``ScrollView`` or ``Form``.
163170 /// - state: the state of the slider with tracking information.
164171 /// - valueLabel: a `View` that describes the purpose of the instance.
@@ -171,6 +178,7 @@ public struct CompactSlider<Value: BinaryFloatingPoint, ValueLabel: View>: View
171178 handleVisibility: HandleVisibility = . standard,
172179 scaleVisibility: ScaleVisibility = . hovering,
173180 minHeight: CGFloat = . compactSliderMinHeight,
181+ maxHeight: CGFloat ? = nil ,
174182 enableDragGestureDelayForiOS: Bool = true ,
175183 state: Binding < CompactSliderState > = . constant( . inactive) ,
176184 @ViewBuilder valueLabel: ( ) -> ValueLabel
@@ -184,6 +192,7 @@ public struct CompactSlider<Value: BinaryFloatingPoint, ValueLabel: View>: View
184192 self . handleVisibility = handleVisibility
185193 self . scaleVisibility = scaleVisibility
186194 self . minHeight = minHeight
195+ self . maxHeight = maxHeight
187196 self . enableDragGestureDelayForiOS = enableDragGestureDelayForiOS
188197 _state = state
189198 self . valueLabel = valueLabel ( )
@@ -271,7 +280,7 @@ public struct CompactSlider<Value: BinaryFloatingPoint, ValueLabel: View>: View
271280 . padding ( . horizontal, . labelPadding)
272281 }
273282 . opacity ( isEnabled ? 1 : 0.5 )
274- . frame ( minHeight: minHeight)
283+ . frame ( minHeight: minHeight, maxHeight : maxHeight )
275284 . fixedSize ( horizontal: false , vertical: true )
276285 }
277286
0 commit comments