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
9265bdd1
Unverified
Commit
9265bdd1
authored
Jul 07, 2020
by
Jose Alba
Committed by
GitHub
Jul 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RangeSlider overlap properly (#60549)
parent
5fa937ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
25 deletions
+86
-25
slider_theme.dart
packages/flutter/lib/src/material/slider_theme.dart
+6
-25
range_slider_test.dart
packages/flutter/test/material/range_slider_test.dart
+80
-0
No files found.
packages/flutter/lib/src/material/slider_theme.dart
View file @
9265bdd1
...
...
@@ -328,8 +328,7 @@ enum Thumb {
/// {@macro flutter.material.slider.seeAlso.rangeSliderTickMarkShape}
@immutable
class
SliderThemeData
with
Diagnosticable
{
/// Create a [SliderThemeData] given a set of exact values. All the values
/// must be specified.
/// Create a [SliderThemeData] given a set of exact values.
///
/// This will rarely be used directly. It is used by [lerp] to
/// create intermediate themes based on two themes.
...
...
@@ -2513,29 +2512,11 @@ class RoundRangeSliderThumbShape extends RangeSliderThumbShape {
// Add a stroke of 1dp around the circle if this thumb would overlap
// the other thumb.
if
(
isOnTop
==
true
)
{
bool
showValueIndicator
;
switch
(
sliderTheme
.
showValueIndicator
)
{
case
ShowValueIndicator
.
onlyForDiscrete
:
showValueIndicator
=
isDiscrete
;
break
;
case
ShowValueIndicator
.
onlyForContinuous
:
showValueIndicator
=
!
isDiscrete
;
break
;
case
ShowValueIndicator
.
always
:
showValueIndicator
=
true
;
break
;
case
ShowValueIndicator
.
never
:
showValueIndicator
=
false
;
break
;
}
if
(!
showValueIndicator
||
activationAnimation
.
value
==
0
)
{
final
Paint
strokePaint
=
Paint
()
..
color
=
sliderTheme
.
overlappingShapeStrokeColor
..
strokeWidth
=
1.0
..
style
=
PaintingStyle
.
stroke
;
canvas
.
drawCircle
(
center
,
radius
,
strokePaint
);
}
final
Paint
strokePaint
=
Paint
()
..
color
=
sliderTheme
.
overlappingShapeStrokeColor
..
strokeWidth
=
1.0
..
style
=
PaintingStyle
.
stroke
;
canvas
.
drawCircle
(
center
,
radius
,
strokePaint
);
}
final
Color
color
=
colorTween
.
evaluate
(
enableAnimation
);
...
...
packages/flutter/test/material/range_slider_test.dart
View file @
9265bdd1
...
...
@@ -1662,6 +1662,86 @@ void main() {
await
gesture
.
up
();
});
testWidgets
(
'Range Slider thumb gets stroked when overlapping'
,
(
WidgetTester
tester
)
async
{
RangeValues
values
=
const
RangeValues
(
0.3
,
0.7
);
final
ThemeData
theme
=
ThemeData
(
platform:
TargetPlatform
.
android
,
primarySwatch:
Colors
.
blue
,
sliderTheme:
const
SliderThemeData
(
valueIndicatorColor:
Color
(
0xff000001
),
showValueIndicator:
ShowValueIndicator
.
onlyForContinuous
,
),
);
final
SliderThemeData
sliderTheme
=
theme
.
sliderTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
Material
(
child:
Center
(
child:
Theme
(
data:
theme
,
child:
RangeSlider
(
values:
values
,
labels:
RangeLabels
(
values
.
start
.
toStringAsFixed
(
2
),
values
.
end
.
toStringAsFixed
(
2
)),
onChanged:
(
RangeValues
newValues
)
{
setState
(()
{
values
=
newValues
;
});
},
),
),
),
);
},
),
),
),
);
// Get the bounds of the track by finding the slider edges and translating
// inwards by the overlay radius.
final
Offset
topLeft
=
tester
.
getTopLeft
(
find
.
byType
(
RangeSlider
)).
translate
(
24
,
0
);
final
Offset
bottomRight
=
tester
.
getBottomRight
(
find
.
byType
(
RangeSlider
)).
translate
(-
24
,
0
);
final
Offset
middle
=
topLeft
+
bottomRight
/
2
;
// Drag the thumbs towards the center.
final
Offset
leftTarget
=
topLeft
+
(
bottomRight
-
topLeft
)
*
0.3
;
await
tester
.
dragFrom
(
leftTarget
,
middle
-
leftTarget
);
await
tester
.
pumpAndSettle
();
final
Offset
rightTarget
=
topLeft
+
(
bottomRight
-
topLeft
)
*
0.7
;
await
tester
.
dragFrom
(
rightTarget
,
middle
-
rightTarget
);
await
tester
.
pumpAndSettle
();
expect
(
values
.
start
,
closeTo
(
0.5
,
0.03
));
expect
(
values
.
end
,
closeTo
(
0.5
,
0.03
));
final
TestGesture
gesture
=
await
tester
.
startGesture
(
middle
);
await
tester
.
pumpAndSettle
();
/// The first circle is the thumb, the second one is the overlapping shape
/// circle, and the last one is the second thumb.
expect
(
find
.
byType
(
RangeSlider
),
paints
..
circle
()
..
circle
(
color:
sliderTheme
.
overlappingShapeStrokeColor
)
..
circle
()
);
await
gesture
.
up
();
expect
(
find
.
byType
(
RangeSlider
),
paints
..
circle
()
..
circle
(
color:
sliderTheme
.
overlappingShapeStrokeColor
)
..
circle
()
);
});
testWidgets
(
'Range Slider implements debugFillProperties'
,
(
WidgetTester
tester
)
async
{
final
DiagnosticPropertiesBuilder
builder
=
DiagnosticPropertiesBuilder
();
...
...
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