Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
5129d8ff
Unverified
Commit
5129d8ff
authored
Apr 12, 2018
by
Greg Spencer
Committed by
GitHub
Apr 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Rail to Track, per UX guideline (#16519)
parent
4dbbf678
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
150 deletions
+150
-150
slider_demo.dart
examples/flutter_gallery/lib/demo/material/slider_demo.dart
+2
-2
slider.dart
packages/flutter/lib/src/material/slider.dart
+53
-53
slider_theme.dart
packages/flutter/lib/src/material/slider_theme.dart
+55
-55
slider_test.dart
packages/flutter/test/material/slider_test.dart
+26
-26
slider_theme_test.dart
packages/flutter/test/material/slider_theme_test.dart
+14
-14
No files found.
examples/flutter_gallery/lib/demo/material/slider_demo.dart
View file @
5129d8ff
...
@@ -184,8 +184,8 @@ class _SliderDemoState extends State<SliderDemo> {
...
@@ -184,8 +184,8 @@ class _SliderDemoState extends State<SliderDemo> {
children:
<
Widget
>[
children:
<
Widget
>[
new
SliderTheme
(
new
SliderTheme
(
data:
theme
.
sliderTheme
.
copyWith
(
data:
theme
.
sliderTheme
.
copyWith
(
active
Rail
Color:
Colors
.
deepPurple
,
active
Track
Color:
Colors
.
deepPurple
,
inactive
Rail
Color:
Colors
.
black26
,
inactive
Track
Color:
Colors
.
black26
,
activeTickMarkColor:
Colors
.
white70
,
activeTickMarkColor:
Colors
.
white70
,
inactiveTickMarkColor:
Colors
.
black
,
inactiveTickMarkColor:
Colors
.
black
,
overlayColor:
Colors
.
black12
,
overlayColor:
Colors
.
black12
,
...
...
packages/flutter/lib/src/material/slider.dart
View file @
5129d8ff
...
@@ -32,7 +32,7 @@ import 'theme.dart';
...
@@ -32,7 +32,7 @@ import 'theme.dart';
///
///
/// * The "thumb", which is a shape that slides horizontally when the user
/// * The "thumb", which is a shape that slides horizontally when the user
/// drags it.
/// 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
/// * The "value indicator", which is a shape that pops up when the user
/// is dragging the thumb to indicate the value being selected.
/// is dragging the thumb to indicate the value being selected.
/// * The "active" side of the slider is the side between the thumb and the
/// * The "active" side of the slider is the side between the thumb and the
...
@@ -50,7 +50,7 @@ import 'theme.dart';
...
@@ -50,7 +50,7 @@ import 'theme.dart';
/// slider.
/// slider.
///
///
/// By default, a slider will be as wide as possible, centered vertically. When
/// 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.
/// wide (with margins on each side) and will shrink-wrap vertically.
///
///
/// Requires one of its ancestors to be a [Material] widget.
/// Requires one of its ancestors to be a [Material] widget.
...
@@ -177,23 +177,23 @@ class Slider extends StatefulWidget {
...
@@ -177,23 +177,23 @@ class Slider extends StatefulWidget {
/// shape.
/// shape.
final
String
label
;
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
/// The "active" side of the slider is the side between the thumb and the
/// minimum value.
/// minimum value.
///
///
/// Defaults to [SliderTheme.active
Rail
Color] of the current [SliderTheme].
/// Defaults to [SliderTheme.active
Track
Color] of the current [SliderTheme].
///
///
/// Using a [SliderTheme] gives much more fine-grained control over the
/// Using a [SliderTheme] gives much more fine-grained control over the
/// appearance of various components of the slider.
/// appearance of various components of the slider.
final
Color
activeColor
;
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
/// The "inactive" side of the slider is the side between the thumb and the
/// maximum value.
/// maximum value.
///
///
/// Defaults to the [SliderTheme.inactive
Rail
Color] of the current
/// Defaults to the [SliderTheme.inactive
Track
Color] of the current
/// [SliderTheme].
/// [SliderTheme].
///
///
/// Using a [SliderTheme] gives much more fine-grained control over the
/// Using a [SliderTheme] gives much more fine-grained control over the
...
@@ -297,8 +297,8 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
...
@@ -297,8 +297,8 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
// control than that, then they need to use a SliderTheme.
// control than that, then they need to use a SliderTheme.
if
(
widget
.
activeColor
!=
null
||
widget
.
inactiveColor
!=
null
)
{
if
(
widget
.
activeColor
!=
null
||
widget
.
inactiveColor
!=
null
)
{
sliderTheme
=
sliderTheme
.
copyWith
(
sliderTheme
=
sliderTheme
.
copyWith
(
active
Rail
Color:
widget
.
activeColor
,
active
Track
Color:
widget
.
activeColor
,
inactive
Rail
Color:
widget
.
inactiveColor
,
inactive
Track
Color:
widget
.
inactiveColor
,
activeTickMarkColor:
widget
.
inactiveColor
,
activeTickMarkColor:
widget
.
inactiveColor
,
inactiveTickMarkColor:
widget
.
activeColor
,
inactiveTickMarkColor:
widget
.
activeColor
,
thumbColor:
widget
.
activeColor
,
thumbColor:
widget
.
activeColor
,
...
@@ -423,9 +423,9 @@ class _RenderSlider extends RenderBox {
...
@@ -423,9 +423,9 @@ class _RenderSlider extends RenderBox {
static
const
Duration
_positionAnimationDuration
=
const
Duration
(
milliseconds:
75
);
static
const
Duration
_positionAnimationDuration
=
const
Duration
(
milliseconds:
75
);
static
const
double
_overlayRadius
=
16.0
;
static
const
double
_overlayRadius
=
16.0
;
static
const
double
_overlayDiameter
=
_overlayRadius
*
2.0
;
static
const
double
_overlayDiameter
=
_overlayRadius
*
2.0
;
static
const
double
_
rail
Height
=
2.0
;
static
const
double
_
track
Height
=
2.0
;
static
const
double
_preferred
Rail
Width
=
144.0
;
static
const
double
_preferred
Track
Width
=
144.0
;
static
const
double
_preferredTotalWidth
=
_preferred
Rail
Width
+
_overlayDiameter
;
static
const
double
_preferredTotalWidth
=
_preferred
Track
Width
+
_overlayDiameter
;
static
const
Duration
_minimumInteractionTime
=
const
Duration
(
milliseconds:
500
);
static
const
Duration
_minimumInteractionTime
=
const
Duration
(
milliseconds:
500
);
static
const
double
_adjustmentUnit
=
0.1
;
// Matches iOS implementation of material slider.
static
const
double
_adjustmentUnit
=
0.1
;
// Matches iOS implementation of material slider.
static
final
Tween
<
double
>
_overlayRadiusTween
=
new
Tween
<
double
>(
begin:
0.0
,
end:
_overlayRadius
);
static
final
Tween
<
double
>
_overlayRadiusTween
=
new
Tween
<
double
>(
begin:
0.0
,
end:
_overlayRadius
);
...
@@ -440,7 +440,7 @@ class _RenderSlider extends RenderBox {
...
@@ -440,7 +440,7 @@ class _RenderSlider extends RenderBox {
bool
_active
=
false
;
bool
_active
=
false
;
double
_currentDragValue
=
0.0
;
double
_currentDragValue
=
0.0
;
double
get
_
rail
Length
=>
size
.
width
-
_overlayDiameter
;
double
get
_
track
Length
=>
size
.
width
-
_overlayDiameter
;
bool
get
isInteractive
=>
onChanged
!=
null
;
bool
get
isInteractive
=>
onChanged
!=
null
;
...
@@ -619,7 +619,7 @@ class _RenderSlider extends RenderBox {
...
@@ -619,7 +619,7 @@ class _RenderSlider extends RenderBox {
}
}
double
_getValueFromGlobalPosition
(
Offset
globalPosition
)
{
double
_getValueFromGlobalPosition
(
Offset
globalPosition
)
{
final
double
visualPosition
=
(
globalToLocal
(
globalPosition
).
dx
-
_overlayRadius
)
/
_
rail
Length
;
final
double
visualPosition
=
(
globalToLocal
(
globalPosition
).
dx
-
_overlayRadius
)
/
_
track
Length
;
return
_getValueFromVisualPosition
(
visualPosition
);
return
_getValueFromVisualPosition
(
visualPosition
);
}
}
...
@@ -666,7 +666,7 @@ class _RenderSlider extends RenderBox {
...
@@ -666,7 +666,7 @@ class _RenderSlider extends RenderBox {
void
_handleDragUpdate
(
DragUpdateDetails
details
)
{
void
_handleDragUpdate
(
DragUpdateDetails
details
)
{
if
(
isInteractive
)
{
if
(
isInteractive
)
{
final
double
valueDelta
=
details
.
primaryDelta
/
_
rail
Length
;
final
double
valueDelta
=
details
.
primaryDelta
/
_
track
Length
;
switch
(
textDirection
)
{
switch
(
textDirection
)
{
case
TextDirection
.
rtl
:
case
TextDirection
.
rtl
:
_currentDragValue
-=
valueDelta
;
_currentDragValue
-=
valueDelta
;
...
@@ -732,24 +732,24 @@ class _RenderSlider extends RenderBox {
...
@@ -732,24 +732,24 @@ class _RenderSlider extends RenderBox {
void
_paintTickMarks
(
void
_paintTickMarks
(
Canvas
canvas
,
Canvas
canvas
,
Rect
rail
Left
,
Rect
track
Left
,
Rect
rail
Right
,
Rect
track
Right
,
Paint
leftPaint
,
Paint
leftPaint
,
Paint
rightPaint
,
Paint
rightPaint
,
)
{
)
{
if
(
isDiscrete
)
{
if
(
isDiscrete
)
{
// The ticks are tiny circles that are the same height as the
rail
.
// The ticks are tiny circles that are the same height as the
track
.
const
double
tickRadius
=
_
rail
Height
/
2.0
;
const
double
tickRadius
=
_
track
Height
/
2.0
;
final
double
railWidth
=
railRight
.
right
-
rail
Left
.
left
;
final
double
trackWidth
=
trackRight
.
right
-
track
Left
.
left
;
final
double
dx
=
(
railWidth
-
_rail
Height
)
/
divisions
;
final
double
dx
=
(
trackWidth
-
_track
Height
)
/
divisions
;
// If the ticks would be too dense, don't bother painting them.
// If the ticks would be too dense, don't bother painting them.
if
(
dx
>=
3.0
*
_
rail
Height
)
{
if
(
dx
>=
3.0
*
_
track
Height
)
{
for
(
int
i
=
0
;
i
<=
divisions
;
i
+=
1
)
{
for
(
int
i
=
0
;
i
<=
divisions
;
i
+=
1
)
{
final
double
left
=
rail
Left
.
left
+
i
*
dx
;
final
double
left
=
track
Left
.
left
+
i
*
dx
;
final
Offset
center
=
new
Offset
(
left
+
tickRadius
,
rail
Left
.
top
+
tickRadius
);
final
Offset
center
=
new
Offset
(
left
+
tickRadius
,
track
Left
.
top
+
tickRadius
);
if
(
rail
Left
.
contains
(
center
))
{
if
(
track
Left
.
contains
(
center
))
{
canvas
.
drawCircle
(
center
,
tickRadius
,
leftPaint
);
canvas
.
drawCircle
(
center
,
tickRadius
,
leftPaint
);
}
else
if
(
rail
Right
.
contains
(
center
))
{
}
else
if
(
track
Right
.
contains
(
center
))
{
canvas
.
drawCircle
(
center
,
tickRadius
,
rightPaint
);
canvas
.
drawCircle
(
center
,
tickRadius
,
rightPaint
);
}
}
}
}
...
@@ -774,71 +774,71 @@ class _RenderSlider extends RenderBox {
...
@@ -774,71 +774,71 @@ class _RenderSlider extends RenderBox {
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
final
Canvas
canvas
=
context
.
canvas
;
final
Canvas
canvas
=
context
.
canvas
;
final
double
rail
Length
=
size
.
width
-
2
*
_overlayRadius
;
final
double
track
Length
=
size
.
width
-
2
*
_overlayRadius
;
final
double
value
=
_state
.
positionController
.
value
;
final
double
value
=
_state
.
positionController
.
value
;
final
ColorTween
active
RailEnableColor
=
new
ColorTween
(
begin:
_sliderTheme
.
disabledActiveRailColor
,
end:
_sliderTheme
.
activeRail
Color
);
final
ColorTween
active
TrackEnableColor
=
new
ColorTween
(
begin:
_sliderTheme
.
disabledActiveTrackColor
,
end:
_sliderTheme
.
activeTrack
Color
);
final
ColorTween
inactive
RailEnableColor
=
new
ColorTween
(
begin:
_sliderTheme
.
disabledInactiveRailColor
,
end:
_sliderTheme
.
inactiveRail
Color
);
final
ColorTween
inactive
TrackEnableColor
=
new
ColorTween
(
begin:
_sliderTheme
.
disabledInactiveTrackColor
,
end:
_sliderTheme
.
inactiveTrack
Color
);
final
ColorTween
activeTickMarkEnableColor
=
new
ColorTween
(
begin:
_sliderTheme
.
disabledActiveTickMarkColor
,
end:
_sliderTheme
.
activeTickMarkColor
);
final
ColorTween
activeTickMarkEnableColor
=
new
ColorTween
(
begin:
_sliderTheme
.
disabledActiveTickMarkColor
,
end:
_sliderTheme
.
activeTickMarkColor
);
final
ColorTween
inactiveTickMarkEnableColor
=
new
ColorTween
(
begin:
_sliderTheme
.
disabledInactiveTickMarkColor
,
end:
_sliderTheme
.
inactiveTickMarkColor
);
final
ColorTween
inactiveTickMarkEnableColor
=
new
ColorTween
(
begin:
_sliderTheme
.
disabledInactiveTickMarkColor
,
end:
_sliderTheme
.
inactiveTickMarkColor
);
final
Paint
active
RailPaint
=
new
Paint
()..
color
=
activeRail
EnableColor
.
evaluate
(
_enableAnimation
);
final
Paint
active
TrackPaint
=
new
Paint
()..
color
=
activeTrack
EnableColor
.
evaluate
(
_enableAnimation
);
final
Paint
inactive
RailPaint
=
new
Paint
()..
color
=
inactiveRail
EnableColor
.
evaluate
(
_enableAnimation
);
final
Paint
inactive
TrackPaint
=
new
Paint
()..
color
=
inactiveTrack
EnableColor
.
evaluate
(
_enableAnimation
);
final
Paint
activeTickMarkPaint
=
new
Paint
()..
color
=
activeTickMarkEnableColor
.
evaluate
(
_enableAnimation
);
final
Paint
activeTickMarkPaint
=
new
Paint
()..
color
=
activeTickMarkEnableColor
.
evaluate
(
_enableAnimation
);
final
Paint
inactiveTickMarkPaint
=
new
Paint
()..
color
=
inactiveTickMarkEnableColor
.
evaluate
(
_enableAnimation
);
final
Paint
inactiveTickMarkPaint
=
new
Paint
()..
color
=
inactiveTickMarkEnableColor
.
evaluate
(
_enableAnimation
);
double
visualPosition
;
double
visualPosition
;
Paint
left
Rail
Paint
;
Paint
left
Track
Paint
;
Paint
right
Rail
Paint
;
Paint
right
Track
Paint
;
Paint
leftTickMarkPaint
;
Paint
leftTickMarkPaint
;
Paint
rightTickMarkPaint
;
Paint
rightTickMarkPaint
;
switch
(
textDirection
)
{
switch
(
textDirection
)
{
case
TextDirection
.
rtl
:
case
TextDirection
.
rtl
:
visualPosition
=
1.0
-
value
;
visualPosition
=
1.0
-
value
;
left
RailPaint
=
inactiveRail
Paint
;
left
TrackPaint
=
inactiveTrack
Paint
;
right
RailPaint
=
activeRail
Paint
;
right
TrackPaint
=
activeTrack
Paint
;
leftTickMarkPaint
=
inactiveTickMarkPaint
;
leftTickMarkPaint
=
inactiveTickMarkPaint
;
rightTickMarkPaint
=
activeTickMarkPaint
;
rightTickMarkPaint
=
activeTickMarkPaint
;
break
;
break
;
case
TextDirection
.
ltr
:
case
TextDirection
.
ltr
:
visualPosition
=
value
;
visualPosition
=
value
;
left
RailPaint
=
activeRail
Paint
;
left
TrackPaint
=
activeTrack
Paint
;
right
RailPaint
=
inactiveRail
Paint
;
right
TrackPaint
=
inactiveTrack
Paint
;
leftTickMarkPaint
=
activeTickMarkPaint
;
leftTickMarkPaint
=
activeTickMarkPaint
;
rightTickMarkPaint
=
inactiveTickMarkPaint
;
rightTickMarkPaint
=
inactiveTickMarkPaint
;
break
;
break
;
}
}
const
double
railRadius
=
_rail
Height
/
2.0
;
const
double
trackRadius
=
_track
Height
/
2.0
;
const
double
thumbGap
=
2.0
;
const
double
thumbGap
=
2.0
;
final
double
rail
VerticalCenter
=
offset
.
dy
+
(
size
.
height
)
/
2.0
;
final
double
track
VerticalCenter
=
offset
.
dy
+
(
size
.
height
)
/
2.0
;
final
double
rail
Left
=
offset
.
dx
+
_overlayRadius
;
final
double
track
Left
=
offset
.
dx
+
_overlayRadius
;
final
double
railTop
=
railVerticalCenter
-
rail
Radius
;
final
double
trackTop
=
trackVerticalCenter
-
track
Radius
;
final
double
railBottom
=
railVerticalCenter
+
rail
Radius
;
final
double
trackBottom
=
trackVerticalCenter
+
track
Radius
;
final
double
railRight
=
railLeft
+
rail
Length
;
final
double
trackRight
=
trackLeft
+
track
Length
;
final
double
railActive
=
railLeft
+
rail
Length
*
visualPosition
;
final
double
trackActive
=
trackLeft
+
track
Length
*
visualPosition
;
final
double
thumbRadius
=
_sliderTheme
.
thumbShape
.
getPreferredSize
(
isInteractive
,
isDiscrete
).
width
/
2.0
;
final
double
thumbRadius
=
_sliderTheme
.
thumbShape
.
getPreferredSize
(
isInteractive
,
isDiscrete
).
width
/
2.0
;
final
double
railActiveLeft
=
math
.
max
(
0.0
,
rail
Active
-
thumbRadius
-
thumbGap
*
(
1.0
-
_enableAnimation
.
value
));
final
double
trackActiveLeft
=
math
.
max
(
0.0
,
track
Active
-
thumbRadius
-
thumbGap
*
(
1.0
-
_enableAnimation
.
value
));
final
double
railActiveRight
=
math
.
min
(
railActive
+
thumbRadius
+
thumbGap
*
(
1.0
-
_enableAnimation
.
value
),
rail
Right
);
final
double
trackActiveRight
=
math
.
min
(
trackActive
+
thumbRadius
+
thumbGap
*
(
1.0
-
_enableAnimation
.
value
),
track
Right
);
final
Rect
railLeftRect
=
new
Rect
.
fromLTRB
(
railLeft
,
railTop
,
railActiveLeft
,
rail
Bottom
);
final
Rect
trackLeftRect
=
new
Rect
.
fromLTRB
(
trackLeft
,
trackTop
,
trackActiveLeft
,
track
Bottom
);
final
Rect
railRightRect
=
new
Rect
.
fromLTRB
(
railActiveRight
,
railTop
,
railRight
,
rail
Bottom
);
final
Rect
trackRightRect
=
new
Rect
.
fromLTRB
(
trackActiveRight
,
trackTop
,
trackRight
,
track
Bottom
);
final
Offset
thumbCenter
=
new
Offset
(
railActive
,
rail
VerticalCenter
);
final
Offset
thumbCenter
=
new
Offset
(
trackActive
,
track
VerticalCenter
);
// Paint the
rail
.
// Paint the
track
.
if
(
visualPosition
>
0.0
)
{
if
(
visualPosition
>
0.0
)
{
canvas
.
drawRect
(
railLeftRect
,
leftRail
Paint
);
canvas
.
drawRect
(
trackLeftRect
,
leftTrack
Paint
);
}
}
if
(
visualPosition
<
1.0
)
{
if
(
visualPosition
<
1.0
)
{
canvas
.
drawRect
(
railRightRect
,
rightRail
Paint
);
canvas
.
drawRect
(
trackRightRect
,
rightTrack
Paint
);
}
}
_paintOverlay
(
canvas
,
thumbCenter
);
_paintOverlay
(
canvas
,
thumbCenter
);
_paintTickMarks
(
_paintTickMarks
(
canvas
,
canvas
,
rail
LeftRect
,
track
LeftRect
,
rail
RightRect
,
track
RightRect
,
leftTickMarkPaint
,
leftTickMarkPaint
,
rightTickMarkPaint
,
rightTickMarkPaint
,
);
);
...
...
packages/flutter/lib/src/material/slider_theme.dart
View file @
5129d8ff
...
@@ -62,7 +62,7 @@ class SliderTheme extends InheritedWidget {
...
@@ -62,7 +62,7 @@ class SliderTheme extends InheritedWidget {
/// @override
/// @override
/// Widget build(BuildContext context) {
/// Widget build(BuildContext context) {
/// return new SliderTheme(
/// return new SliderTheme(
/// data: SliderTheme.of(context).copyWith(active
Rail
Color: const Color(0xff804040)),
/// data: SliderTheme.of(context).copyWith(active
Track
Color: const Color(0xff804040)),
/// child: new Slider(
/// child: new Slider(
/// onChanged: (double value) { setState(() { _rocketThrust = value; }); },
/// onChanged: (double value) { setState(() { _rocketThrust = value; }); },
/// value: _rocketThrust,
/// value: _rocketThrust,
...
@@ -121,7 +121,7 @@ enum ShowValueIndicator {
...
@@ -121,7 +121,7 @@ enum ShowValueIndicator {
///
///
/// * The "thumb", which is a shape that slides horizontally when the user
/// * The "thumb", which is a shape that slides horizontally when the user
/// drags it.
/// 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
/// * The "value indicator", which is a shape that pops up when the user
/// is dragging the thumb to indicate the value being selected.
/// is dragging the thumb to indicate the value being selected.
/// * The "active" side of the slider is the side between the thumb and the
/// * The "active" side of the slider is the side between the thumb and the
...
@@ -169,7 +169,7 @@ class SliderThemeData extends Diagnosticable {
...
@@ -169,7 +169,7 @@ class SliderThemeData extends Diagnosticable {
/// @override
/// @override
/// Widget build(BuildContext context) {
/// Widget build(BuildContext context) {
/// return new SliderTheme(
/// return new SliderTheme(
/// data: SliderTheme.of(context).copyWith(active
Rail
Color: const Color(0xff404080)),
/// data: SliderTheme.of(context).copyWith(active
Track
Color: const Color(0xff404080)),
/// child: new Slider(
/// child: new Slider(
/// onChanged: (double value) { setState(() { _bliss = value; }); },
/// onChanged: (double value) { setState(() { _bliss = value; }); },
/// value: _bliss,
/// value: _bliss,
...
@@ -179,10 +179,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -179,10 +179,10 @@ class SliderThemeData extends Diagnosticable {
/// }
/// }
/// ```
/// ```
const
SliderThemeData
({
const
SliderThemeData
({
@required
this
.
active
Rail
Color
,
@required
this
.
active
Track
Color
,
@required
this
.
inactive
Rail
Color
,
@required
this
.
inactive
Track
Color
,
@required
this
.
disabledActive
Rail
Color
,
@required
this
.
disabledActive
Track
Color
,
@required
this
.
disabledInactive
Rail
Color
,
@required
this
.
disabledInactive
Track
Color
,
@required
this
.
activeTickMarkColor
,
@required
this
.
activeTickMarkColor
,
@required
this
.
inactiveTickMarkColor
,
@required
this
.
inactiveTickMarkColor
,
@required
this
.
disabledActiveTickMarkColor
,
@required
this
.
disabledActiveTickMarkColor
,
...
@@ -195,10 +195,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -195,10 +195,10 @@ class SliderThemeData extends Diagnosticable {
@required
this
.
valueIndicatorShape
,
@required
this
.
valueIndicatorShape
,
@required
this
.
showValueIndicator
,
@required
this
.
showValueIndicator
,
@required
this
.
valueIndicatorTextStyle
,
@required
this
.
valueIndicatorTextStyle
,
})
:
assert
(
active
Rail
Color
!=
null
),
})
:
assert
(
active
Track
Color
!=
null
),
assert
(
inactive
Rail
Color
!=
null
),
assert
(
inactive
Track
Color
!=
null
),
assert
(
disabledActive
Rail
Color
!=
null
),
assert
(
disabledActive
Track
Color
!=
null
),
assert
(
disabledInactive
Rail
Color
!=
null
),
assert
(
disabledInactive
Track
Color
!=
null
),
assert
(
activeTickMarkColor
!=
null
),
assert
(
activeTickMarkColor
!=
null
),
assert
(
inactiveTickMarkColor
!=
null
),
assert
(
inactiveTickMarkColor
!=
null
),
assert
(
disabledActiveTickMarkColor
!=
null
),
assert
(
disabledActiveTickMarkColor
!=
null
),
...
@@ -234,10 +234,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -234,10 +234,10 @@ class SliderThemeData extends Diagnosticable {
// These are Material Design defaults, and are used to derive
// These are Material Design defaults, and are used to derive
// component Colors (with opacity) from base colors.
// component Colors (with opacity) from base colors.
const
int
active
Rail
Alpha
=
0xff
;
const
int
active
Track
Alpha
=
0xff
;
const
int
inactive
Rail
Alpha
=
0x3d
;
// 24% opacity
const
int
inactive
Track
Alpha
=
0x3d
;
// 24% opacity
const
int
disabledActive
Rail
Alpha
=
0x52
;
// 32% opacity
const
int
disabledActive
Track
Alpha
=
0x52
;
// 32% opacity
const
int
disabledInactive
Rail
Alpha
=
0x1f
;
// 12% opacity
const
int
disabledInactive
Track
Alpha
=
0x1f
;
// 12% opacity
const
int
activeTickMarkAlpha
=
0x8a
;
// 54% opacity
const
int
activeTickMarkAlpha
=
0x8a
;
// 54% opacity
const
int
inactiveTickMarkAlpha
=
0x8a
;
// 54% opacity
const
int
inactiveTickMarkAlpha
=
0x8a
;
// 54% opacity
const
int
disabledActiveTickMarkAlpha
=
0x1f
;
// 12% opacity
const
int
disabledActiveTickMarkAlpha
=
0x1f
;
// 12% opacity
...
@@ -254,10 +254,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -254,10 +254,10 @@ class SliderThemeData extends Diagnosticable {
const
int
overlayLightAlpha
=
0x29
;
// 16% opacity
const
int
overlayLightAlpha
=
0x29
;
// 16% opacity
return
new
SliderThemeData
(
return
new
SliderThemeData
(
active
RailColor:
primaryColor
.
withAlpha
(
activeRail
Alpha
),
active
TrackColor:
primaryColor
.
withAlpha
(
activeTrack
Alpha
),
inactive
RailColor:
primaryColor
.
withAlpha
(
inactiveRail
Alpha
),
inactive
TrackColor:
primaryColor
.
withAlpha
(
inactiveTrack
Alpha
),
disabledActive
RailColor:
primaryColorDark
.
withAlpha
(
disabledActiveRail
Alpha
),
disabledActive
TrackColor:
primaryColorDark
.
withAlpha
(
disabledActiveTrack
Alpha
),
disabledInactive
RailColor:
primaryColorDark
.
withAlpha
(
disabledInactiveRail
Alpha
),
disabledInactive
TrackColor:
primaryColorDark
.
withAlpha
(
disabledInactiveTrack
Alpha
),
activeTickMarkColor:
primaryColorLight
.
withAlpha
(
activeTickMarkAlpha
),
activeTickMarkColor:
primaryColorLight
.
withAlpha
(
activeTickMarkAlpha
),
inactiveTickMarkColor:
primaryColor
.
withAlpha
(
inactiveTickMarkAlpha
),
inactiveTickMarkColor:
primaryColor
.
withAlpha
(
inactiveTickMarkAlpha
),
disabledActiveTickMarkColor:
primaryColorLight
.
withAlpha
(
disabledActiveTickMarkAlpha
),
disabledActiveTickMarkColor:
primaryColorLight
.
withAlpha
(
disabledActiveTickMarkAlpha
),
...
@@ -273,35 +273,35 @@ class SliderThemeData extends Diagnosticable {
...
@@ -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.
/// current thumb position.
final
Color
active
Rail
Color
;
final
Color
active
Track
Color
;
/// 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.
/// [Slider.max] position.
final
Color
inactive
Rail
Color
;
final
Color
inactive
Track
Color
;
/// 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.
/// current thumb position when the [Slider] is disabled.
final
Color
disabledActive
Rail
Color
;
final
Color
disabledActive
Track
Color
;
/// 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.
/// [Slider.max] position when the [Slider] is disabled.
final
Color
disabledInactive
Rail
Color
;
final
Color
disabledInactive
Track
Color
;
/// 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.
/// position and the current thumb position.
final
Color
activeTickMarkColor
;
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.
/// thumb position and the [Slider.max] position.
final
Color
inactiveTickMarkColor
;
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.
/// position and the current thumb position when the [Slider] is disabled.
final
Color
disabledActiveTickMarkColor
;
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
/// thumb position and the [Slider.max] position when the [Slider] is
/// disabled.
/// disabled.
final
Color
disabledInactiveTickMarkColor
;
final
Color
disabledInactiveTickMarkColor
;
...
@@ -350,10 +350,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -350,10 +350,10 @@ class SliderThemeData extends Diagnosticable {
/// Creates a copy of this object but with the given fields replaced with the
/// Creates a copy of this object but with the given fields replaced with the
/// new values.
/// new values.
SliderThemeData
copyWith
({
SliderThemeData
copyWith
({
Color
active
Rail
Color
,
Color
active
Track
Color
,
Color
inactive
Rail
Color
,
Color
inactive
Track
Color
,
Color
disabledActive
Rail
Color
,
Color
disabledActive
Track
Color
,
Color
disabledInactive
Rail
Color
,
Color
disabledInactive
Track
Color
,
Color
activeTickMarkColor
,
Color
activeTickMarkColor
,
Color
inactiveTickMarkColor
,
Color
inactiveTickMarkColor
,
Color
disabledActiveTickMarkColor
,
Color
disabledActiveTickMarkColor
,
...
@@ -368,10 +368,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -368,10 +368,10 @@ class SliderThemeData extends Diagnosticable {
TextStyle
valueIndicatorTextStyle
,
TextStyle
valueIndicatorTextStyle
,
})
{
})
{
return
new
SliderThemeData
(
return
new
SliderThemeData
(
active
RailColor:
activeRailColor
??
this
.
activeRail
Color
,
active
TrackColor:
activeTrackColor
??
this
.
activeTrack
Color
,
inactive
RailColor:
inactiveRailColor
??
this
.
inactiveRail
Color
,
inactive
TrackColor:
inactiveTrackColor
??
this
.
inactiveTrack
Color
,
disabledActive
RailColor:
disabledActiveRailColor
??
this
.
disabledActiveRail
Color
,
disabledActive
TrackColor:
disabledActiveTrackColor
??
this
.
disabledActiveTrack
Color
,
disabledInactive
RailColor:
disabledInactiveRailColor
??
this
.
disabledInactiveRail
Color
,
disabledInactive
TrackColor:
disabledInactiveTrackColor
??
this
.
disabledInactiveTrack
Color
,
activeTickMarkColor:
activeTickMarkColor
??
this
.
activeTickMarkColor
,
activeTickMarkColor:
activeTickMarkColor
??
this
.
activeTickMarkColor
,
inactiveTickMarkColor:
inactiveTickMarkColor
??
this
.
inactiveTickMarkColor
,
inactiveTickMarkColor:
inactiveTickMarkColor
??
this
.
inactiveTickMarkColor
,
disabledActiveTickMarkColor:
disabledActiveTickMarkColor
??
this
.
disabledActiveTickMarkColor
,
disabledActiveTickMarkColor:
disabledActiveTickMarkColor
??
this
.
disabledActiveTickMarkColor
,
...
@@ -407,10 +407,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -407,10 +407,10 @@ class SliderThemeData extends Diagnosticable {
assert
(
b
!=
null
);
assert
(
b
!=
null
);
assert
(
t
!=
null
);
assert
(
t
!=
null
);
return
new
SliderThemeData
(
return
new
SliderThemeData
(
active
RailColor:
Color
.
lerp
(
a
.
activeRailColor
,
b
.
activeRail
Color
,
t
),
active
TrackColor:
Color
.
lerp
(
a
.
activeTrackColor
,
b
.
activeTrack
Color
,
t
),
inactive
RailColor:
Color
.
lerp
(
a
.
inactiveRailColor
,
b
.
inactiveRail
Color
,
t
),
inactive
TrackColor:
Color
.
lerp
(
a
.
inactiveTrackColor
,
b
.
inactiveTrack
Color
,
t
),
disabledActive
RailColor:
Color
.
lerp
(
a
.
disabledActiveRailColor
,
b
.
disabledActiveRail
Color
,
t
),
disabledActive
TrackColor:
Color
.
lerp
(
a
.
disabledActiveTrackColor
,
b
.
disabledActiveTrack
Color
,
t
),
disabledInactive
RailColor:
Color
.
lerp
(
a
.
disabledInactiveRailColor
,
b
.
disabledInactiveRail
Color
,
t
),
disabledInactive
TrackColor:
Color
.
lerp
(
a
.
disabledInactiveTrackColor
,
b
.
disabledInactiveTrack
Color
,
t
),
activeTickMarkColor:
Color
.
lerp
(
a
.
activeTickMarkColor
,
b
.
activeTickMarkColor
,
t
),
activeTickMarkColor:
Color
.
lerp
(
a
.
activeTickMarkColor
,
b
.
activeTickMarkColor
,
t
),
inactiveTickMarkColor:
Color
.
lerp
(
a
.
inactiveTickMarkColor
,
b
.
inactiveTickMarkColor
,
t
),
inactiveTickMarkColor:
Color
.
lerp
(
a
.
inactiveTickMarkColor
,
b
.
inactiveTickMarkColor
,
t
),
disabledActiveTickMarkColor:
Color
.
lerp
(
a
.
disabledActiveTickMarkColor
,
b
.
disabledActiveTickMarkColor
,
t
),
disabledActiveTickMarkColor:
Color
.
lerp
(
a
.
disabledActiveTickMarkColor
,
b
.
disabledActiveTickMarkColor
,
t
),
...
@@ -429,10 +429,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -429,10 +429,10 @@ class SliderThemeData extends Diagnosticable {
@override
@override
int
get
hashCode
{
int
get
hashCode
{
return
hashValues
(
return
hashValues
(
active
Rail
Color
,
active
Track
Color
,
inactive
Rail
Color
,
inactive
Track
Color
,
disabledActive
Rail
Color
,
disabledActive
Track
Color
,
disabledInactive
Rail
Color
,
disabledInactive
Track
Color
,
activeTickMarkColor
,
activeTickMarkColor
,
inactiveTickMarkColor
,
inactiveTickMarkColor
,
disabledActiveTickMarkColor
,
disabledActiveTickMarkColor
,
...
@@ -457,10 +457,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -457,10 +457,10 @@ class SliderThemeData extends Diagnosticable {
return
false
;
return
false
;
}
}
final
SliderThemeData
otherData
=
other
;
final
SliderThemeData
otherData
=
other
;
return
otherData
.
active
RailColor
==
activeRail
Color
&&
return
otherData
.
active
TrackColor
==
activeTrack
Color
&&
otherData
.
inactive
RailColor
==
inactiveRail
Color
&&
otherData
.
inactive
TrackColor
==
inactiveTrack
Color
&&
otherData
.
disabledActive
RailColor
==
disabledActiveRail
Color
&&
otherData
.
disabledActive
TrackColor
==
disabledActiveTrack
Color
&&
otherData
.
disabledInactive
RailColor
==
disabledInactiveRail
Color
&&
otherData
.
disabledInactive
TrackColor
==
disabledInactiveTrack
Color
&&
otherData
.
activeTickMarkColor
==
activeTickMarkColor
&&
otherData
.
activeTickMarkColor
==
activeTickMarkColor
&&
otherData
.
inactiveTickMarkColor
==
inactiveTickMarkColor
&&
otherData
.
inactiveTickMarkColor
==
inactiveTickMarkColor
&&
otherData
.
disabledActiveTickMarkColor
==
disabledActiveTickMarkColor
&&
otherData
.
disabledActiveTickMarkColor
==
disabledActiveTickMarkColor
&&
...
@@ -485,10 +485,10 @@ class SliderThemeData extends Diagnosticable {
...
@@ -485,10 +485,10 @@ class SliderThemeData extends Diagnosticable {
primaryColorLight:
defaultTheme
.
primaryColorLight
,
primaryColorLight:
defaultTheme
.
primaryColorLight
,
valueIndicatorTextStyle:
defaultTheme
.
accentTextTheme
.
body2
,
valueIndicatorTextStyle:
defaultTheme
.
accentTextTheme
.
body2
,
);
);
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'active
RailColor'
,
activeRailColor
,
defaultValue:
defaultData
.
activeRail
Color
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'active
TrackColor'
,
activeTrackColor
,
defaultValue:
defaultData
.
activeTrack
Color
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'inactive
RailColor'
,
inactiveRailColor
,
defaultValue:
defaultData
.
inactiveRail
Color
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'inactive
TrackColor'
,
inactiveTrackColor
,
defaultValue:
defaultData
.
inactiveTrack
Color
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'disabledActive
RailColor'
,
disabledActiveRailColor
,
defaultValue:
defaultData
.
disabledActiveRail
Color
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'disabledActive
TrackColor'
,
disabledActiveTrackColor
,
defaultValue:
defaultData
.
disabledActiveTrack
Color
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'disabledInactive
RailColor'
,
disabledInactiveRailColor
,
defaultValue:
defaultData
.
disabledInactiveRail
Color
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'disabledInactive
TrackColor'
,
disabledInactiveTrackColor
,
defaultValue:
defaultData
.
disabledInactiveTrack
Color
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'activeTickMarkColor'
,
activeTickMarkColor
,
defaultValue:
defaultData
.
activeTickMarkColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'activeTickMarkColor'
,
activeTickMarkColor
,
defaultValue:
defaultData
.
activeTickMarkColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'inactiveTickMarkColor'
,
inactiveTickMarkColor
,
defaultValue:
defaultData
.
inactiveTickMarkColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'inactiveTickMarkColor'
,
inactiveTickMarkColor
,
defaultValue:
defaultData
.
inactiveTickMarkColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'disabledActiveTickMarkColor'
,
disabledActiveTickMarkColor
,
defaultValue:
defaultData
.
disabledActiveTickMarkColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
new
DiagnosticsProperty
<
Color
>(
'disabledActiveTickMarkColor'
,
disabledActiveTickMarkColor
,
defaultValue:
defaultData
.
disabledActiveTickMarkColor
,
level:
DiagnosticLevel
.
debug
));
...
...
packages/flutter/test/material/slider_test.dart
View file @
5129d8ff
...
@@ -555,30 +555,30 @@ void main() {
...
@@ -555,30 +555,30 @@ void main() {
final
RenderBox
sliderBox
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
Slider
));
final
RenderBox
sliderBox
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
Slider
));
// Check default theme for enabled widget.
// Check default theme for enabled widget.
expect
(
sliderBox
,
paints
..
rect
(
color:
sliderTheme
.
active
RailColor
)..
rect
(
color:
sliderTheme
.
inactiveRail
Color
));
expect
(
sliderBox
,
paints
..
rect
(
color:
sliderTheme
.
active
TrackColor
)..
rect
(
color:
sliderTheme
.
inactiveTrack
Color
));
expect
(
sliderBox
,
paints
..
circle
(
color:
sliderTheme
.
thumbColor
));
expect
(
sliderBox
,
paints
..
circle
(
color:
sliderTheme
.
thumbColor
));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
activeTickMarkColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
activeTickMarkColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
inactiveTickMarkColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
inactiveTickMarkColor
)));
// Test setting only the activeColor.
// Test setting only the activeColor.
await
tester
.
pumpWidget
(
buildApp
(
activeColor:
customColor1
));
await
tester
.
pumpWidget
(
buildApp
(
activeColor:
customColor1
));
expect
(
sliderBox
,
paints
..
rect
(
color:
customColor1
)..
rect
(
color:
sliderTheme
.
inactive
Rail
Color
));
expect
(
sliderBox
,
paints
..
rect
(
color:
customColor1
)..
rect
(
color:
sliderTheme
.
inactive
Track
Color
));
expect
(
sliderBox
,
paints
..
circle
(
color:
customColor1
));
expect
(
sliderBox
,
paints
..
circle
(
color:
customColor1
));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Track
Color
)));
// Test setting only the inactiveColor.
// Test setting only the inactiveColor.
await
tester
.
pumpWidget
(
buildApp
(
inactiveColor:
customColor1
));
await
tester
.
pumpWidget
(
buildApp
(
inactiveColor:
customColor1
));
expect
(
sliderBox
,
paints
..
rect
(
color:
sliderTheme
.
active
Rail
Color
)..
rect
(
color:
customColor1
));
expect
(
sliderBox
,
paints
..
rect
(
color:
sliderTheme
.
active
Track
Color
)..
rect
(
color:
customColor1
));
expect
(
sliderBox
,
paints
..
circle
(
color:
sliderTheme
.
thumbColor
));
expect
(
sliderBox
,
paints
..
circle
(
color:
sliderTheme
.
thumbColor
));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Track
Color
)));
// Test setting both activeColor and inactiveColor.
// Test setting both activeColor and inactiveColor.
await
tester
.
pumpWidget
(
buildApp
(
activeColor:
customColor1
,
inactiveColor:
customColor2
));
await
tester
.
pumpWidget
(
buildApp
(
activeColor:
customColor1
,
inactiveColor:
customColor2
));
...
@@ -586,12 +586,12 @@ void main() {
...
@@ -586,12 +586,12 @@ void main() {
expect
(
sliderBox
,
paints
..
circle
(
color:
customColor1
));
expect
(
sliderBox
,
paints
..
circle
(
color:
customColor1
));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Track
Color
)));
// Test colors for discrete slider.
// Test colors for discrete slider.
await
tester
.
pumpWidget
(
buildApp
(
divisions:
3
));
await
tester
.
pumpWidget
(
buildApp
(
divisions:
3
));
expect
(
sliderBox
,
paints
..
rect
(
color:
sliderTheme
.
active
RailColor
)..
rect
(
color:
sliderTheme
.
inactiveRail
Color
));
expect
(
sliderBox
,
paints
..
rect
(
color:
sliderTheme
.
active
TrackColor
)..
rect
(
color:
sliderTheme
.
inactiveTrack
Color
));
expect
(
expect
(
sliderBox
,
sliderBox
,
paints
paints
...
@@ -601,8 +601,8 @@ void main() {
...
@@ -601,8 +601,8 @@ void main() {
..
circle
(
color:
sliderTheme
.
inactiveTickMarkColor
)
..
circle
(
color:
sliderTheme
.
inactiveTickMarkColor
)
..
circle
(
color:
sliderTheme
.
thumbColor
));
..
circle
(
color:
sliderTheme
.
thumbColor
));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Track
Color
)));
// Test colors for discrete slider with inactiveColor and activeColor set.
// Test colors for discrete slider with inactiveColor and activeColor set.
await
tester
.
pumpWidget
(
buildApp
(
await
tester
.
pumpWidget
(
buildApp
(
...
@@ -621,8 +621,8 @@ void main() {
...
@@ -621,8 +621,8 @@ void main() {
..
circle
(
color:
customColor1
));
..
circle
(
color:
customColor1
));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
disabledInactive
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
activeTickMarkColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
activeTickMarkColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
inactiveTickMarkColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
inactiveTickMarkColor
)));
...
@@ -632,24 +632,24 @@ void main() {
...
@@ -632,24 +632,24 @@ void main() {
expect
(
expect
(
sliderBox
,
sliderBox
,
paints
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Rail
Color
)
..
rect
(
color:
sliderTheme
.
disabledActive
Track
Color
)
..
rect
(
color:
sliderTheme
.
disabledInactive
Rail
Color
));
..
rect
(
color:
sliderTheme
.
disabledInactive
Track
Color
));
expect
(
sliderBox
,
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
));
expect
(
sliderBox
,
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
active
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
active
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
inactive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
inactive
Track
Color
)));
// Test setting the activeColor and inactiveColor for disabled widget.
// Test setting the activeColor and inactiveColor for disabled widget.
await
tester
.
pumpWidget
(
buildApp
(
activeColor:
customColor1
,
inactiveColor:
customColor2
,
enabled:
false
));
await
tester
.
pumpWidget
(
buildApp
(
activeColor:
customColor1
,
inactiveColor:
customColor2
,
enabled:
false
));
expect
(
expect
(
sliderBox
,
sliderBox
,
paints
paints
..
rect
(
color:
sliderTheme
.
disabledActive
Rail
Color
)
..
rect
(
color:
sliderTheme
.
disabledActive
Track
Color
)
..
rect
(
color:
sliderTheme
.
disabledInactive
Rail
Color
));
..
rect
(
color:
sliderTheme
.
disabledInactive
Track
Color
));
expect
(
sliderBox
,
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
));
expect
(
sliderBox
,
paints
..
circle
(
color:
sliderTheme
.
disabledThumbColor
));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
sliderTheme
.
thumbColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
active
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
active
Track
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
inactive
Rail
Color
)));
expect
(
sliderBox
,
isNot
(
paints
..
rect
(
color:
sliderTheme
.
inactive
Track
Color
)));
// Test that the default value indicator has the right colors.
// Test that the default value indicator has the right colors.
await
tester
.
pumpWidget
(
buildApp
(
divisions:
3
));
await
tester
.
pumpWidget
(
buildApp
(
divisions:
3
));
...
@@ -661,8 +661,8 @@ void main() {
...
@@ -661,8 +661,8 @@ void main() {
expect
(
expect
(
sliderBox
,
sliderBox
,
paints
paints
..
rect
(
color:
sliderTheme
.
active
Rail
Color
)
..
rect
(
color:
sliderTheme
.
active
Track
Color
)
..
rect
(
color:
sliderTheme
.
inactive
Rail
Color
)
..
rect
(
color:
sliderTheme
.
inactive
Track
Color
)
..
circle
(
color:
sliderTheme
.
overlayColor
)
..
circle
(
color:
sliderTheme
.
overlayColor
)
..
circle
(
color:
sliderTheme
.
activeTickMarkColor
)
..
circle
(
color:
sliderTheme
.
activeTickMarkColor
)
..
circle
(
color:
sliderTheme
.
activeTickMarkColor
)
..
circle
(
color:
sliderTheme
.
activeTickMarkColor
)
...
...
packages/flutter/test/material/slider_theme_test.dart
View file @
5129d8ff
...
@@ -19,8 +19,8 @@ void main() {
...
@@ -19,8 +19,8 @@ void main() {
);
);
final
SliderThemeData
sliderTheme
=
theme
.
sliderTheme
;
final
SliderThemeData
sliderTheme
=
theme
.
sliderTheme
;
expect
(
sliderTheme
.
active
Rail
Color
.
value
,
equals
(
Colors
.
red
.
value
));
expect
(
sliderTheme
.
active
Track
Color
.
value
,
equals
(
Colors
.
red
.
value
));
expect
(
sliderTheme
.
inactive
Rail
Color
.
value
,
equals
(
Colors
.
red
.
withAlpha
(
0x3d
).
value
));
expect
(
sliderTheme
.
inactive
Track
Color
.
value
,
equals
(
Colors
.
red
.
withAlpha
(
0x3d
).
value
));
});
});
testWidgets
(
'Slider uses ThemeData slider theme if present'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Slider uses ThemeData slider theme if present'
,
(
WidgetTester
tester
)
async
{
...
@@ -55,7 +55,7 @@ void main() {
...
@@ -55,7 +55,7 @@ void main() {
final
RenderBox
sliderBox
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
Slider
));
final
RenderBox
sliderBox
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
Slider
));
expect
(
sliderBox
,
paints
..
rect
(
color:
sliderTheme
.
disabledActive
RailColor
)..
rect
(
color:
sliderTheme
.
disabledInactiveRail
Color
));
expect
(
sliderBox
,
paints
..
rect
(
color:
sliderTheme
.
disabledActive
TrackColor
)..
rect
(
color:
sliderTheme
.
disabledInactiveTrack
Color
));
});
});
testWidgets
(
'Slider overrides ThemeData theme if SliderTheme present'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Slider overrides ThemeData theme if SliderTheme present'
,
(
WidgetTester
tester
)
async
{
...
@@ -65,8 +65,8 @@ void main() {
...
@@ -65,8 +65,8 @@ void main() {
);
);
final
SliderThemeData
sliderTheme
=
theme
.
sliderTheme
;
final
SliderThemeData
sliderTheme
=
theme
.
sliderTheme
;
final
SliderThemeData
customTheme
=
sliderTheme
.
copyWith
(
final
SliderThemeData
customTheme
=
sliderTheme
.
copyWith
(
active
Rail
Color:
Colors
.
purple
,
active
Track
Color:
Colors
.
purple
,
inactive
Rail
Color:
Colors
.
purple
.
withAlpha
(
0x3d
),
inactive
Track
Color:
Colors
.
purple
.
withAlpha
(
0x3d
),
);
);
Widget
buildSlider
(
SliderThemeData
data
)
{
Widget
buildSlider
(
SliderThemeData
data
)
{
...
@@ -97,7 +97,7 @@ void main() {
...
@@ -97,7 +97,7 @@ void main() {
final
RenderBox
sliderBox
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
Slider
));
final
RenderBox
sliderBox
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
Slider
));
expect
(
sliderBox
,
paints
..
rect
(
color:
customTheme
.
disabledActive
RailColor
)..
rect
(
color:
customTheme
.
disabledInactiveRail
Color
));
expect
(
sliderBox
,
paints
..
rect
(
color:
customTheme
.
disabledActive
TrackColor
)..
rect
(
color:
customTheme
.
disabledInactiveTrack
Color
));
});
});
testWidgets
(
'SliderThemeData generates correct opacities for fromPrimaryColors'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'SliderThemeData generates correct opacities for fromPrimaryColors'
,
(
WidgetTester
tester
)
async
{
...
@@ -113,10 +113,10 @@ void main() {
...
@@ -113,10 +113,10 @@ void main() {
valueIndicatorTextStyle:
new
ThemeData
.
fallback
().
accentTextTheme
.
body2
.
copyWith
(
color:
customColor4
),
valueIndicatorTextStyle:
new
ThemeData
.
fallback
().
accentTextTheme
.
body2
.
copyWith
(
color:
customColor4
),
);
);
expect
(
sliderTheme
.
active
Rail
Color
,
equals
(
customColor1
.
withAlpha
(
0xff
)));
expect
(
sliderTheme
.
active
Track
Color
,
equals
(
customColor1
.
withAlpha
(
0xff
)));
expect
(
sliderTheme
.
inactive
Rail
Color
,
equals
(
customColor1
.
withAlpha
(
0x3d
)));
expect
(
sliderTheme
.
inactive
Track
Color
,
equals
(
customColor1
.
withAlpha
(
0x3d
)));
expect
(
sliderTheme
.
disabledActive
Rail
Color
,
equals
(
customColor2
.
withAlpha
(
0x52
)));
expect
(
sliderTheme
.
disabledActive
Track
Color
,
equals
(
customColor2
.
withAlpha
(
0x52
)));
expect
(
sliderTheme
.
disabledInactive
Rail
Color
,
equals
(
customColor2
.
withAlpha
(
0x1f
)));
expect
(
sliderTheme
.
disabledInactive
Track
Color
,
equals
(
customColor2
.
withAlpha
(
0x1f
)));
expect
(
sliderTheme
.
activeTickMarkColor
,
equals
(
customColor3
.
withAlpha
(
0x8a
)));
expect
(
sliderTheme
.
activeTickMarkColor
,
equals
(
customColor3
.
withAlpha
(
0x8a
)));
expect
(
sliderTheme
.
inactiveTickMarkColor
,
equals
(
customColor1
.
withAlpha
(
0x8a
)));
expect
(
sliderTheme
.
inactiveTickMarkColor
,
equals
(
customColor1
.
withAlpha
(
0x8a
)));
expect
(
sliderTheme
.
disabledActiveTickMarkColor
,
equals
(
customColor3
.
withAlpha
(
0x1f
)));
expect
(
sliderTheme
.
disabledActiveTickMarkColor
,
equals
(
customColor3
.
withAlpha
(
0x1f
)));
...
@@ -146,10 +146,10 @@ void main() {
...
@@ -146,10 +146,10 @@ void main() {
);
);
final
SliderThemeData
lerp
=
SliderThemeData
.
lerp
(
sliderThemeBlack
,
sliderThemeWhite
,
0.5
);
final
SliderThemeData
lerp
=
SliderThemeData
.
lerp
(
sliderThemeBlack
,
sliderThemeWhite
,
0.5
);
const
Color
middleGrey
=
const
Color
(
0xff7f7f7f
);
const
Color
middleGrey
=
const
Color
(
0xff7f7f7f
);
expect
(
lerp
.
active
Rail
Color
,
equals
(
middleGrey
.
withAlpha
(
0xff
)));
expect
(
lerp
.
active
Track
Color
,
equals
(
middleGrey
.
withAlpha
(
0xff
)));
expect
(
lerp
.
inactive
Rail
Color
,
equals
(
middleGrey
.
withAlpha
(
0x3d
)));
expect
(
lerp
.
inactive
Track
Color
,
equals
(
middleGrey
.
withAlpha
(
0x3d
)));
expect
(
lerp
.
disabledActive
Rail
Color
,
equals
(
middleGrey
.
withAlpha
(
0x52
)));
expect
(
lerp
.
disabledActive
Track
Color
,
equals
(
middleGrey
.
withAlpha
(
0x52
)));
expect
(
lerp
.
disabledInactive
Rail
Color
,
equals
(
middleGrey
.
withAlpha
(
0x1f
)));
expect
(
lerp
.
disabledInactive
Track
Color
,
equals
(
middleGrey
.
withAlpha
(
0x1f
)));
expect
(
lerp
.
activeTickMarkColor
,
equals
(
middleGrey
.
withAlpha
(
0x8a
)));
expect
(
lerp
.
activeTickMarkColor
,
equals
(
middleGrey
.
withAlpha
(
0x8a
)));
expect
(
lerp
.
inactiveTickMarkColor
,
equals
(
middleGrey
.
withAlpha
(
0x8a
)));
expect
(
lerp
.
inactiveTickMarkColor
,
equals
(
middleGrey
.
withAlpha
(
0x8a
)));
expect
(
lerp
.
disabledActiveTickMarkColor
,
equals
(
middleGrey
.
withAlpha
(
0x1f
)));
expect
(
lerp
.
disabledActiveTickMarkColor
,
equals
(
middleGrey
.
withAlpha
(
0x1f
)));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment