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
709b3550
Commit
709b3550
authored
Oct 23, 2015
by
Kris Giesing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address comments
parent
608e971f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
36 deletions
+38
-36
double_tap.dart
packages/flutter/lib/src/gestures/double_tap.dart
+3
-3
tap.dart
packages/flutter/lib/src/gestures/tap.dart
+34
-32
gesture_detector.dart
packages/flutter/lib/src/widgets/gesture_detector.dart
+1
-1
No files found.
packages/flutter/lib/src/gestures/double_tap.dart
View file @
709b3550
...
...
@@ -11,7 +11,6 @@ import 'recognizer.dart';
import
'tap.dart'
;
class
DoubleTapGestureRecognizer
extends
DisposableArenaMember
{
static
int
sInstances
=
0
;
DoubleTapGestureRecognizer
({
this
.
router
,
this
.
onDoubleTap
});
...
...
@@ -133,12 +132,13 @@ class DoubleTapGestureRecognizer extends DisposableArenaMember {
tracker
.
entry
.
resolve
(
GestureDisposition
.
accepted
);
_freezeTracker
(
tracker
);
_trackers
.
remove
(
tracker
.
pointer
);
onDoubleTap
?.
call
();
if
(
onDoubleTap
!=
null
)
onDoubleTap
();
_reset
();
}
void
_clearTrackers
()
{
List
<
TapTracker
>
localTrackers
=
new
List
.
from
(
_trackers
.
values
);
List
<
TapTracker
>
localTrackers
=
new
List
<
TapTracker
>
.
from
(
_trackers
.
values
);
for
(
TapTracker
tracker
in
localTrackers
)
_reject
(
tracker
);
assert
(
_trackers
.
isEmpty
);
...
...
packages/flutter/lib/src/gestures/tap.dart
View file @
709b3550
...
...
@@ -23,47 +23,45 @@ enum TapResolution {
class
TapTracker
{
TapTracker
({
PointerInputEvent
event
,
this
.
entry
})
:
pointer
=
event
.
pointer
,
initialPosition
=
event
.
position
,
isTrackingPointer
=
false
{
assert
(
event
.
type
==
'pointerdown'
);
}
:
pointer
=
event
.
pointer
,
_
initialPosition
=
event
.
position
,
_
isTrackingPointer
=
false
{
assert
(
event
.
type
==
'pointerdown'
);
}
int
pointer
;
ui
.
Point
initialPosition
;
bool
isTrackingPointer
;
Timer
timer
;
GestureArenaEntry
entry
;
ui
.
Point
_initialPosition
;
bool
_isTrackingPointer
;
Timer
_timer
;
void
startTimer
(
void
callback
())
{
if
(
timer
==
null
)
{
timer
=
new
Timer
(
kTapTimeout
,
callback
);
}
_timer
??=
new
Timer
(
kTapTimeout
,
callback
);
}
void
stopTimer
()
{
if
(
timer
!=
null
)
{
timer
.
cancel
();
timer
=
null
;
if
(
_
timer
!=
null
)
{
_
timer
.
cancel
();
_
timer
=
null
;
}
}
void
startTrackingPointer
(
PointerRouter
router
,
PointerRoute
route
)
{
if
(!
isTrackingPointer
)
{
isTrackingPointer
=
true
;
if
(!
_
isTrackingPointer
)
{
_
isTrackingPointer
=
true
;
router
.
addRoute
(
pointer
,
route
);
}
}
void
stopTrackingPointer
(
PointerRouter
router
,
PointerRoute
route
)
{
if
(
isTrackingPointer
)
{
isTrackingPointer
=
false
;
if
(
_
isTrackingPointer
)
{
_
isTrackingPointer
=
false
;
router
.
removeRoute
(
pointer
,
route
);
}
}
bool
isWithinTolerance
(
PointerInputEvent
event
,
double
tolerance
)
{
ui
.
Offset
offset
=
event
.
position
-
initialPosition
;
ui
.
Offset
offset
=
event
.
position
-
_
initialPosition
;
return
offset
.
distance
<=
tolerance
;
}
...
...
@@ -75,13 +73,13 @@ class TapTracker {
class
TapGesture
extends
TapTracker
{
TapGesture
({
this
.
gestureRecognizer
,
PointerInputEvent
event
})
:
super
(
event:
event
)
{
entry
=
GestureArena
.
instance
.
add
(
event
.
pointer
,
gestureRecognizer
);
_wonArena
=
false
;
_didTap
=
false
;
startTimer
(()
=>
cancel
());
startTrackingPointer
(
gestureRecognizer
.
router
,
handleEvent
);
}
:
super
(
event:
event
)
{
entry
=
GestureArena
.
instance
.
add
(
event
.
pointer
,
gestureRecognizer
);
_wonArena
=
false
;
_didTap
=
false
;
startTimer
(()
=>
cancel
());
startTrackingPointer
(
gestureRecognizer
.
router
,
handleEvent
);
}
TapGestureRecognizer
gestureRecognizer
;
...
...
@@ -144,7 +142,8 @@ class TapGestureRecognizer extends DisposableArenaMember {
gestureRecognizer:
this
,
event:
event
);
onTapDown
?.
call
();
if
(
onTapDown
!=
null
)
onTapDown
();
}
void
acceptGesture
(
int
pointer
)
{
...
...
@@ -157,14 +156,17 @@ class TapGestureRecognizer extends DisposableArenaMember {
void
_resolveTap
(
int
pointer
,
TapResolution
resolution
)
{
_gestureMap
.
remove
(
pointer
);
if
(
resolution
==
TapResolution
.
tap
)
onTap
?.
call
();
else
onTapCancel
?.
call
();
if
(
resolution
==
TapResolution
.
tap
)
{
if
(
onTap
!=
null
)
onTap
();
}
else
{
if
(
onTapCancel
!=
null
)
onTapCancel
();
}
}
void
dispose
()
{
List
<
TapGesture
>
localGestures
=
new
List
.
from
(
_gestureMap
.
values
);
List
<
TapGesture
>
localGestures
=
new
List
<
TapGesture
>
.
from
(
_gestureMap
.
values
);
for
(
TapGesture
gesture
in
localGestures
)
gesture
.
cancel
();
// Rejection of each gesture should cause it to be removed from our map
...
...
packages/flutter/lib/src/widgets/gesture_detector.dart
View file @
709b3550
...
...
@@ -140,7 +140,7 @@ class _GestureDetectorState extends State<GestureDetector> {
if
(
config
.
onDoubleTap
==
null
)
{
_doubleTap
=
_ensureDisposed
(
_doubleTap
);
}
else
{
_doubleTap
=
new
DoubleTapGestureRecognizer
(
router:
_router
);
_doubleTap
??
=
new
DoubleTapGestureRecognizer
(
router:
_router
);
_doubleTap
.
onDoubleTap
=
config
.
onDoubleTap
;
}
}
...
...
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