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
361730ed
Unverified
Commit
361730ed
authored
Aug 09, 2019
by
Justin McCandless
Committed by
GitHub
Aug 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iOS 13 scrollbar vibration (#37724)
Vibrate when starting scrollbar dragging.
parent
f0354b82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
scrollbar.dart
packages/flutter/lib/src/cupertino/scrollbar.dart
+3
-0
scrollbar_test.dart
packages/flutter/test/cupertino/scrollbar_test.dart
+22
-2
No files found.
packages/flutter/lib/src/cupertino/scrollbar.dart
View file @
361730ed
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
// All values eyeballed.
// All values eyeballed.
...
@@ -207,6 +208,7 @@ class _CupertinoScrollbarState extends State<CupertinoScrollbar> with TickerProv
...
@@ -207,6 +208,7 @@ class _CupertinoScrollbarState extends State<CupertinoScrollbar> with TickerProv
_assertVertical
();
_assertVertical
();
_fadeoutTimer
?.
cancel
();
_fadeoutTimer
?.
cancel
();
_fadeoutAnimationController
.
forward
();
_fadeoutAnimationController
.
forward
();
HapticFeedback
.
mediumImpact
();
_dragScrollbar
(
details
.
localPosition
.
dy
);
_dragScrollbar
(
details
.
localPosition
.
dy
);
_dragScrollbarPositionY
=
details
.
localPosition
.
dy
;
_dragScrollbarPositionY
=
details
.
localPosition
.
dy
;
}
}
...
@@ -234,6 +236,7 @@ class _CupertinoScrollbarState extends State<CupertinoScrollbar> with TickerProv
...
@@ -234,6 +236,7 @@ class _CupertinoScrollbarState extends State<CupertinoScrollbar> with TickerProv
_assertVertical
();
_assertVertical
();
_fadeoutTimer
?.
cancel
();
_fadeoutTimer
?.
cancel
();
_thicknessAnimationController
.
forward
();
_thicknessAnimationController
.
forward
();
HapticFeedback
.
mediumImpact
();
_dragScrollbar
(
details
.
localPosition
.
dy
);
_dragScrollbar
(
details
.
localPosition
.
dy
);
_dragScrollbarPositionY
=
details
.
localPosition
.
dy
;
_dragScrollbarPositionY
=
details
.
localPosition
.
dy
;
}
}
...
...
packages/flutter/test/cupertino/scrollbar_test.dart
View file @
361730ed
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../rendering/mock_canvas.dart'
;
import
'../rendering/mock_canvas.dart'
;
...
@@ -86,9 +87,18 @@ void main() {
...
@@ -86,9 +87,18 @@ void main() {
await
scrollGesture
.
up
();
await
scrollGesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
// Longpress on the scrollbar thumb.
int
hapticFeedbackCalls
=
0
;
SystemChannels
.
platform
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
if
(
methodCall
.
method
==
'HapticFeedback.vibrate'
)
{
hapticFeedbackCalls
++;
}
});
// Longpress on the scrollbar thumb and expect a vibration.
expect
(
hapticFeedbackCalls
,
0
);
final
TestGesture
dragScrollbarGesture
=
await
tester
.
startGesture
(
const
Offset
(
796.0
,
50.0
));
final
TestGesture
dragScrollbarGesture
=
await
tester
.
startGesture
(
const
Offset
(
796.0
,
50.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
expect
(
hapticFeedbackCalls
,
1
);
// Drag the thumb down to scroll down.
// Drag the thumb down to scroll down.
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
scrollAmount
));
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
scrollAmount
));
...
@@ -145,11 +155,21 @@ void main() {
...
@@ -145,11 +155,21 @@ void main() {
await
scrollGesture
.
up
();
await
scrollGesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
// Drag in from the right side on top of the scrollbar thumb.
int
hapticFeedbackCalls
=
0
;
SystemChannels
.
platform
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
if
(
methodCall
.
method
==
'HapticFeedback.vibrate'
)
{
hapticFeedbackCalls
++;
}
});
// Drag in from the right side on top of the scrollbar thumb and expect a
// vibration.
expect
(
hapticFeedbackCalls
,
0
);
final
TestGesture
dragScrollbarGesture
=
await
tester
.
startGesture
(
const
Offset
(
796.0
,
50.0
));
final
TestGesture
dragScrollbarGesture
=
await
tester
.
startGesture
(
const
Offset
(
796.0
,
50.0
));
await
tester
.
pump
();
await
tester
.
pump
();
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(-
50.0
,
0.0
));
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(-
50.0
,
0.0
));
await
tester
.
pump
(
_kScrollbarResizeDuration
);
await
tester
.
pump
(
_kScrollbarResizeDuration
);
expect
(
hapticFeedbackCalls
,
1
);
// Drag the thumb down to scroll down.
// Drag the thumb down to scroll down.
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
scrollAmount
));
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
scrollAmount
));
...
...
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