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
5f394877
Unverified
Commit
5f394877
authored
Jun 13, 2019
by
LongCatIsLooong
Committed by
GitHub
Jun 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't show scrollbar if there isn't enough content (#34175)
parent
3ae6abd9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
3 deletions
+82
-3
scrollbar.dart
packages/flutter/lib/src/cupertino/scrollbar.dart
+5
-0
scrollbar.dart
packages/flutter/lib/src/material/scrollbar.dart
+5
-0
scrollbar_paint_test.dart
packages/flutter/test/cupertino/scrollbar_paint_test.dart
+41
-1
scrollbar_paint_test.dart
packages/flutter/test/material/scrollbar_paint_test.dart
+28
-0
scrollbar_test.dart
packages/flutter/test/material/scrollbar_test.dart
+3
-2
No files found.
packages/flutter/lib/src/cupertino/scrollbar.dart
View file @
5f394877
...
@@ -103,6 +103,11 @@ class _CupertinoScrollbarState extends State<CupertinoScrollbar> with TickerProv
...
@@ -103,6 +103,11 @@ class _CupertinoScrollbarState extends State<CupertinoScrollbar> with TickerProv
}
}
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
final
ScrollMetrics
metrics
=
notification
.
metrics
;
if
(
metrics
.
maxScrollExtent
<=
metrics
.
minScrollExtent
)
{
return
false
;
}
if
(
notification
is
ScrollUpdateNotification
||
if
(
notification
is
ScrollUpdateNotification
||
notification
is
OverscrollNotification
)
{
notification
is
OverscrollNotification
)
{
// Any movements always makes the scrollbar start showing up.
// Any movements always makes the scrollbar start showing up.
...
...
packages/flutter/lib/src/material/scrollbar.dart
View file @
5f394877
...
@@ -109,6 +109,11 @@ class _ScrollbarState extends State<Scrollbar> with TickerProviderStateMixin {
...
@@ -109,6 +109,11 @@ class _ScrollbarState extends State<Scrollbar> with TickerProviderStateMixin {
}
}
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
final
ScrollMetrics
metrics
=
notification
.
metrics
;
if
(
metrics
.
maxScrollExtent
<=
metrics
.
minScrollExtent
)
{
return
false
;
}
// iOS sub-delegates to the CupertinoScrollbar instead and doesn't handle
// iOS sub-delegates to the CupertinoScrollbar instead and doesn't handle
// scroll notifications here.
// scroll notifications here.
if
(
_currentPlatform
!=
TargetPlatform
.
iOS
if
(
_currentPlatform
!=
TargetPlatform
.
iOS
...
...
packages/flutter/test/cupertino/scrollbar_paint_test.dart
View file @
5f394877
...
@@ -77,7 +77,7 @@ void main() {
...
@@ -77,7 +77,7 @@ void main() {
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
ListView
)));
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
ListView
)));
await
gesture
.
moveBy
(
_kGestureOffset
);
await
gesture
.
moveBy
(
_kGestureOffset
);
// Move back to original position.
// Move back to original position.
await
gesture
.
moveBy
(
Offset
.
zero
.
translate
(-
_kGestureOffset
.
dx
,
-
_kGestureOffset
.
dy
));
await
gesture
.
moveBy
(
Offset
(-
_kGestureOffset
.
dx
,
-
_kGestureOffset
.
dy
));
await
tester
.
pump
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
...
@@ -96,4 +96,44 @@ void main() {
...
@@ -96,4 +96,44 @@ void main() {
),
),
));
));
});
});
testWidgets
(
"should not paint when there isn't enough space"
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
MediaQuery
(
data:
const
MediaQueryData
(
padding:
EdgeInsets
.
fromLTRB
(
0
,
20
,
0
,
34
),
),
child:
CupertinoPageScaffold
(
navigationBar:
const
CupertinoNavigationBar
(
middle:
Text
(
'Title'
),
backgroundColor:
Color
(
0x11111111
),
),
child:
CupertinoScrollbar
(
child:
ListView
(
physics:
const
AlwaysScrollableScrollPhysics
(
parent:
BouncingScrollPhysics
()),
children:
const
<
Widget
>
[
SizedBox
(
width:
10
,
height:
10
)],
),
),
),
),
),
);
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
ListView
)));
await
gesture
.
moveBy
(
_kGestureOffset
);
// Move back to original position.
await
gesture
.
moveBy
(
Offset
(-
_kGestureOffset
.
dx
,
-
_kGestureOffset
.
dy
));
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
expect
(
find
.
byType
(
CupertinoScrollbar
),
isNot
(
paints
..
rrect
()));
// The scrollbar should not appear even when overscrolled.
final
TestGesture
overscrollGesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
ListView
)));
await
overscrollGesture
.
moveBy
(
_kGestureOffset
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
expect
(
find
.
byType
(
CupertinoScrollbar
),
isNot
(
paints
..
rrect
()));
});
}
}
packages/flutter/test/material/scrollbar_paint_test.dart
View file @
5f394877
...
@@ -77,4 +77,32 @@ void main() {
...
@@ -77,4 +77,32 @@ void main() {
),
),
));
));
});
});
testWidgets
(
"should not paint when there isn't enough space"
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
data:
const
MediaQueryData
(
padding:
EdgeInsets
.
fromLTRB
(
0
,
20
,
0
,
34
)
),
child:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Title'
)),
body:
Scrollbar
(
child:
ListView
(
children:
const
<
Widget
>[
SizedBox
(
width:
40
,
height:
40
)]
),
),
),
),
));
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
ListView
)));
// On Android it should not overscroll.
await
gesture
.
moveBy
(
const
Offset
(
0
,
100
));
// Trigger fade in animation.
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
expect
(
find
.
byType
(
Scrollbar
),
isNot
(
paints
..
rect
()));
});
}
}
packages/flutter/test/material/scrollbar_test.dart
View file @
5f394877
...
@@ -115,8 +115,9 @@ void main() {
...
@@ -115,8 +115,9 @@ void main() {
final
List
<
Invocation
>
invocations
=
<
Invocation
>[];
final
List
<
Invocation
>
invocations
=
<
Invocation
>[];
final
TestCanvas
canvas
=
TestCanvas
(
invocations
);
final
TestCanvas
canvas
=
TestCanvas
(
invocations
);
scrollPainter
.
paint
(
canvas
,
const
Size
(
10.0
,
100.0
));
scrollPainter
.
paint
(
canvas
,
const
Size
(
10.0
,
100.0
));
final
Rect
thumbRect
=
invocations
.
single
.
positionalArguments
[
0
];
expect
(
thumbRect
.
isFinite
,
isTrue
);
// Scrollbar is not supposed to draw anything if there isn't enough content.
expect
(
invocations
.
isEmpty
,
isTrue
);
});
});
testWidgets
(
'Adaptive scrollbar'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Adaptive scrollbar'
,
(
WidgetTester
tester
)
async
{
...
...
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