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
18e512d3
Commit
18e512d3
authored
Sep 04, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace Scroll with Drag in names in GestureRecognizer et al
parent
e6d48ac5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
144 additions
and
142 deletions
+144
-142
scroll.dart
packages/flutter/lib/gestures/scroll.dart
+51
-51
dismissable.dart
packages/flutter/lib/src/widgets/dismissable.dart
+9
-9
gesture_detector.dart
packages/flutter/lib/src/widgets/gesture_detector.dart
+50
-50
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+4
-4
dismissable_test.dart
packages/unit/test/widget/dismissable_test.dart
+2
-0
gesture_detector_test.dart
packages/unit/test/widget/gesture_detector_test.dart
+28
-28
No files found.
packages/flutter/lib/gestures/scroll.dart
View file @
18e512d3
...
...
@@ -8,15 +8,15 @@ import 'package:sky/gestures/arena.dart';
import
'package:sky/gestures/recognizer.dart'
;
import
'package:sky/gestures/constants.dart'
;
enum
Scroll
State
{
enum
Drag
State
{
ready
,
possible
,
accepted
}
typedef
void
Gesture
Scroll
StartCallback
(
);
typedef
void
Gesture
Scroll
UpdateCallback
(
double
scrollDelta
);
typedef
void
Gesture
Scroll
EndCallback
(
);
typedef
void
Gesture
Drag
StartCallback
(
);
typedef
void
Gesture
Drag
UpdateCallback
(
double
scrollDelta
);
typedef
void
Gesture
Drag
EndCallback
(
);
typedef
void
GesturePanStartCallback
(
);
typedef
void
GesturePanUpdateCallback
(
sky
.
Offset
scrollDelta
);
...
...
@@ -24,39 +24,39 @@ typedef void GesturePanEndCallback();
typedef
void
_GesturePolymorphicUpdateCallback
<
T
>(
T
scrollDelta
);
abstract
class
_
Scroll
GestureRecognizer
<
T
extends
dynamic
>
extends
GestureRecognizer
{
_
Scroll
GestureRecognizer
({
PointerRouter
router
,
this
.
onStart
,
this
.
onUpdate
,
this
.
onEnd
})
abstract
class
_
Drag
GestureRecognizer
<
T
extends
dynamic
>
extends
GestureRecognizer
{
_
Drag
GestureRecognizer
({
PointerRouter
router
,
this
.
onStart
,
this
.
onUpdate
,
this
.
onEnd
})
:
super
(
router:
router
);
Gesture
Scroll
StartCallback
onStart
;
Gesture
Drag
StartCallback
onStart
;
_GesturePolymorphicUpdateCallback
<
T
>
onUpdate
;
Gesture
Scroll
EndCallback
onEnd
;
Gesture
Drag
EndCallback
onEnd
;
ScrollState
_state
=
Scroll
State
.
ready
;
T
_pending
Scroll
Delta
;
DragState
_state
=
Drag
State
.
ready
;
T
_pending
Drag
Delta
;
T
get
_initialPending
Scroll
Delta
;
T
_get
Scroll
Delta
(
sky
.
PointerEvent
event
);
bool
get
_hasSufficientPending
Scroll
DeltaToAccept
;
T
get
_initialPending
Drag
Delta
;
T
_get
Drag
Delta
(
sky
.
PointerEvent
event
);
bool
get
_hasSufficientPending
Drag
DeltaToAccept
;
void
addPointer
(
sky
.
PointerEvent
event
)
{
startTrackingPointer
(
event
.
pointer
);
if
(
_state
==
Scroll
State
.
ready
)
{
_state
=
Scroll
State
.
possible
;
_pending
ScrollDelta
=
_initialPendingScroll
Delta
;
if
(
_state
==
Drag
State
.
ready
)
{
_state
=
Drag
State
.
possible
;
_pending
DragDelta
=
_initialPendingDrag
Delta
;
}
}
void
handleEvent
(
sky
.
PointerEvent
event
)
{
assert
(
_state
!=
Scroll
State
.
ready
);
assert
(
_state
!=
Drag
State
.
ready
);
if
(
event
.
type
==
'pointermove'
)
{
T
delta
=
_get
Scroll
Delta
(
event
);
if
(
_state
==
Scroll
State
.
accepted
)
{
T
delta
=
_get
Drag
Delta
(
event
);
if
(
_state
==
Drag
State
.
accepted
)
{
if
(
onUpdate
!=
null
)
onUpdate
(
delta
);
}
else
{
_pending
Scroll
Delta
+=
delta
;
if
(
_hasSufficientPending
Scroll
DeltaToAccept
)
_pending
Drag
Delta
+=
delta
;
if
(
_hasSufficientPending
Drag
DeltaToAccept
)
resolve
(
GestureDisposition
.
accepted
);
}
}
...
...
@@ -64,58 +64,58 @@ abstract class _ScrollGestureRecognizer<T extends dynamic> extends GestureRecogn
}
void
acceptGesture
(
int
pointer
)
{
if
(
_state
!=
Scroll
State
.
accepted
)
{
_state
=
Scroll
State
.
accepted
;
T
delta
=
_pending
Scroll
Delta
;
_pending
Scroll
Delta
=
null
;
if
(
_state
!=
Drag
State
.
accepted
)
{
_state
=
Drag
State
.
accepted
;
T
delta
=
_pending
Drag
Delta
;
_pending
Drag
Delta
=
null
;
if
(
onStart
!=
null
)
onStart
();
if
(
delta
!=
_initialPending
Scroll
Delta
&&
onUpdate
!=
null
)
if
(
delta
!=
_initialPending
Drag
Delta
&&
onUpdate
!=
null
)
onUpdate
(
delta
);
}
}
void
didStopTrackingLastPointer
()
{
if
(
_state
==
Scroll
State
.
possible
)
{
if
(
_state
==
Drag
State
.
possible
)
{
resolve
(
GestureDisposition
.
rejected
);
_state
=
Scroll
State
.
ready
;
_state
=
Drag
State
.
ready
;
return
;
}
bool
wasAccepted
=
(
_state
==
Scroll
State
.
accepted
);
_state
=
Scroll
State
.
ready
;
bool
wasAccepted
=
(
_state
==
Drag
State
.
accepted
);
_state
=
Drag
State
.
ready
;
if
(
wasAccepted
&&
onEnd
!=
null
)
onEnd
();
}
}
class
Vertical
ScrollGestureRecognizer
extends
_Scroll
GestureRecognizer
<
double
>
{
Vertical
Scroll
GestureRecognizer
({
class
Vertical
DragGestureRecognizer
extends
_Drag
GestureRecognizer
<
double
>
{
Vertical
Drag
GestureRecognizer
({
PointerRouter
router
,
Gesture
Scroll
StartCallback
onStart
,
Gesture
Scroll
UpdateCallback
onUpdate
,
Gesture
Scroll
EndCallback
onEnd
Gesture
Drag
StartCallback
onStart
,
Gesture
Drag
UpdateCallback
onUpdate
,
Gesture
Drag
EndCallback
onEnd
})
:
super
(
router:
router
,
onStart:
onStart
,
onUpdate:
onUpdate
,
onEnd:
onEnd
);
double
get
_initialPending
Scroll
Delta
=>
0.0
;
double
get
_initialPending
Drag
Delta
=>
0.0
;
// Notice that we negate dy because scroll offsets go in the opposite direction.
double
_get
Scroll
Delta
(
sky
.
PointerEvent
event
)
=>
-
event
.
dy
;
bool
get
_hasSufficientPending
ScrollDeltaToAccept
=>
_pendingScroll
Delta
.
abs
()
>
kTouchSlop
;
double
_get
Drag
Delta
(
sky
.
PointerEvent
event
)
=>
-
event
.
dy
;
bool
get
_hasSufficientPending
DragDeltaToAccept
=>
_pendingDrag
Delta
.
abs
()
>
kTouchSlop
;
}
class
Horizontal
ScrollGestureRecognizer
extends
_Scroll
GestureRecognizer
<
double
>
{
Horizontal
Scroll
GestureRecognizer
({
class
Horizontal
DragGestureRecognizer
extends
_Drag
GestureRecognizer
<
double
>
{
Horizontal
Drag
GestureRecognizer
({
PointerRouter
router
,
Gesture
Scroll
StartCallback
onStart
,
Gesture
Scroll
UpdateCallback
onUpdate
,
Gesture
Scroll
EndCallback
onEnd
Gesture
Drag
StartCallback
onStart
,
Gesture
Drag
UpdateCallback
onUpdate
,
Gesture
Drag
EndCallback
onEnd
})
:
super
(
router:
router
,
onStart:
onStart
,
onUpdate:
onUpdate
,
onEnd:
onEnd
);
double
get
_initialPending
Scroll
Delta
=>
0.0
;
double
_get
Scroll
Delta
(
sky
.
PointerEvent
event
)
=>
-
event
.
dx
;
bool
get
_hasSufficientPending
ScrollDeltaToAccept
=>
_pendingScroll
Delta
.
abs
()
>
kTouchSlop
;
double
get
_initialPending
Drag
Delta
=>
0.0
;
double
_get
Drag
Delta
(
sky
.
PointerEvent
event
)
=>
-
event
.
dx
;
bool
get
_hasSufficientPending
DragDeltaToAccept
=>
_pendingDrag
Delta
.
abs
()
>
kTouchSlop
;
}
class
PanGestureRecognizer
extends
_
Scroll
GestureRecognizer
<
sky
.
Offset
>
{
class
PanGestureRecognizer
extends
_
Drag
GestureRecognizer
<
sky
.
Offset
>
{
PanGestureRecognizer
({
PointerRouter
router
,
GesturePanStartCallback
onStart
,
...
...
@@ -123,10 +123,10 @@ class PanGestureRecognizer extends _ScrollGestureRecognizer<sky.Offset> {
GesturePanEndCallback
onEnd
})
:
super
(
router:
router
,
onStart:
onStart
,
onUpdate:
onUpdate
,
onEnd:
onEnd
);
sky
.
Offset
get
_initialPending
Scroll
Delta
=>
sky
.
Offset
.
zero
;
sky
.
Offset
get
_initialPending
Drag
Delta
=>
sky
.
Offset
.
zero
;
// Notice that we negate dy because scroll offsets go in the opposite direction.
sky
.
Offset
_get
Scroll
Delta
(
sky
.
PointerEvent
event
)
=>
new
sky
.
Offset
(
event
.
dx
,
-
event
.
dy
);
bool
get
_hasSufficientPending
Scroll
DeltaToAccept
{
return
_pending
ScrollDelta
.
dx
.
abs
()
>
kTouchSlop
||
_pendingScroll
Delta
.
dy
.
abs
()
>
kTouchSlop
;
sky
.
Offset
_get
Drag
Delta
(
sky
.
PointerEvent
event
)
=>
new
sky
.
Offset
(
event
.
dx
,
-
event
.
dy
);
bool
get
_hasSufficientPending
Drag
DeltaToAccept
{
return
_pending
DragDelta
.
dx
.
abs
()
>
kTouchSlop
||
_pendingDrag
Delta
.
dy
.
abs
()
>
kTouchSlop
;
}
}
packages/flutter/lib/src/widgets/dismissable.dart
View file @
18e512d3
...
...
@@ -119,7 +119,7 @@ class Dismissable extends StatefulComponent {
_maybeCallOnResized
();
}
void
_handle
Scroll
Start
()
{
void
_handle
Drag
Start
()
{
if
(
_fadePerformance
.
isAnimating
)
return
;
_dragUnderway
=
true
;
...
...
@@ -127,7 +127,7 @@ class Dismissable extends StatefulComponent {
_fadePerformance
.
progress
=
0.0
;
}
void
_handle
Scroll
Update
(
double
scrollOffset
)
{
void
_handle
Drag
Update
(
double
scrollOffset
)
{
if
(!
_isActive
||
_fadePerformance
.
isAnimating
)
return
;
...
...
@@ -157,7 +157,7 @@ class Dismissable extends StatefulComponent {
_fadePerformance
.
progress
=
_dragExtent
.
abs
()
/
(
_size
.
width
*
_kDismissCardThreshold
);
}
_handle
Scroll
End
()
{
_handle
Drag
End
()
{
if
(!
_isActive
||
_fadePerformance
.
isAnimating
)
return
;
_dragUnderway
=
false
;
...
...
@@ -238,12 +238,12 @@ class Dismissable extends StatefulComponent {
}
return
new
GestureDetector
(
onHorizontal
ScrollStart:
_directionIsYAxis
?
null
:
_handleScroll
Start
,
onHorizontal
ScrollUpdate:
_directionIsYAxis
?
null
:
_handleScroll
Update
,
onHorizontal
ScrollEnd:
_directionIsYAxis
?
null
:
_handleScroll
End
,
onVertical
ScrollStart:
_directionIsYAxis
?
_handleScroll
Start
:
null
,
onVertical
ScrollUpdate:
_directionIsYAxis
?
_handleScroll
Update
:
null
,
onVertical
ScrollEnd:
_directionIsYAxis
?
_handleScroll
End
:
null
,
onHorizontal
DragStart:
_directionIsYAxis
?
null
:
_handleDrag
Start
,
onHorizontal
DragUpdate:
_directionIsYAxis
?
null
:
_handleDrag
Update
,
onHorizontal
DragEnd:
_directionIsYAxis
?
null
:
_handleDrag
End
,
onVertical
DragStart:
_directionIsYAxis
?
_handleDrag
Start
:
null
,
onVertical
DragUpdate:
_directionIsYAxis
?
_handleDrag
Update
:
null
,
onVertical
DragEnd:
_directionIsYAxis
?
_handleDrag
End
:
null
,
child:
new
Listener
(
onGestureFlingStart:
_handleFlingStart
,
child:
new
SizeObserver
(
...
...
packages/flutter/lib/src/widgets/gesture_detector.dart
View file @
18e512d3
...
...
@@ -19,12 +19,12 @@ class GestureDetector extends StatefulComponent {
this
.
onTap
,
this
.
onShowPress
,
this
.
onLongPress
,
this
.
onVertical
Scroll
Start
,
this
.
onVertical
Scroll
Update
,
this
.
onVertical
Scroll
End
,
this
.
onHorizontal
Scroll
Start
,
this
.
onHorizontal
Scroll
Update
,
this
.
onHorizontal
Scroll
End
,
this
.
onVertical
Drag
Start
,
this
.
onVertical
Drag
Update
,
this
.
onVertical
Drag
End
,
this
.
onHorizontal
Drag
Start
,
this
.
onHorizontal
Drag
Update
,
this
.
onHorizontal
Drag
End
,
this
.
onPanStart
,
this
.
onPanUpdate
,
this
.
onPanEnd
...
...
@@ -35,13 +35,13 @@ class GestureDetector extends StatefulComponent {
GestureShowPressListener
onShowPress
;
GestureLongPressListener
onLongPress
;
Gesture
ScrollStartCallback
onVerticalScroll
Start
;
Gesture
ScrollUpdateCallback
onVerticalScroll
Update
;
Gesture
ScrollEndCallback
onVerticalScroll
End
;
Gesture
DragStartCallback
onVerticalDrag
Start
;
Gesture
DragUpdateCallback
onVerticalDrag
Update
;
Gesture
DragEndCallback
onVerticalDrag
End
;
Gesture
ScrollStartCallback
onHorizontalScroll
Start
;
Gesture
ScrollUpdateCallback
onHorizontalScroll
Update
;
Gesture
ScrollEndCallback
onHorizontalScroll
End
;
Gesture
DragStartCallback
onHorizontalDrag
Start
;
Gesture
DragUpdateCallback
onHorizontalDrag
Update
;
Gesture
DragEndCallback
onHorizontalDrag
End
;
GesturePanStartCallback
onPanStart
;
GesturePanUpdateCallback
onPanUpdate
;
...
...
@@ -52,12 +52,12 @@ class GestureDetector extends StatefulComponent {
onTap
=
source
.
onTap
;
onShowPress
=
source
.
onShowPress
;
onLongPress
=
source
.
onLongPress
;
onVertical
ScrollStart
=
source
.
onVerticalScroll
Start
;
onVertical
ScrollUpdate
=
source
.
onVerticalScroll
Update
;
onVertical
ScrollEnd
=
source
.
onVerticalScroll
End
;
onHorizontal
ScrollStart
=
source
.
onHorizontalScroll
Start
;
onHorizontal
ScrollUpdate
=
source
.
onHorizontalScroll
Update
;
onHorizontal
ScrollEnd
=
source
.
onHorizontalScroll
End
;
onVertical
DragStart
=
source
.
onVerticalDrag
Start
;
onVertical
DragUpdate
=
source
.
onVerticalDrag
Update
;
onVertical
DragEnd
=
source
.
onVerticalDrag
End
;
onHorizontal
DragStart
=
source
.
onHorizontalDrag
Start
;
onHorizontal
DragUpdate
=
source
.
onHorizontalDrag
Update
;
onHorizontal
DragEnd
=
source
.
onHorizontalDrag
End
;
onPanStart
=
source
.
onPanStart
;
onPanUpdate
=
source
.
onPanUpdate
;
onPanEnd
=
source
.
onPanEnd
;
...
...
@@ -87,18 +87,18 @@ class GestureDetector extends StatefulComponent {
return
_longPress
;
}
Vertical
ScrollGestureRecognizer
_verticalScroll
;
Vertical
ScrollGestureRecognizer
_ensureVerticalScroll
()
{
if
(
_vertical
Scroll
==
null
)
_vertical
Scroll
=
new
VerticalScroll
GestureRecognizer
(
router:
_router
);
return
_vertical
Scroll
;
Vertical
DragGestureRecognizer
_verticalDrag
;
Vertical
DragGestureRecognizer
_ensureVerticalDrag
()
{
if
(
_vertical
Drag
==
null
)
_vertical
Drag
=
new
VerticalDrag
GestureRecognizer
(
router:
_router
);
return
_vertical
Drag
;
}
Horizontal
ScrollGestureRecognizer
_horizontalScroll
;
Horizontal
ScrollGestureRecognizer
_ensureHorizontalScroll
()
{
if
(
_horizontal
Scroll
==
null
)
_horizontal
Scroll
=
new
HorizontalScroll
GestureRecognizer
(
router:
_router
);
return
_horizontal
Scroll
;
Horizontal
DragGestureRecognizer
_horizontalDrag
;
Horizontal
DragGestureRecognizer
_ensureHorizontalDrag
()
{
if
(
_horizontal
Drag
==
null
)
_horizontal
Drag
=
new
HorizontalDrag
GestureRecognizer
(
router:
_router
);
return
_horizontal
Drag
;
}
PanGestureRecognizer
_pan
;
...
...
@@ -118,8 +118,8 @@ class GestureDetector extends StatefulComponent {
_tap
=
_ensureDisposed
(
_tap
);
_showPress
=
_ensureDisposed
(
_showPress
);
_longPress
=
_ensureDisposed
(
_longPress
);
_vertical
Scroll
=
_ensureDisposed
(
_verticalScroll
);
_horizontal
Scroll
=
_ensureDisposed
(
_horizontalScroll
);
_vertical
Drag
=
_ensureDisposed
(
_verticalDrag
);
_horizontal
Drag
=
_ensureDisposed
(
_horizontalDrag
);
_pan
=
_ensureDisposed
(
_pan
);
}
...
...
@@ -127,8 +127,8 @@ class GestureDetector extends StatefulComponent {
_syncTap
();
_syncShowPress
();
_syncLongPress
();
_syncVertical
Scroll
();
_syncHorizontal
Scroll
();
_syncVertical
Drag
();
_syncHorizontal
Drag
();
_syncPan
();
}
...
...
@@ -153,25 +153,25 @@ class GestureDetector extends StatefulComponent {
_ensureLongPress
().
onLongPress
=
onLongPress
;
}
void
_syncVertical
Scroll
()
{
if
(
onVertical
ScrollStart
==
null
&&
onVerticalScrollUpdate
==
null
&&
onVerticalScroll
End
==
null
)
{
_vertical
Scroll
=
_ensureDisposed
(
_verticalScroll
);
void
_syncVertical
Drag
()
{
if
(
onVertical
DragStart
==
null
&&
onVerticalDragUpdate
==
null
&&
onVerticalDrag
End
==
null
)
{
_vertical
Drag
=
_ensureDisposed
(
_verticalDrag
);
}
else
{
_ensureVertical
Scroll
()
..
onStart
=
onVertical
Scroll
Start
..
onUpdate
=
onVertical
Scroll
Update
..
onEnd
=
onVertical
Scroll
End
;
_ensureVertical
Drag
()
..
onStart
=
onVertical
Drag
Start
..
onUpdate
=
onVertical
Drag
Update
..
onEnd
=
onVertical
Drag
End
;
}
}
void
_syncHorizontal
Scroll
()
{
if
(
onHorizontal
ScrollStart
==
null
&&
onHorizontalScrollUpdate
==
null
&&
onHorizontalScroll
End
==
null
)
{
_horizontal
Scroll
=
_ensureDisposed
(
_horizontalScroll
);
void
_syncHorizontal
Drag
()
{
if
(
onHorizontal
DragStart
==
null
&&
onHorizontalDragUpdate
==
null
&&
onHorizontalDrag
End
==
null
)
{
_horizontal
Drag
=
_ensureDisposed
(
_horizontalDrag
);
}
else
{
_ensureHorizontal
Scroll
()
..
onStart
=
onHorizontal
Scroll
Start
..
onUpdate
=
onHorizontal
Scroll
Update
..
onEnd
=
onHorizontal
Scroll
End
;
_ensureHorizontal
Drag
()
..
onStart
=
onHorizontal
Drag
Start
..
onUpdate
=
onHorizontal
Drag
Update
..
onEnd
=
onHorizontal
Drag
End
;
}
}
...
...
@@ -198,10 +198,10 @@ class GestureDetector extends StatefulComponent {
_showPress
.
addPointer
(
event
);
if
(
_longPress
!=
null
)
_longPress
.
addPointer
(
event
);
if
(
_vertical
Scroll
!=
null
)
_vertical
Scroll
.
addPointer
(
event
);
if
(
_horizontal
Scroll
!=
null
)
_horizontal
Scroll
.
addPointer
(
event
);
if
(
_vertical
Drag
!=
null
)
_vertical
Drag
.
addPointer
(
event
);
if
(
_horizontal
Drag
!=
null
)
_horizontal
Drag
.
addPointer
(
event
);
if
(
_pan
!=
null
)
_pan
.
addPointer
(
event
);
return
EventDisposition
.
processed
;
...
...
packages/flutter/lib/src/widgets/scrollable.dart
View file @
18e512d3
...
...
@@ -85,10 +85,10 @@ abstract class Scrollable extends StatefulComponent {
Widget
build
()
{
return
new
GestureDetector
(
onVertical
Scroll
Update:
scrollDirection
==
ScrollDirection
.
vertical
?
scrollBy
:
null
,
onVertical
Scroll
End:
scrollDirection
==
ScrollDirection
.
vertical
?
_maybeSettleScrollOffset
:
null
,
onHorizontal
Scroll
Update:
scrollDirection
==
ScrollDirection
.
horizontal
?
scrollBy
:
null
,
onHorizontal
Scroll
End:
scrollDirection
==
ScrollDirection
.
horizontal
?
_maybeSettleScrollOffset
:
null
,
onVertical
Drag
Update:
scrollDirection
==
ScrollDirection
.
vertical
?
scrollBy
:
null
,
onVertical
Drag
End:
scrollDirection
==
ScrollDirection
.
vertical
?
_maybeSettleScrollOffset
:
null
,
onHorizontal
Drag
Update:
scrollDirection
==
ScrollDirection
.
horizontal
?
scrollBy
:
null
,
onHorizontal
Drag
End:
scrollDirection
==
ScrollDirection
.
horizontal
?
_maybeSettleScrollOffset
:
null
,
child:
new
Listener
(
child:
buildContent
(),
onPointerDown:
_handlePointerDown
,
...
...
packages/unit/test/widget/dismissable_test.dart
View file @
18e512d3
...
...
@@ -77,6 +77,8 @@ void dismissItem(WidgetTester tester, int item, { DismissDirection gestureDirect
downLocation
=
tester
.
getTopLeft
(
itemWidget
);
upLocation
=
tester
.
getBottomLeft
(
itemWidget
);
break
;
default
:
fail
(
"unsupported gestureDirection"
);
}
TestPointer
pointer
=
new
TestPointer
(
5
);
...
...
packages/unit/test/widget/gesture_detector_test.dart
View file @
18e512d3
...
...
@@ -9,49 +9,49 @@ void main() {
WidgetTester
tester
=
new
WidgetTester
();
TestPointer
pointer
=
new
TestPointer
(
7
);
bool
didStart
Scroll
=
false
;
double
updated
Scroll
Delta
;
bool
didEnd
Scroll
=
false
;
bool
didStart
Drag
=
false
;
double
updated
Drag
Delta
;
bool
didEnd
Drag
=
false
;
Widget
builder
()
{
return
new
GestureDetector
(
onVertical
Scroll
Start:
()
{
didStart
Scroll
=
true
;
onVertical
Drag
Start:
()
{
didStart
Drag
=
true
;
},
onVertical
Scroll
Update:
(
double
scrollDelta
)
{
updated
Scroll
Delta
=
scrollDelta
;
onVertical
Drag
Update:
(
double
scrollDelta
)
{
updated
Drag
Delta
=
scrollDelta
;
},
onVertical
Scroll
End:
()
{
didEnd
Scroll
=
true
;
onVertical
Drag
End:
()
{
didEnd
Drag
=
true
;
},
child:
new
Container
()
);
}
tester
.
pumpFrame
(
builder
);
expect
(
didStart
Scroll
,
isFalse
);
expect
(
updated
Scroll
Delta
,
isNull
);
expect
(
didEnd
Scroll
,
isFalse
);
expect
(
didStart
Drag
,
isFalse
);
expect
(
updated
Drag
Delta
,
isNull
);
expect
(
didEnd
Drag
,
isFalse
);
Point
firstLocation
=
new
Point
(
10.0
,
10.0
);
tester
.
dispatchEvent
(
pointer
.
down
(
firstLocation
),
firstLocation
);
expect
(
didStart
Scroll
,
isTrue
);
didStart
Scroll
=
false
;
expect
(
updated
Scroll
Delta
,
isNull
);
expect
(
didEnd
Scroll
,
isFalse
);
expect
(
didStart
Drag
,
isTrue
);
didStart
Drag
=
false
;
expect
(
updated
Drag
Delta
,
isNull
);
expect
(
didEnd
Drag
,
isFalse
);
Point
secondLocation
=
new
Point
(
10.0
,
9.0
);
tester
.
dispatchEvent
(
pointer
.
move
(
secondLocation
),
firstLocation
);
expect
(
didStart
Scroll
,
isFalse
);
expect
(
updated
Scroll
Delta
,
1.0
);
updated
Scroll
Delta
=
null
;
expect
(
didEnd
Scroll
,
isFalse
);
expect
(
didStart
Drag
,
isFalse
);
expect
(
updated
Drag
Delta
,
1.0
);
updated
Drag
Delta
=
null
;
expect
(
didEnd
Drag
,
isFalse
);
tester
.
dispatchEvent
(
pointer
.
up
(),
firstLocation
);
expect
(
didStart
Scroll
,
isFalse
);
expect
(
updated
Scroll
Delta
,
isNull
);
expect
(
didEnd
Scroll
,
isTrue
);
didEnd
Scroll
=
false
;
expect
(
didStart
Drag
,
isFalse
);
expect
(
updated
Drag
Delta
,
isNull
);
expect
(
didEnd
Drag
,
isTrue
);
didEnd
Drag
=
false
;
tester
.
pumpFrame
(()
=>
new
Container
());
});
...
...
@@ -68,10 +68,10 @@ void main() {
Widget
builder
()
{
return
new
GestureDetector
(
onVertical
Scroll
Update:
(
double
delta
)
{
dragDistance
+=
delta
;
},
onVertical
Scroll
End:
()
{
gestureCount
+=
1
;
},
onHorizontal
Scroll
Update:
(
_
)
{
fail
(
"gesture should not match"
);
},
onHorizontal
Scroll
End:
()
{
fail
(
"gesture should not match"
);
},
onVertical
Drag
Update:
(
double
delta
)
{
dragDistance
+=
delta
;
},
onVertical
Drag
End:
()
{
gestureCount
+=
1
;
},
onHorizontal
Drag
Update:
(
_
)
{
fail
(
"gesture should not match"
);
},
onHorizontal
Drag
End:
()
{
fail
(
"gesture should not match"
);
},
child:
new
Container
()
);
}
...
...
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