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
df0a9fc1
Commit
df0a9fc1
authored
Apr 08, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scrollbar cleanups (#3229)
parent
83ef964a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+1
-1
scrollbar.dart
packages/flutter/lib/src/material/scrollbar.dart
+15
-13
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
df0a9fc1
...
...
@@ -487,7 +487,7 @@ class ScaffoldState extends State<Scaffold> {
double
_floatingAppBarHeight
=
0.0
;
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
if
(
config
.
scrollableKey
!=
null
&&
config
.
scrollableKey
==
notification
.
scrollable
.
config
.
key
)
{
if
(
config
.
scrollableKey
==
null
||
config
.
scrollableKey
==
notification
.
scrollable
.
config
.
key
)
{
final
double
newScrollOffset
=
notification
.
scrollable
.
scrollOffset
;
setState
(()
{
_scrollOffsetDelta
=
_scrollOffset
-
newScrollOffset
;
...
...
packages/flutter/lib/src/material/scrollbar.dart
View file @
df0a9fc1
...
...
@@ -6,24 +6,24 @@ import 'package:flutter/widgets.dart';
import
'theme.dart'
;
const
double
_kMinScrollbarThumb
Length
=
18.0
;
const
double
_kMinScrollbarThumb
Extent
=
18.0
;
const
double
_kScrollbarThumbGirth
=
6.0
;
const
Duration
_kScrollbarThumbFadeDuration
=
const
Duration
(
milliseconds:
300
);
class
_
Scrollbar
Painter
extends
CustomPainter
{
_
Scrollbar
Painter
({
class
_Painter
extends
CustomPainter
{
_Painter
({
this
.
scrollOffset
,
this
.
scrollDirection
,
this
.
contentExtent
,
this
.
containerExtent
,
this
.
thumbC
olor
this
.
c
olor
});
final
double
scrollOffset
;
final
Axis
scrollDirection
;
final
double
contentExtent
;
final
double
containerExtent
;
final
Color
thumbC
olor
;
final
Color
c
olor
;
void
paintScrollbar
(
Canvas
canvas
,
Size
size
)
{
Point
thumbOrigin
;
...
...
@@ -32,7 +32,7 @@ class _ScrollbarPainter extends CustomPainter {
switch
(
scrollDirection
)
{
case
Axis
.
vertical
:
double
thumbHeight
=
size
.
height
*
containerExtent
/
contentExtent
;
thumbHeight
=
thumbHeight
.
clamp
(
_kMinScrollbarThumb
Length
,
size
.
height
);
thumbHeight
=
thumbHeight
.
clamp
(
_kMinScrollbarThumb
Extent
,
size
.
height
);
final
double
maxThumbTop
=
size
.
height
-
thumbHeight
;
double
thumbTop
=
(
scrollOffset
/
(
contentExtent
-
containerExtent
))
*
maxThumbTop
;
thumbTop
=
thumbTop
.
clamp
(
0.0
,
maxThumbTop
);
...
...
@@ -41,7 +41,7 @@ class _ScrollbarPainter extends CustomPainter {
break
;
case
Axis
.
horizontal
:
double
thumbWidth
=
size
.
width
*
containerExtent
/
contentExtent
;
thumbWidth
=
thumbWidth
.
clamp
(
_kMinScrollbarThumb
Length
,
size
.
width
);
thumbWidth
=
thumbWidth
.
clamp
(
_kMinScrollbarThumb
Extent
,
size
.
width
);
final
double
maxThumbLeft
=
size
.
width
-
thumbWidth
;
double
thumbLeft
=
(
scrollOffset
/
(
contentExtent
-
containerExtent
))
*
maxThumbLeft
;
thumbLeft
=
thumbLeft
.
clamp
(
0.0
,
maxThumbLeft
);
...
...
@@ -50,24 +50,24 @@ class _ScrollbarPainter extends CustomPainter {
break
;
}
final
Paint
paint
=
new
Paint
()..
color
=
thumbC
olor
;
final
Paint
paint
=
new
Paint
()..
color
=
c
olor
;
canvas
.
drawRect
(
thumbOrigin
&
thumbSize
,
paint
);
}
@override
void
paint
(
Canvas
canvas
,
Size
size
)
{
if
(
scrollOffset
==
null
||
thumbC
olor
.
alpha
==
0
)
if
(
scrollOffset
==
null
||
c
olor
.
alpha
==
0
)
return
;
paintScrollbar
(
canvas
,
size
);
}
@override
bool
shouldRepaint
(
_
Scrollbar
Painter
oldPainter
)
{
bool
shouldRepaint
(
_Painter
oldPainter
)
{
return
oldPainter
.
scrollOffset
!=
scrollOffset
||
oldPainter
.
scrollDirection
!=
scrollDirection
||
oldPainter
.
contentExtent
!=
contentExtent
||
oldPainter
.
containerExtent
!=
containerExtent
||
oldPainter
.
thumbColor
!=
thumbC
olor
;
||
oldPainter
.
color
!=
c
olor
;
}
}
...
...
@@ -102,6 +102,8 @@ class _ScrollbarState extends State<Scrollbar> {
}
void
_updateState
(
ScrollableState
scrollable
)
{
if
(
scrollable
.
scrollBehavior
is
!
ExtentScrollBehavior
)
return
;
final
ExtentScrollBehavior
scrollBehavior
=
scrollable
.
scrollBehavior
;
_scrollOffset
=
scrollable
.
scrollOffset
;
_scrollDirection
=
scrollable
.
config
.
scrollDirection
;
...
...
@@ -151,12 +153,12 @@ class _ScrollbarState extends State<Scrollbar> {
animation:
_opacity
,
builder:
(
BuildContext
context
,
Widget
child
)
{
return
new
CustomPaint
(
foregroundPainter:
new
_
Scrollbar
Painter
(
foregroundPainter:
new
_Painter
(
scrollOffset:
_scrollOffset
,
scrollDirection:
_scrollDirection
,
containerExtent:
_containerExtent
,
contentExtent:
_contentExtent
,
thumbC
olor:
Theme
.
of
(
context
).
highlightColor
.
withOpacity
(
_opacity
.
value
)
c
olor:
Theme
.
of
(
context
).
highlightColor
.
withOpacity
(
_opacity
.
value
)
),
child:
child
);
...
...
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