Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ae83946
first
clocksmith Mar 18, 2019
33ea3a2
finished breaking changes, need test updates
clocksmith Mar 18, 2019
6905520
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Mar 18, 2019
7160df0
m
clocksmith Mar 19, 2019
e401055
merge
clocksmith Mar 30, 2019
8130024
slider_test tests passing
clocksmith Mar 31, 2019
8ffbaed
updating slider theme tests
clocksmith Apr 1, 2019
b0498fd
tests pass
clocksmith Apr 2, 2019
3db99f1
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 2, 2019
ac52a38
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 2, 2019
c3828a9
m
clocksmith Apr 2, 2019
6fc7be4
fix lobe
clocksmith Apr 2, 2019
fb6c98a
m
clocksmith Apr 3, 2019
253141b
fix lobe
clocksmith Apr 3, 2019
7a48d4e
remove unused import
clocksmith Apr 3, 2019
4b7304b
analuzer
clocksmith Apr 3, 2019
9cb0514
analyzer
clocksmith Apr 3, 2019
76ba565
tests pass
clocksmith Apr 3, 2019
24f1d4f
add docs
clocksmith Apr 4, 2019
9def771
remove whitespace
clocksmith Apr 4, 2019
0ecb5f4
Empty commit to rerun tests
clocksmith Apr 4, 2019
f17e140
addressing comments
clocksmith Apr 5, 2019
9c1c59f
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 5, 2019
aa91414
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 8, 2019
d93da77
resolving comments
clocksmith Apr 8, 2019
0f392bb
resolve comments
clocksmith Apr 8, 2019
4679b45
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 8, 2019
5f1a182
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 9, 2019
a3911c6
resolve comments
clocksmith Apr 9, 2019
1976859
resolve comments
clocksmith Apr 9, 2019
ae34070
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 9, 2019
7c65374
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 10, 2019
6441278
remove invalid theme data test on slider
clocksmith Apr 10, 2019
d4533f7
adding merge and in the middle of writing test
clocksmith Apr 10, 2019
0d99bff
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 15, 2019
2ba2ea1
undo sliderThemeData.merge additions
clocksmith Apr 16, 2019
f783391
resolve comments
clocksmith Apr 16, 2019
f1f059c
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 18, 2019
136a92a
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 18, 2019
3f0b334
rect track uses thumb radius
clocksmith Apr 22, 2019
f44adf9
Merge branch 'master' of https://github.com/flutter/flutter into slid…
clocksmith Apr 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 37 additions & 17 deletions packages/flutter/lib/src/material/slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -428,27 +428,52 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
return widget.max > widget.min ? (value - widget.min) / (widget.max - widget.min) : 0.0;
}

static const double _defaultTrackHeight = 2;
static const SliderTrackShape _defaultTrackShape = RoundedRectSliderTrackShape();
static const SliderTickMarkShape _defaultTickMarkShape = RoundSliderTickMarkShape();
static const SliderComponentShape _defaultOverlayShape = RoundSliderOverlayShape();
static const SliderComponentShape _defaultThumbShape = RoundSliderThumbShape();
static const SliderComponentShape _defaultValueIndicatorShape = PaddleSliderValueIndicatorShape();
static const ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete;

@override
Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context));
assert(debugCheckHasMediaQuery(context));

final ThemeData theme = Theme.of(context);
SliderThemeData sliderTheme = SliderTheme.of(context);

// If the widget has active or inactive colors specified, then we plug them
// in to the slider theme as best we can. If the developer wants more
// control than that, then they need to use a SliderTheme.
if (widget.activeColor != null || widget.inactiveColor != null) {
sliderTheme = sliderTheme.copyWith(
activeTrackColor: widget.activeColor,
inactiveTrackColor: widget.inactiveColor,
activeTickMarkColor: widget.inactiveColor,
inactiveTickMarkColor: widget.activeColor,
thumbColor: widget.activeColor,
valueIndicatorColor: widget.activeColor,
overlayColor: widget.activeColor?.withAlpha(0x29),
);
}
// control than that, then they need to use a SliderTheme. The default
// colors come from the ThemeData.colorScheme. These colors, along with
// the default shapes and text styles are aligned to the Material
// Guidelines.
sliderTheme = sliderTheme.copyWith(
trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight,
activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary,
inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24),
disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32),
disabledInactiveTrackColor: sliderTheme.disabledInactiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.12),
activeTickMarkColor: widget.inactiveColor ?? sliderTheme.activeTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.54),
inactiveTickMarkColor: widget.activeColor ?? sliderTheme.inactiveTickMarkColor ?? theme.colorScheme.primary.withOpacity(0.54),
disabledActiveTickMarkColor: sliderTheme.disabledActiveTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.12),
disabledInactiveTickMarkColor: sliderTheme.disabledInactiveTickMarkColor ?? theme.colorScheme.onSurface.withOpacity(0.12),
thumbColor: widget.activeColor ?? sliderTheme.thumbColor ?? theme.colorScheme.primary,
disabledThumbColor: sliderTheme.disabledThumbColor ?? theme.colorScheme.onSurface.withOpacity(0.38),
overlayColor: widget.activeColor?.withOpacity(0.12) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12),
valueIndicatorColor: widget.activeColor ?? sliderTheme.valueIndicatorColor ?? theme.colorScheme.primary,
trackShape: sliderTheme.trackShape ?? _defaultTrackShape,
tickMarkShape: sliderTheme.tickMarkShape ?? _defaultTickMarkShape,
thumbShape: sliderTheme.thumbShape ?? _defaultThumbShape,
overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape,
valueIndicatorShape: sliderTheme.valueIndicatorShape ?? _defaultValueIndicatorShape,
showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator,
valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.body2.copyWith(
color: theme.colorScheme.onPrimary,
),
);

return _SliderRenderObjectWidget(
value: _unlerp(widget.value),
Expand Down Expand Up @@ -498,7 +523,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
divisions: divisions,
label: label,
sliderTheme: sliderTheme,
theme: Theme.of(context),
mediaQueryData: mediaQueryData,
onChanged: onChanged,
onChangeStart: onChangeStart,
Expand Down Expand Up @@ -536,7 +560,6 @@ class _RenderSlider extends RenderBox {
int divisions,
String label,
SliderThemeData sliderTheme,
ThemeData theme,
MediaQueryData mediaQueryData,
TargetPlatform platform,
ValueChanged<double> onChanged,
Expand All @@ -554,7 +577,6 @@ class _RenderSlider extends RenderBox {
_value = value,
_divisions = divisions,
_sliderTheme = sliderTheme,
_theme = theme,
_mediaQueryData = mediaQueryData,
_onChanged = onChanged,
_state = state,
Expand Down Expand Up @@ -983,7 +1005,6 @@ class _RenderSlider extends RenderBox {
isEnabled: isInteractive,
);

// TODO(closkmith): Move this to paint after the thumb.
if (!_overlayAnimation.isDismissed) {
_sliderTheme.overlayShape.paint(
context,
Expand All @@ -1000,7 +1021,6 @@ class _RenderSlider extends RenderBox {
}

if (isDiscrete) {
// TODO(clocksmith): Align tick mark centers to ends of track by not subtracting diameter from length.
final double tickMarkWidth = _sliderTheme.tickMarkShape.getPreferredSize(
isEnabled: isInteractive,
sliderTheme: _sliderTheme,
Expand Down
Loading