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
7b518d95
Commit
7b518d95
authored
Dec 04, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #737 from Hixie/yak2-slider
Slider Improvements
parents
87667cb7
6c3459e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
13 deletions
+34
-13
slider_demo.dart
examples/material_gallery/lib/demo/slider_demo.dart
+12
-8
slider.dart
packages/flutter/lib/src/material/slider.dart
+22
-5
No files found.
examples/material_gallery/lib/demo/slider_demo.dart
View file @
7b518d95
...
...
@@ -11,13 +11,9 @@ class SliderDemo extends StatefulComponent {
}
class
_SliderDemoState
extends
State
<
SliderDemo
>
{
double
_value
=
0.25
;
double
_value
=
25.0
;
Widget
build
(
BuildContext
context
)
{
Widget
label
=
new
Container
(
padding:
const
EdgeDims
.
symmetric
(
horizontal:
16.0
),
child:
new
Text
(
_value
.
toStringAsFixed
(
2
))
);
return
new
Block
([
new
Container
(
height:
100.0
,
...
...
@@ -25,13 +21,18 @@ class _SliderDemoState extends State<SliderDemo> {
child:
new
Row
([
new
Slider
(
value:
_value
,
min:
0.0
,
max:
100.0
,
onChanged:
(
double
value
)
{
setState
(()
{
_value
=
value
;
});
}
),
label
,
new
Container
(
padding:
const
EdgeDims
.
symmetric
(
horizontal:
16.0
),
child:
new
Text
(
_value
.
round
().
toString
().
padLeft
(
3
,
'0'
))
),
],
justifyContent:
FlexJustifyContent
.
collapse
)
)
),
...
...
@@ -40,8 +41,11 @@ class _SliderDemoState extends State<SliderDemo> {
child:
new
Center
(
child:
new
Row
([
// Disabled, but tracking the slider above.
new
Slider
(
value:
_value
),
label
,
new
Slider
(
value:
_value
/
100.0
),
new
Container
(
padding:
const
EdgeDims
.
symmetric
(
horizontal:
16.0
),
child:
new
Text
((
_value
/
100.0
).
toStringAsFixed
(
2
))
),
],
justifyContent:
FlexJustifyContent
.
collapse
)
)
)
...
...
packages/flutter/lib/src/material/slider.dart
View file @
7b518d95
...
...
@@ -13,17 +13,34 @@ import 'constants.dart';
import
'theme.dart'
;
class
Slider
extends
StatelessComponent
{
Slider
({
Key
key
,
this
.
value
,
this
.
onChanged
})
:
super
(
key:
key
);
Slider
({
Key
key
,
this
.
value
,
this
.
min
:
0.0
,
this
.
max
:
1.0
,
this
.
onChanged
})
:
super
(
key:
key
)
{
assert
(
value
!=
null
);
assert
(
min
!=
null
);
assert
(
max
!=
null
);
assert
(
value
>=
min
&&
value
<=
max
);
}
final
double
value
;
final
double
min
;
final
double
max
;
final
ValueChanged
<
double
>
onChanged
;
void
_handleChanged
(
double
value
)
{
assert
(
onChanged
!=
null
);
onChanged
(
value
*
(
max
-
min
)
+
min
);
}
Widget
build
(
BuildContext
context
)
{
return
new
_SliderRenderObjectWidget
(
value:
value
,
value:
(
value
-
min
)
/
(
max
-
min
)
,
primaryColor:
Theme
.
of
(
context
).
accentColor
,
onChanged:
onChanged
onChanged:
onChanged
!=
null
?
_handleChanged
:
null
);
}
}
...
...
@@ -106,7 +123,7 @@ class _RenderSlider extends RenderConstrainedBox {
void
_handleDragStart
(
Point
globalPosition
)
{
if
(
onChanged
!=
null
)
{
_active
=
true
;
_currentDragValue
=
globalToLocal
(
globalPosition
).
x
/
_trackLength
;
_currentDragValue
=
(
globalToLocal
(
globalPosition
).
x
-
_kReactionRadius
)
/
_trackLength
;
onChanged
(
_currentDragValue
.
clamp
(
0.0
,
1.0
));
_reaction
.
forward
();
markNeedsPaint
();
...
...
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