diff --git a/examples/flutter_gallery/lib/demo/material/slider_demo.dart b/examples/flutter_gallery/lib/demo/material/slider_demo.dart index fe3cd438f0..cb5ec76e51 100644 --- a/examples/flutter_gallery/lib/demo/material/slider_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/slider_demo.dart @@ -184,8 +184,8 @@ class _SliderDemoState extends State { children: [ new SliderTheme( data: theme.sliderTheme.copyWith( - activeRailColor: Colors.deepPurple, - inactiveRailColor: Colors.black26, + activeTrackColor: Colors.deepPurple, + inactiveTrackColor: Colors.black26, activeTickMarkColor: Colors.white70, inactiveTickMarkColor: Colors.black, overlayColor: Colors.black12, diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index a868eaddcd..3ad34f61bb 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -32,7 +32,7 @@ import 'theme.dart'; /// /// * The "thumb", which is a shape that slides horizontally when the user /// drags it. -/// * The "rail", which is the line that the slider thumb slides along. +/// * The "track", which is the line that the slider thumb slides along. /// * The "value indicator", which is a shape that pops up when the user /// is dragging the thumb to indicate the value being selected. /// * The "active" side of the slider is the side between the thumb and the @@ -50,7 +50,7 @@ import 'theme.dart'; /// slider. /// /// By default, a slider will be as wide as possible, centered vertically. When -/// given unbounded constraints, it will attempt to make the rail 144 pixels +/// given unbounded constraints, it will attempt to make the track 144 pixels /// wide (with margins on each side) and will shrink-wrap vertically. /// /// Requires one of its ancestors to be a [Material] widget. @@ -177,23 +177,23 @@ class Slider extends StatefulWidget { /// shape. final String label; - /// The color to use for the portion of the slider rail that is active. + /// The color to use for the portion of the slider track that is active. /// /// The "active" side of the slider is the side between the thumb and the /// minimum value. /// - /// Defaults to [SliderTheme.activeRailColor] of the current [SliderTheme]. + /// Defaults to [SliderTheme.activeTrackColor] of the current [SliderTheme]. /// /// Using a [SliderTheme] gives much more fine-grained control over the /// appearance of various components of the slider. final Color activeColor; - /// The color for the inactive portion of the slider rail. + /// The color for the inactive portion of the slider track. /// /// The "inactive" side of the slider is the side between the thumb and the /// maximum value. /// - /// Defaults to the [SliderTheme.inactiveRailColor] of the current + /// Defaults to the [SliderTheme.inactiveTrackColor] of the current /// [SliderTheme]. /// /// Using a [SliderTheme] gives much more fine-grained control over the @@ -297,8 +297,8 @@ class _SliderState extends State with TickerProviderStateMixin { // control than that, then they need to use a SliderTheme. if (widget.activeColor != null || widget.inactiveColor != null) { sliderTheme = sliderTheme.copyWith( - activeRailColor: widget.activeColor, - inactiveRailColor: widget.inactiveColor, + activeTrackColor: widget.activeColor, + inactiveTrackColor: widget.inactiveColor, activeTickMarkColor: widget.inactiveColor, inactiveTickMarkColor: widget.activeColor, thumbColor: widget.activeColor, @@ -423,9 +423,9 @@ class _RenderSlider extends RenderBox { static const Duration _positionAnimationDuration = const Duration(milliseconds: 75); static const double _overlayRadius = 16.0; static const double _overlayDiameter = _overlayRadius * 2.0; - static const double _railHeight = 2.0; - static const double _preferredRailWidth = 144.0; - static const double _preferredTotalWidth = _preferredRailWidth + _overlayDiameter; + static const double _trackHeight = 2.0; + static const double _preferredTrackWidth = 144.0; + static const double _preferredTotalWidth = _preferredTrackWidth + _overlayDiameter; static const Duration _minimumInteractionTime = const Duration(milliseconds: 500); static const double _adjustmentUnit = 0.1; // Matches iOS implementation of material slider. static final Tween _overlayRadiusTween = new Tween(begin: 0.0, end: _overlayRadius); @@ -440,7 +440,7 @@ class _RenderSlider extends RenderBox { bool _active = false; double _currentDragValue = 0.0; - double get _railLength => size.width - _overlayDiameter; + double get _trackLength => size.width - _overlayDiameter; bool get isInteractive => onChanged != null; @@ -619,7 +619,7 @@ class _RenderSlider extends RenderBox { } double _getValueFromGlobalPosition(Offset globalPosition) { - final double visualPosition = (globalToLocal(globalPosition).dx - _overlayRadius) / _railLength; + final double visualPosition = (globalToLocal(globalPosition).dx - _overlayRadius) / _trackLength; return _getValueFromVisualPosition(visualPosition); } @@ -666,7 +666,7 @@ class _RenderSlider extends RenderBox { void _handleDragUpdate(DragUpdateDetails details) { if (isInteractive) { - final double valueDelta = details.primaryDelta / _railLength; + final double valueDelta = details.primaryDelta / _trackLength; switch (textDirection) { case TextDirection.rtl: _currentDragValue -= valueDelta; @@ -732,24 +732,24 @@ class _RenderSlider extends RenderBox { void _paintTickMarks( Canvas canvas, - Rect railLeft, - Rect railRight, + Rect trackLeft, + Rect trackRight, Paint leftPaint, Paint rightPaint, ) { if (isDiscrete) { - // The ticks are tiny circles that are the same height as the rail. - const double tickRadius = _railHeight / 2.0; - final double railWidth = railRight.right - railLeft.left; - final double dx = (railWidth - _railHeight) / divisions; + // The ticks are tiny circles that are the same height as the track. + const double tickRadius = _trackHeight / 2.0; + final double trackWidth = trackRight.right - trackLeft.left; + final double dx = (trackWidth - _trackHeight) / divisions; // If the ticks would be too dense, don't bother painting them. - if (dx >= 3.0 * _railHeight) { + if (dx >= 3.0 * _trackHeight) { for (int i = 0; i <= divisions; i += 1) { - final double left = railLeft.left + i * dx; - final Offset center = new Offset(left + tickRadius, railLeft.top + tickRadius); - if (railLeft.contains(center)) { + final double left = trackLeft.left + i * dx; + final Offset center = new Offset(left + tickRadius, trackLeft.top + tickRadius); + if (trackLeft.contains(center)) { canvas.drawCircle(center, tickRadius, leftPaint); - } else if (railRight.contains(center)) { + } else if (trackRight.contains(center)) { canvas.drawCircle(center, tickRadius, rightPaint); } } @@ -774,71 +774,71 @@ class _RenderSlider extends RenderBox { void paint(PaintingContext context, Offset offset) { final Canvas canvas = context.canvas; - final double railLength = size.width - 2 * _overlayRadius; + final double trackLength = size.width - 2 * _overlayRadius; final double value = _state.positionController.value; - final ColorTween activeRailEnableColor = new ColorTween(begin: _sliderTheme.disabledActiveRailColor, end: _sliderTheme.activeRailColor); - final ColorTween inactiveRailEnableColor = new ColorTween(begin: _sliderTheme.disabledInactiveRailColor, end: _sliderTheme.inactiveRailColor); + final ColorTween activeTrackEnableColor = new ColorTween(begin: _sliderTheme.disabledActiveTrackColor, end: _sliderTheme.activeTrackColor); + final ColorTween inactiveTrackEnableColor = new ColorTween(begin: _sliderTheme.disabledInactiveTrackColor, end: _sliderTheme.inactiveTrackColor); final ColorTween activeTickMarkEnableColor = new ColorTween(begin: _sliderTheme.disabledActiveTickMarkColor, end: _sliderTheme.activeTickMarkColor); final ColorTween inactiveTickMarkEnableColor = new ColorTween(begin: _sliderTheme.disabledInactiveTickMarkColor, end: _sliderTheme.inactiveTickMarkColor); - final Paint activeRailPaint = new Paint()..color = activeRailEnableColor.evaluate(_enableAnimation); - final Paint inactiveRailPaint = new Paint()..color = inactiveRailEnableColor.evaluate(_enableAnimation); + final Paint activeTrackPaint = new Paint()..color = activeTrackEnableColor.evaluate(_enableAnimation); + final Paint inactiveTrackPaint = new Paint()..color = inactiveTrackEnableColor.evaluate(_enableAnimation); final Paint activeTickMarkPaint = new Paint()..color = activeTickMarkEnableColor.evaluate(_enableAnimation); final Paint inactiveTickMarkPaint = new Paint()..color = inactiveTickMarkEnableColor.evaluate(_enableAnimation); double visualPosition; - Paint leftRailPaint; - Paint rightRailPaint; + Paint leftTrackPaint; + Paint rightTrackPaint; Paint leftTickMarkPaint; Paint rightTickMarkPaint; switch (textDirection) { case TextDirection.rtl: visualPosition = 1.0 - value; - leftRailPaint = inactiveRailPaint; - rightRailPaint = activeRailPaint; + leftTrackPaint = inactiveTrackPaint; + rightTrackPaint = activeTrackPaint; leftTickMarkPaint = inactiveTickMarkPaint; rightTickMarkPaint = activeTickMarkPaint; break; case TextDirection.ltr: visualPosition = value; - leftRailPaint = activeRailPaint; - rightRailPaint = inactiveRailPaint; + leftTrackPaint = activeTrackPaint; + rightTrackPaint = inactiveTrackPaint; leftTickMarkPaint = activeTickMarkPaint; rightTickMarkPaint = inactiveTickMarkPaint; break; } - const double railRadius = _railHeight / 2.0; + const double trackRadius = _trackHeight / 2.0; const double thumbGap = 2.0; - final double railVerticalCenter = offset.dy + (size.height) / 2.0; - final double railLeft = offset.dx + _overlayRadius; - final double railTop = railVerticalCenter - railRadius; - final double railBottom = railVerticalCenter + railRadius; - final double railRight = railLeft + railLength; - final double railActive = railLeft + railLength * visualPosition; + final double trackVerticalCenter = offset.dy + (size.height) / 2.0; + final double trackLeft = offset.dx + _overlayRadius; + final double trackTop = trackVerticalCenter - trackRadius; + final double trackBottom = trackVerticalCenter + trackRadius; + final double trackRight = trackLeft + trackLength; + final double trackActive = trackLeft + trackLength * visualPosition; final double thumbRadius = _sliderTheme.thumbShape.getPreferredSize(isInteractive, isDiscrete).width / 2.0; - final double railActiveLeft = math.max(0.0, railActive - thumbRadius - thumbGap * (1.0 - _enableAnimation.value)); - final double railActiveRight = math.min(railActive + thumbRadius + thumbGap * (1.0 - _enableAnimation.value), railRight); - final Rect railLeftRect = new Rect.fromLTRB(railLeft, railTop, railActiveLeft, railBottom); - final Rect railRightRect = new Rect.fromLTRB(railActiveRight, railTop, railRight, railBottom); + final double trackActiveLeft = math.max(0.0, trackActive - thumbRadius - thumbGap * (1.0 - _enableAnimation.value)); + final double trackActiveRight = math.min(trackActive + thumbRadius + thumbGap * (1.0 - _enableAnimation.value), trackRight); + final Rect trackLeftRect = new Rect.fromLTRB(trackLeft, trackTop, trackActiveLeft, trackBottom); + final Rect trackRightRect = new Rect.fromLTRB(trackActiveRight, trackTop, trackRight, trackBottom); - final Offset thumbCenter = new Offset(railActive, railVerticalCenter); + final Offset thumbCenter = new Offset(trackActive, trackVerticalCenter); - // Paint the rail. + // Paint the track. if (visualPosition > 0.0) { - canvas.drawRect(railLeftRect, leftRailPaint); + canvas.drawRect(trackLeftRect, leftTrackPaint); } if (visualPosition < 1.0) { - canvas.drawRect(railRightRect, rightRailPaint); + canvas.drawRect(trackRightRect, rightTrackPaint); } _paintOverlay(canvas, thumbCenter); _paintTickMarks( canvas, - railLeftRect, - railRightRect, + trackLeftRect, + trackRightRect, leftTickMarkPaint, rightTickMarkPaint, ); diff --git a/packages/flutter/lib/src/material/slider_theme.dart b/packages/flutter/lib/src/material/slider_theme.dart index 92cb63f68b..6e93b709c8 100644 --- a/packages/flutter/lib/src/material/slider_theme.dart +++ b/packages/flutter/lib/src/material/slider_theme.dart @@ -62,7 +62,7 @@ class SliderTheme extends InheritedWidget { /// @override /// Widget build(BuildContext context) { /// return new SliderTheme( - /// data: SliderTheme.of(context).copyWith(activeRailColor: const Color(0xff804040)), + /// data: SliderTheme.of(context).copyWith(activeTrackColor: const Color(0xff804040)), /// child: new Slider( /// onChanged: (double value) { setState(() { _rocketThrust = value; }); }, /// value: _rocketThrust, @@ -121,7 +121,7 @@ enum ShowValueIndicator { /// /// * The "thumb", which is a shape that slides horizontally when the user /// drags it. -/// * The "rail", which is the line that the slider thumb slides along. +/// * The "track", which is the line that the slider thumb slides along. /// * The "value indicator", which is a shape that pops up when the user /// is dragging the thumb to indicate the value being selected. /// * The "active" side of the slider is the side between the thumb and the @@ -169,7 +169,7 @@ class SliderThemeData extends Diagnosticable { /// @override /// Widget build(BuildContext context) { /// return new SliderTheme( - /// data: SliderTheme.of(context).copyWith(activeRailColor: const Color(0xff404080)), + /// data: SliderTheme.of(context).copyWith(activeTrackColor: const Color(0xff404080)), /// child: new Slider( /// onChanged: (double value) { setState(() { _bliss = value; }); }, /// value: _bliss, @@ -179,10 +179,10 @@ class SliderThemeData extends Diagnosticable { /// } /// ``` const SliderThemeData({ - @required this.activeRailColor, - @required this.inactiveRailColor, - @required this.disabledActiveRailColor, - @required this.disabledInactiveRailColor, + @required this.activeTrackColor, + @required this.inactiveTrackColor, + @required this.disabledActiveTrackColor, + @required this.disabledInactiveTrackColor, @required this.activeTickMarkColor, @required this.inactiveTickMarkColor, @required this.disabledActiveTickMarkColor, @@ -195,10 +195,10 @@ class SliderThemeData extends Diagnosticable { @required this.valueIndicatorShape, @required this.showValueIndicator, @required this.valueIndicatorTextStyle, - }) : assert(activeRailColor != null), - assert(inactiveRailColor != null), - assert(disabledActiveRailColor != null), - assert(disabledInactiveRailColor != null), + }) : assert(activeTrackColor != null), + assert(inactiveTrackColor != null), + assert(disabledActiveTrackColor != null), + assert(disabledInactiveTrackColor != null), assert(activeTickMarkColor != null), assert(inactiveTickMarkColor != null), assert(disabledActiveTickMarkColor != null), @@ -234,10 +234,10 @@ class SliderThemeData extends Diagnosticable { // These are Material Design defaults, and are used to derive // component Colors (with opacity) from base colors. - const int activeRailAlpha = 0xff; - const int inactiveRailAlpha = 0x3d; // 24% opacity - const int disabledActiveRailAlpha = 0x52; // 32% opacity - const int disabledInactiveRailAlpha = 0x1f; // 12% opacity + const int activeTrackAlpha = 0xff; + const int inactiveTrackAlpha = 0x3d; // 24% opacity + const int disabledActiveTrackAlpha = 0x52; // 32% opacity + const int disabledInactiveTrackAlpha = 0x1f; // 12% opacity const int activeTickMarkAlpha = 0x8a; // 54% opacity const int inactiveTickMarkAlpha = 0x8a; // 54% opacity const int disabledActiveTickMarkAlpha = 0x1f; // 12% opacity @@ -254,10 +254,10 @@ class SliderThemeData extends Diagnosticable { const int overlayLightAlpha = 0x29; // 16% opacity return new SliderThemeData( - activeRailColor: primaryColor.withAlpha(activeRailAlpha), - inactiveRailColor: primaryColor.withAlpha(inactiveRailAlpha), - disabledActiveRailColor: primaryColorDark.withAlpha(disabledActiveRailAlpha), - disabledInactiveRailColor: primaryColorDark.withAlpha(disabledInactiveRailAlpha), + activeTrackColor: primaryColor.withAlpha(activeTrackAlpha), + inactiveTrackColor: primaryColor.withAlpha(inactiveTrackAlpha), + disabledActiveTrackColor: primaryColorDark.withAlpha(disabledActiveTrackAlpha), + disabledInactiveTrackColor: primaryColorDark.withAlpha(disabledInactiveTrackAlpha), activeTickMarkColor: primaryColorLight.withAlpha(activeTickMarkAlpha), inactiveTickMarkColor: primaryColor.withAlpha(inactiveTickMarkAlpha), disabledActiveTickMarkColor: primaryColorLight.withAlpha(disabledActiveTickMarkAlpha), @@ -273,35 +273,35 @@ class SliderThemeData extends Diagnosticable { ); } - /// The color of the [Slider] rail between the [Slider.min] position and the + /// The color of the [Slider] track between the [Slider.min] position and the /// current thumb position. - final Color activeRailColor; + final Color activeTrackColor; - /// The color of the [Slider] rail between the current thumb position and the + /// The color of the [Slider] track between the current thumb position and the /// [Slider.max] position. - final Color inactiveRailColor; + final Color inactiveTrackColor; - /// The color of the [Slider] rail between the [Slider.min] position and the + /// The color of the [Slider] track between the [Slider.min] position and the /// current thumb position when the [Slider] is disabled. - final Color disabledActiveRailColor; + final Color disabledActiveTrackColor; - /// The color of the [Slider] rail between the current thumb position and the + /// The color of the [Slider] track between the current thumb position and the /// [Slider.max] position when the [Slider] is disabled. - final Color disabledInactiveRailColor; + final Color disabledInactiveTrackColor; - /// The color of the rail's tick marks that are drawn between the [Slider.min] + /// The color of the track's tick marks that are drawn between the [Slider.min] /// position and the current thumb position. final Color activeTickMarkColor; - /// The color of the rail's tick marks that are drawn between the current + /// The color of the track's tick marks that are drawn between the current /// thumb position and the [Slider.max] position. final Color inactiveTickMarkColor; - /// The color of the rail's tick marks that are drawn between the [Slider.min] + /// The color of the track's tick marks that are drawn between the [Slider.min] /// position and the current thumb position when the [Slider] is disabled. final Color disabledActiveTickMarkColor; - /// The color of the rail's tick marks that are drawn between the current + /// The color of the track's tick marks that are drawn between the current /// thumb position and the [Slider.max] position when the [Slider] is /// disabled. final Color disabledInactiveTickMarkColor; @@ -350,10 +350,10 @@ class SliderThemeData extends Diagnosticable { /// Creates a copy of this object but with the given fields replaced with the /// new values. SliderThemeData copyWith({ - Color activeRailColor, - Color inactiveRailColor, - Color disabledActiveRailColor, - Color disabledInactiveRailColor, + Color activeTrackColor, + Color inactiveTrackColor, + Color disabledActiveTrackColor, + Color disabledInactiveTrackColor, Color activeTickMarkColor, Color inactiveTickMarkColor, Color disabledActiveTickMarkColor, @@ -368,10 +368,10 @@ class SliderThemeData extends Diagnosticable { TextStyle valueIndicatorTextStyle, }) { return new SliderThemeData( - activeRailColor: activeRailColor ?? this.activeRailColor, - inactiveRailColor: inactiveRailColor ?? this.inactiveRailColor, - disabledActiveRailColor: disabledActiveRailColor ?? this.disabledActiveRailColor, - disabledInactiveRailColor: disabledInactiveRailColor ?? this.disabledInactiveRailColor, + activeTrackColor: activeTrackColor ?? this.activeTrackColor, + inactiveTrackColor: inactiveTrackColor ?? this.inactiveTrackColor, + disabledActiveTrackColor: disabledActiveTrackColor ?? this.disabledActiveTrackColor, + disabledInactiveTrackColor: disabledInactiveTrackColor ?? this.disabledInactiveTrackColor, activeTickMarkColor: activeTickMarkColor ?? this.activeTickMarkColor, inactiveTickMarkColor: inactiveTickMarkColor ?? this.inactiveTickMarkColor, disabledActiveTickMarkColor: disabledActiveTickMarkColor ?? this.disabledActiveTickMarkColor, @@ -407,10 +407,10 @@ class SliderThemeData extends Diagnosticable { assert(b != null); assert(t != null); return new SliderThemeData( - activeRailColor: Color.lerp(a.activeRailColor, b.activeRailColor, t), - inactiveRailColor: Color.lerp(a.inactiveRailColor, b.inactiveRailColor, t), - disabledActiveRailColor: Color.lerp(a.disabledActiveRailColor, b.disabledActiveRailColor, t), - disabledInactiveRailColor: Color.lerp(a.disabledInactiveRailColor, b.disabledInactiveRailColor, t), + activeTrackColor: Color.lerp(a.activeTrackColor, b.activeTrackColor, t), + inactiveTrackColor: Color.lerp(a.inactiveTrackColor, b.inactiveTrackColor, t), + disabledActiveTrackColor: Color.lerp(a.disabledActiveTrackColor, b.disabledActiveTrackColor, t), + disabledInactiveTrackColor: Color.lerp(a.disabledInactiveTrackColor, b.disabledInactiveTrackColor, t), activeTickMarkColor: Color.lerp(a.activeTickMarkColor, b.activeTickMarkColor, t), inactiveTickMarkColor: Color.lerp(a.inactiveTickMarkColor, b.inactiveTickMarkColor, t), disabledActiveTickMarkColor: Color.lerp(a.disabledActiveTickMarkColor, b.disabledActiveTickMarkColor, t), @@ -429,10 +429,10 @@ class SliderThemeData extends Diagnosticable { @override int get hashCode { return hashValues( - activeRailColor, - inactiveRailColor, - disabledActiveRailColor, - disabledInactiveRailColor, + activeTrackColor, + inactiveTrackColor, + disabledActiveTrackColor, + disabledInactiveTrackColor, activeTickMarkColor, inactiveTickMarkColor, disabledActiveTickMarkColor, @@ -457,10 +457,10 @@ class SliderThemeData extends Diagnosticable { return false; } final SliderThemeData otherData = other; - return otherData.activeRailColor == activeRailColor && - otherData.inactiveRailColor == inactiveRailColor && - otherData.disabledActiveRailColor == disabledActiveRailColor && - otherData.disabledInactiveRailColor == disabledInactiveRailColor && + return otherData.activeTrackColor == activeTrackColor && + otherData.inactiveTrackColor == inactiveTrackColor && + otherData.disabledActiveTrackColor == disabledActiveTrackColor && + otherData.disabledInactiveTrackColor == disabledInactiveTrackColor && otherData.activeTickMarkColor == activeTickMarkColor && otherData.inactiveTickMarkColor == inactiveTickMarkColor && otherData.disabledActiveTickMarkColor == disabledActiveTickMarkColor && @@ -485,10 +485,10 @@ class SliderThemeData extends Diagnosticable { primaryColorLight: defaultTheme.primaryColorLight, valueIndicatorTextStyle: defaultTheme.accentTextTheme.body2, ); - properties.add(new DiagnosticsProperty('activeRailColor', activeRailColor, defaultValue: defaultData.activeRailColor)); - properties.add(new DiagnosticsProperty('inactiveRailColor', inactiveRailColor, defaultValue: defaultData.inactiveRailColor)); - properties.add(new DiagnosticsProperty('disabledActiveRailColor', disabledActiveRailColor, defaultValue: defaultData.disabledActiveRailColor, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('disabledInactiveRailColor', disabledInactiveRailColor, defaultValue: defaultData.disabledInactiveRailColor, level: DiagnosticLevel.debug)); + properties.add(new DiagnosticsProperty('activeTrackColor', activeTrackColor, defaultValue: defaultData.activeTrackColor)); + properties.add(new DiagnosticsProperty('inactiveTrackColor', inactiveTrackColor, defaultValue: defaultData.inactiveTrackColor)); + properties.add(new DiagnosticsProperty('disabledActiveTrackColor', disabledActiveTrackColor, defaultValue: defaultData.disabledActiveTrackColor, level: DiagnosticLevel.debug)); + properties.add(new DiagnosticsProperty('disabledInactiveTrackColor', disabledInactiveTrackColor, defaultValue: defaultData.disabledInactiveTrackColor, level: DiagnosticLevel.debug)); properties.add(new DiagnosticsProperty('activeTickMarkColor', activeTickMarkColor, defaultValue: defaultData.activeTickMarkColor, level: DiagnosticLevel.debug)); properties.add(new DiagnosticsProperty('inactiveTickMarkColor', inactiveTickMarkColor, defaultValue: defaultData.inactiveTickMarkColor, level: DiagnosticLevel.debug)); properties.add(new DiagnosticsProperty('disabledActiveTickMarkColor', disabledActiveTickMarkColor, defaultValue: defaultData.disabledActiveTickMarkColor, level: DiagnosticLevel.debug)); diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index d8e02bea1b..e86ec02bb4 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -555,30 +555,30 @@ void main() { final RenderBox sliderBox = tester.firstRenderObject(find.byType(Slider)); // Check default theme for enabled widget. - expect(sliderBox, paints..rect(color: sliderTheme.activeRailColor)..rect(color: sliderTheme.inactiveRailColor)); + expect(sliderBox, paints..rect(color: sliderTheme.activeTrackColor)..rect(color: sliderTheme.inactiveTrackColor)); expect(sliderBox, paints..circle(color: sliderTheme.thumbColor)); expect(sliderBox, isNot(paints..circle(color: sliderTheme.disabledThumbColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveRailColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveRailColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveTrackColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveTrackColor))); expect(sliderBox, isNot(paints..circle(color: sliderTheme.activeTickMarkColor))); expect(sliderBox, isNot(paints..circle(color: sliderTheme.inactiveTickMarkColor))); // Test setting only the activeColor. await tester.pumpWidget(buildApp(activeColor: customColor1)); - expect(sliderBox, paints..rect(color: customColor1)..rect(color: sliderTheme.inactiveRailColor)); + expect(sliderBox, paints..rect(color: customColor1)..rect(color: sliderTheme.inactiveTrackColor)); expect(sliderBox, paints..circle(color: customColor1)); expect(sliderBox, isNot(paints..circle(color: sliderTheme.thumbColor))); expect(sliderBox, isNot(paints..circle(color: sliderTheme.disabledThumbColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveRailColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveRailColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveTrackColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveTrackColor))); // Test setting only the inactiveColor. await tester.pumpWidget(buildApp(inactiveColor: customColor1)); - expect(sliderBox, paints..rect(color: sliderTheme.activeRailColor)..rect(color: customColor1)); + expect(sliderBox, paints..rect(color: sliderTheme.activeTrackColor)..rect(color: customColor1)); expect(sliderBox, paints..circle(color: sliderTheme.thumbColor)); expect(sliderBox, isNot(paints..circle(color: sliderTheme.disabledThumbColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveRailColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveRailColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveTrackColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveTrackColor))); // Test setting both activeColor and inactiveColor. await tester.pumpWidget(buildApp(activeColor: customColor1, inactiveColor: customColor2)); @@ -586,12 +586,12 @@ void main() { expect(sliderBox, paints..circle(color: customColor1)); expect(sliderBox, isNot(paints..circle(color: sliderTheme.thumbColor))); expect(sliderBox, isNot(paints..circle(color: sliderTheme.disabledThumbColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveRailColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveRailColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveTrackColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveTrackColor))); // Test colors for discrete slider. await tester.pumpWidget(buildApp(divisions: 3)); - expect(sliderBox, paints..rect(color: sliderTheme.activeRailColor)..rect(color: sliderTheme.inactiveRailColor)); + expect(sliderBox, paints..rect(color: sliderTheme.activeTrackColor)..rect(color: sliderTheme.inactiveTrackColor)); expect( sliderBox, paints @@ -601,8 +601,8 @@ void main() { ..circle(color: sliderTheme.inactiveTickMarkColor) ..circle(color: sliderTheme.thumbColor)); expect(sliderBox, isNot(paints..circle(color: sliderTheme.disabledThumbColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveRailColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveRailColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveTrackColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveTrackColor))); // Test colors for discrete slider with inactiveColor and activeColor set. await tester.pumpWidget(buildApp( @@ -621,8 +621,8 @@ void main() { ..circle(color: customColor1)); expect(sliderBox, isNot(paints..circle(color: sliderTheme.thumbColor))); expect(sliderBox, isNot(paints..circle(color: sliderTheme.disabledThumbColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveRailColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveRailColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledActiveTrackColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.disabledInactiveTrackColor))); expect(sliderBox, isNot(paints..circle(color: sliderTheme.activeTickMarkColor))); expect(sliderBox, isNot(paints..circle(color: sliderTheme.inactiveTickMarkColor))); @@ -632,24 +632,24 @@ void main() { expect( sliderBox, paints - ..rect(color: sliderTheme.disabledActiveRailColor) - ..rect(color: sliderTheme.disabledInactiveRailColor)); + ..rect(color: sliderTheme.disabledActiveTrackColor) + ..rect(color: sliderTheme.disabledInactiveTrackColor)); expect(sliderBox, paints..circle(color: sliderTheme.disabledThumbColor)); expect(sliderBox, isNot(paints..circle(color: sliderTheme.thumbColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.activeRailColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.inactiveRailColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.activeTrackColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.inactiveTrackColor))); // Test setting the activeColor and inactiveColor for disabled widget. await tester.pumpWidget(buildApp(activeColor: customColor1, inactiveColor: customColor2, enabled: false)); expect( sliderBox, paints - ..rect(color: sliderTheme.disabledActiveRailColor) - ..rect(color: sliderTheme.disabledInactiveRailColor)); + ..rect(color: sliderTheme.disabledActiveTrackColor) + ..rect(color: sliderTheme.disabledInactiveTrackColor)); expect(sliderBox, paints..circle(color: sliderTheme.disabledThumbColor)); expect(sliderBox, isNot(paints..circle(color: sliderTheme.thumbColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.activeRailColor))); - expect(sliderBox, isNot(paints..rect(color: sliderTheme.inactiveRailColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.activeTrackColor))); + expect(sliderBox, isNot(paints..rect(color: sliderTheme.inactiveTrackColor))); // Test that the default value indicator has the right colors. await tester.pumpWidget(buildApp(divisions: 3)); @@ -661,8 +661,8 @@ void main() { expect( sliderBox, paints - ..rect(color: sliderTheme.activeRailColor) - ..rect(color: sliderTheme.inactiveRailColor) + ..rect(color: sliderTheme.activeTrackColor) + ..rect(color: sliderTheme.inactiveTrackColor) ..circle(color: sliderTheme.overlayColor) ..circle(color: sliderTheme.activeTickMarkColor) ..circle(color: sliderTheme.activeTickMarkColor) diff --git a/packages/flutter/test/material/slider_theme_test.dart b/packages/flutter/test/material/slider_theme_test.dart index 66eb2e77cb..47b0c0ff1a 100644 --- a/packages/flutter/test/material/slider_theme_test.dart +++ b/packages/flutter/test/material/slider_theme_test.dart @@ -19,8 +19,8 @@ void main() { ); final SliderThemeData sliderTheme = theme.sliderTheme; - expect(sliderTheme.activeRailColor.value, equals(Colors.red.value)); - expect(sliderTheme.inactiveRailColor.value, equals(Colors.red.withAlpha(0x3d).value)); + expect(sliderTheme.activeTrackColor.value, equals(Colors.red.value)); + expect(sliderTheme.inactiveTrackColor.value, equals(Colors.red.withAlpha(0x3d).value)); }); testWidgets('Slider uses ThemeData slider theme if present', (WidgetTester tester) async { @@ -55,7 +55,7 @@ void main() { final RenderBox sliderBox = tester.firstRenderObject(find.byType(Slider)); - expect(sliderBox, paints..rect(color: sliderTheme.disabledActiveRailColor)..rect(color: sliderTheme.disabledInactiveRailColor)); + expect(sliderBox, paints..rect(color: sliderTheme.disabledActiveTrackColor)..rect(color: sliderTheme.disabledInactiveTrackColor)); }); testWidgets('Slider overrides ThemeData theme if SliderTheme present', (WidgetTester tester) async { @@ -65,8 +65,8 @@ void main() { ); final SliderThemeData sliderTheme = theme.sliderTheme; final SliderThemeData customTheme = sliderTheme.copyWith( - activeRailColor: Colors.purple, - inactiveRailColor: Colors.purple.withAlpha(0x3d), + activeTrackColor: Colors.purple, + inactiveTrackColor: Colors.purple.withAlpha(0x3d), ); Widget buildSlider(SliderThemeData data) { @@ -97,7 +97,7 @@ void main() { final RenderBox sliderBox = tester.firstRenderObject(find.byType(Slider)); - expect(sliderBox, paints..rect(color: customTheme.disabledActiveRailColor)..rect(color: customTheme.disabledInactiveRailColor)); + expect(sliderBox, paints..rect(color: customTheme.disabledActiveTrackColor)..rect(color: customTheme.disabledInactiveTrackColor)); }); testWidgets('SliderThemeData generates correct opacities for fromPrimaryColors', (WidgetTester tester) async { @@ -113,10 +113,10 @@ void main() { valueIndicatorTextStyle: new ThemeData.fallback().accentTextTheme.body2.copyWith(color: customColor4), ); - expect(sliderTheme.activeRailColor, equals(customColor1.withAlpha(0xff))); - expect(sliderTheme.inactiveRailColor, equals(customColor1.withAlpha(0x3d))); - expect(sliderTheme.disabledActiveRailColor, equals(customColor2.withAlpha(0x52))); - expect(sliderTheme.disabledInactiveRailColor, equals(customColor2.withAlpha(0x1f))); + expect(sliderTheme.activeTrackColor, equals(customColor1.withAlpha(0xff))); + expect(sliderTheme.inactiveTrackColor, equals(customColor1.withAlpha(0x3d))); + expect(sliderTheme.disabledActiveTrackColor, equals(customColor2.withAlpha(0x52))); + expect(sliderTheme.disabledInactiveTrackColor, equals(customColor2.withAlpha(0x1f))); expect(sliderTheme.activeTickMarkColor, equals(customColor3.withAlpha(0x8a))); expect(sliderTheme.inactiveTickMarkColor, equals(customColor1.withAlpha(0x8a))); expect(sliderTheme.disabledActiveTickMarkColor, equals(customColor3.withAlpha(0x1f))); @@ -146,10 +146,10 @@ void main() { ); final SliderThemeData lerp = SliderThemeData.lerp(sliderThemeBlack, sliderThemeWhite, 0.5); const Color middleGrey = const Color(0xff7f7f7f); - expect(lerp.activeRailColor, equals(middleGrey.withAlpha(0xff))); - expect(lerp.inactiveRailColor, equals(middleGrey.withAlpha(0x3d))); - expect(lerp.disabledActiveRailColor, equals(middleGrey.withAlpha(0x52))); - expect(lerp.disabledInactiveRailColor, equals(middleGrey.withAlpha(0x1f))); + expect(lerp.activeTrackColor, equals(middleGrey.withAlpha(0xff))); + expect(lerp.inactiveTrackColor, equals(middleGrey.withAlpha(0x3d))); + expect(lerp.disabledActiveTrackColor, equals(middleGrey.withAlpha(0x52))); + expect(lerp.disabledInactiveTrackColor, equals(middleGrey.withAlpha(0x1f))); expect(lerp.activeTickMarkColor, equals(middleGrey.withAlpha(0x8a))); expect(lerp.inactiveTickMarkColor, equals(middleGrey.withAlpha(0x8a))); expect(lerp.disabledActiveTickMarkColor, equals(middleGrey.withAlpha(0x1f)));