[Material] Fix TextDirection and selected thumb for RangeSliderThumbShape and RangeSliderValueIndicatorShape (#34501)
Expose the RangeSlider's TextDirection in the RangeSliderThumbShape's abstract paint() method, and ensure that start and end thumb are non-null when being passed to the thumb and value indicator shape paint methods.
This commit is contained in:
parent
822bbaadde
commit
8b2ccca3a4
@ -1229,6 +1229,7 @@ class _RenderRangeSlider extends RenderBox {
|
||||
|
||||
final bool isLastThumbStart = _lastThumbSelection == Thumb.start;
|
||||
final Thumb bottomThumb = isLastThumbStart ? Thumb.end : Thumb.start;
|
||||
final Thumb topThumb = isLastThumbStart ? Thumb.start : Thumb.end;
|
||||
final Offset bottomThumbCenter = isLastThumbStart ? endThumbCenter : startThumbCenter;
|
||||
final Offset topThumbCenter = isLastThumbStart ? startThumbCenter : endThumbCenter;
|
||||
final TextPainter bottomLabelPainter = isLastThumbStart ? _endLabelPainter : _startLabelPainter;
|
||||
@ -1262,7 +1263,7 @@ class _RenderRangeSlider extends RenderBox {
|
||||
parentBox: this,
|
||||
sliderTheme: _sliderTheme,
|
||||
textDirection: _textDirection,
|
||||
thumb: _lastThumbSelection,
|
||||
thumb: topThumb,
|
||||
value: topValue,
|
||||
);
|
||||
}
|
||||
@ -1274,6 +1275,7 @@ class _RenderRangeSlider extends RenderBox {
|
||||
enableAnimation: _enableAnimation,
|
||||
isDiscrete: isDiscrete,
|
||||
isOnTop: false,
|
||||
textDirection: textDirection,
|
||||
sliderTheme: _sliderTheme,
|
||||
thumb: bottomThumb,
|
||||
);
|
||||
@ -1284,8 +1286,9 @@ class _RenderRangeSlider extends RenderBox {
|
||||
enableAnimation: _enableAnimation,
|
||||
isDiscrete: isDiscrete,
|
||||
isOnTop: thumbDelta < sliderTheme.rangeThumbShape.getPreferredSize(isEnabled, isDiscrete).width,
|
||||
textDirection: textDirection,
|
||||
sliderTheme: _sliderTheme,
|
||||
thumb: _lastThumbSelection,
|
||||
thumb: topThumb,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1193,6 +1193,10 @@ abstract class RangeSliderThumbShape {
|
||||
///
|
||||
/// {@macro flutter.material.rangeSlider.shape.sliderTheme}
|
||||
///
|
||||
/// [textDirection] can be used to determine how the orientation of either
|
||||
/// slider thumb should be changed, such as drawing different shapes for the
|
||||
/// left and right thumb.
|
||||
///
|
||||
/// {@macro flutter.material.rangeSlider.shape.thumb}
|
||||
void paint(
|
||||
PaintingContext context,
|
||||
@ -1202,6 +1206,7 @@ abstract class RangeSliderThumbShape {
|
||||
bool isDiscrete,
|
||||
bool isEnabled,
|
||||
bool isOnTop,
|
||||
TextDirection textDirection,
|
||||
SliderThemeData sliderTheme,
|
||||
Thumb thumb,
|
||||
});
|
||||
@ -2290,6 +2295,7 @@ class RoundRangeSliderThumbShape extends RangeSliderThumbShape {
|
||||
bool isEnabled = false,
|
||||
bool isOnTop,
|
||||
@required SliderThemeData sliderTheme,
|
||||
TextDirection textDirection,
|
||||
Thumb thumb,
|
||||
}) {
|
||||
assert(context != null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user