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
f6a88d03
Unverified
Commit
f6a88d03
authored
Jan 06, 2020
by
Mouad Debbar
Committed by
GitHub
Jan 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Registering multiple transformed events should work (#48149)
parent
2221a9f5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
pointer_signal_resolver.dart
...ges/flutter/lib/src/gestures/pointer_signal_resolver.dart
+6
-2
pointer_signal_resolver_test.dart
...s/flutter/test/gestures/pointer_signal_resolver_test.dart
+15
-0
No files found.
packages/flutter/lib/src/gestures/pointer_signal_resolver.dart
View file @
f6a88d03
...
@@ -10,6 +10,10 @@ import 'events.dart';
...
@@ -10,6 +10,10 @@ import 'events.dart';
/// interest in a pointer signal event.
/// interest in a pointer signal event.
typedef
PointerSignalResolvedCallback
=
void
Function
(
PointerSignalEvent
event
);
typedef
PointerSignalResolvedCallback
=
void
Function
(
PointerSignalEvent
event
);
bool
_isSameEvent
(
PointerSignalEvent
event1
,
PointerSignalEvent
event2
)
{
return
(
event1
.
original
??
event1
)
==
(
event2
.
original
??
event2
);
}
/// An resolver for pointer signal events.
/// An resolver for pointer signal events.
///
///
/// Objects interested in a [PointerSignalEvent] should register a callback to
/// Objects interested in a [PointerSignalEvent] should register a callback to
...
@@ -29,7 +33,7 @@ class PointerSignalResolver {
...
@@ -29,7 +33,7 @@ class PointerSignalResolver {
void
register
(
PointerSignalEvent
event
,
PointerSignalResolvedCallback
callback
)
{
void
register
(
PointerSignalEvent
event
,
PointerSignalResolvedCallback
callback
)
{
assert
(
event
!=
null
);
assert
(
event
!=
null
);
assert
(
callback
!=
null
);
assert
(
callback
!=
null
);
assert
(
_currentEvent
==
null
||
_
currentEvent
==
event
);
assert
(
_currentEvent
==
null
||
_
isSameEvent
(
_currentEvent
,
event
)
);
if
(
_firstRegisteredCallback
!=
null
)
{
if
(
_firstRegisteredCallback
!=
null
)
{
return
;
return
;
}
}
...
@@ -47,7 +51,7 @@ class PointerSignalResolver {
...
@@ -47,7 +51,7 @@ class PointerSignalResolver {
assert
(
_currentEvent
==
null
);
assert
(
_currentEvent
==
null
);
return
;
return
;
}
}
assert
(
(
_currentEvent
.
original
??
_currentEvent
)
==
event
);
assert
(
_isSameEvent
(
_currentEvent
,
event
)
);
try
{
try
{
_firstRegisteredCallback
(
_currentEvent
);
_firstRegisteredCallback
(
_currentEvent
);
}
catch
(
exception
,
stack
)
{
}
catch
(
exception
,
stack
)
{
...
...
packages/flutter/test/gestures/pointer_signal_resolver_test.dart
View file @
f6a88d03
...
@@ -74,14 +74,29 @@ void main() {
...
@@ -74,14 +74,29 @@ void main() {
const
PointerScrollEvent
originalEvent
=
PointerScrollEvent
();
const
PointerScrollEvent
originalEvent
=
PointerScrollEvent
();
final
PointerSignalEvent
transformedEvent
=
originalEvent
final
PointerSignalEvent
transformedEvent
=
originalEvent
.
transformed
(
Matrix4
.
translationValues
(
10.0
,
20.0
,
0.0
));
.
transformed
(
Matrix4
.
translationValues
(
10.0
,
20.0
,
0.0
));
final
PointerSignalEvent
anotherTransformedEvent
=
originalEvent
.
transformed
(
Matrix4
.
translationValues
(
30.0
,
50.0
,
0.0
));
expect
(
originalEvent
,
isNot
(
same
(
transformedEvent
)));
expect
(
originalEvent
,
isNot
(
same
(
transformedEvent
)));
expect
(
transformedEvent
.
original
,
same
(
originalEvent
));
expect
(
transformedEvent
.
original
,
same
(
originalEvent
));
expect
(
originalEvent
,
isNot
(
same
(
anotherTransformedEvent
)));
expect
(
anotherTransformedEvent
.
original
,
same
(
originalEvent
));
final
List
<
PointerSignalEvent
>
events
=
<
PointerSignalEvent
>[];
final
List
<
PointerSignalEvent
>
events
=
<
PointerSignalEvent
>[];
resolver
.
register
(
transformedEvent
,
(
PointerSignalEvent
event
)
{
resolver
.
register
(
transformedEvent
,
(
PointerSignalEvent
event
)
{
events
.
add
(
event
);
events
.
add
(
event
);
});
});
// Registering a second transformed event should not throw an assertion.
expect
(()
{
resolver
.
register
(
anotherTransformedEvent
,
(
PointerSignalEvent
event
)
{
// This shouldn't be called because only the first registered callback is
// invoked.
events
.
add
(
event
);
});
},
returnsNormally
);
resolver
.
resolve
(
originalEvent
);
resolver
.
resolve
(
originalEvent
);
expect
(
events
.
single
,
same
(
transformedEvent
));
expect
(
events
.
single
,
same
(
transformedEvent
));
...
...
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