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
d4b0c66b
Commit
d4b0c66b
authored
Mar 30, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish Slider implementation
Based on feedback from the material design team. Fixes #1613
parent
4fae8dfb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
slider.dart
packages/flutter/lib/src/material/slider.dart
+19
-13
No files found.
packages/flutter/lib/src/material/slider.dart
View file @
d4b0c66b
...
...
@@ -73,11 +73,15 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
}
const
double
_kThumbRadius
=
6.0
;
const
double
_kThumbRadiusDisabled
=
3.0
;
const
double
_kActiveThumbRadius
=
9.0
;
const
double
_kDisabledThumbRadius
=
4.0
;
const
double
_kReactionRadius
=
16.0
;
const
double
_kTrackWidth
=
144.0
;
final
Color
_kInactiveTrackColor
=
Colors
.
grey
[
400
];
final
Color
_kActiveTrackColor
=
Colors
.
grey
[
500
];
final
Tween
<
double
>
_kReactionRadiusTween
=
new
Tween
<
double
>(
begin:
_kThumbRadius
,
end:
_kReactionRadius
);
final
Tween
<
double
>
_kThumbRadiusTween
=
new
Tween
<
double
>(
begin:
_kThumbRadius
,
end:
_kActiveThumbRadius
);
final
ColorTween
_kTrackColorTween
=
new
ColorTween
(
begin:
_kInactiveTrackColor
,
end:
_kActiveTrackColor
);
class
_RenderSlider
extends
RenderConstrainedBox
{
_RenderSlider
({
...
...
@@ -93,13 +97,10 @@ class _RenderSlider extends RenderConstrainedBox {
..
onUpdate
=
_handleDragUpdate
..
onEnd
=
_handleDragEnd
;
_reactionController
=
new
AnimationController
(
duration:
kRadialReactionDuration
);
_reaction
=
new
Tween
<
double
>(
begin:
_kThumbRadius
,
end:
_kReactionRadius
).
animate
(
new
CurvedAnimation
(
_reaction
=
new
CurvedAnimation
(
parent:
_reactionController
,
curve:
Curves
.
ease
)
)
..
addListener
(
markNeedsPaint
);
)..
addListener
(
markNeedsPaint
);
}
double
get
value
=>
_value
;
...
...
@@ -182,18 +183,23 @@ class _RenderSlider extends RenderConstrainedBox {
double
trackActive
=
trackLeft
+
trackLength
*
value
;
Paint
primaryPaint
=
new
Paint
()..
color
=
enabled
?
_activeColor
:
_kInactiveTrackColor
;
Paint
trackPaint
=
new
Paint
()..
color
=
_
active
?
_kActiveTrackColor
:
_kInactiveTrackColor
;
Paint
trackPaint
=
new
Paint
()..
color
=
_
kTrackColorTween
.
evaluate
(
_reaction
)
;
double
thumbRadius
=
enabled
?
_kThumbRadius
:
_kThumbRadiusDisabled
;
double
thumbRadius
=
enabled
?
_kThumbRadiusTween
.
evaluate
(
_reaction
)
:
_kDisabledThumbRadius
;
Point
activeLocation
=
new
Point
(
trackActive
,
trackCenter
);
canvas
.
drawRect
(
new
Rect
.
fromLTRB
(
trackLeft
,
trackTop
,
trackRight
,
trackBottom
),
trackPaint
);
if
(
_value
>
0.0
)
canvas
.
drawRect
(
new
Rect
.
fromLTRB
(
trackLeft
,
trackTop
,
trackActive
,
trackBottom
),
primaryPaint
);
if
(
enabled
)
{
canvas
.
drawRect
(
new
Rect
.
fromLTRB
(
trackLeft
,
trackTop
,
trackRight
,
trackBottom
),
trackPaint
);
if
(
_value
>
0.0
)
canvas
.
drawRect
(
new
Rect
.
fromLTRB
(
trackLeft
,
trackTop
,
trackActive
,
trackBottom
),
primaryPaint
);
}
else
{
canvas
.
drawRect
(
new
Rect
.
fromLTRB
(
trackLeft
,
trackTop
,
activeLocation
.
x
-
_kDisabledThumbRadius
-
2
,
trackBottom
),
trackPaint
);
canvas
.
drawRect
(
new
Rect
.
fromLTRB
(
activeLocation
.
x
+
_kDisabledThumbRadius
+
2
,
trackTop
,
trackRight
,
trackBottom
),
trackPaint
);
}
Point
activeLocation
=
new
Point
(
trackActive
,
trackCenter
);
if
(
_reaction
.
status
!=
AnimationStatus
.
dismissed
)
{
Paint
reactionPaint
=
new
Paint
()..
color
=
_activeColor
.
withAlpha
(
kRadialReactionAlpha
);
canvas
.
drawCircle
(
activeLocation
,
_
reaction
.
value
,
reactionPaint
);
canvas
.
drawCircle
(
activeLocation
,
_
kReactionRadiusTween
.
evaluate
(
_reaction
)
,
reactionPaint
);
}
canvas
.
drawCircle
(
activeLocation
,
thumbRadius
,
primaryPaint
);
}
...
...
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