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
3aba15f9
Unverified
Commit
3aba15f9
authored
Nov 02, 2020
by
Michael Goderbauer
Committed by
GitHub
Nov 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move to onTapUp (#69422)
parent
22f3cd8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
17 deletions
+70
-17
ink_well.dart
packages/flutter/lib/src/material/ink_well.dart
+26
-17
ink_well_test.dart
packages/flutter/test/material/ink_well_test.dart
+44
-0
No files found.
packages/flutter/lib/src/material/ink_well.dart
View file @
3aba15f9
...
...
@@ -732,11 +732,14 @@ class _InkResponseState extends State<_InkResponseStateWidget>
InteractiveInkFeature
?
_currentSplash
;
bool
_hovering
=
false
;
final
Map
<
_HighlightType
,
InkHighlight
?>
_highlights
=
<
_HighlightType
,
InkHighlight
?>{};
late
Map
<
Type
,
Action
<
Intent
>>
_actionMap
;
late
final
Map
<
Type
,
Action
<
Intent
>>
_actionMap
=
<
Type
,
Action
<
Intent
>>{
ActivateIntent:
CallbackAction
<
ActivateIntent
>(
onInvoke:
_simulateTap
),
};
bool
get
highlightsExist
=>
_highlights
.
values
.
where
((
InkHighlight
?
highlight
)
=>
highlight
!=
null
).
isNotEmpty
;
final
ObserverList
<
_ParentInkResponseState
>
_activeChildren
=
ObserverList
<
_ParentInkResponseState
>();
@override
void
markChildInkResponsePressed
(
_ParentInkResponseState
childState
,
bool
value
)
{
assert
(
childState
!=
null
);
...
...
@@ -753,17 +756,19 @@ class _InkResponseState extends State<_InkResponseStateWidget>
}
bool
get
_anyChildInkResponsePressed
=>
_activeChildren
.
isNotEmpty
;
void
_handleAction
(
ActivateIntent
intent
)
{
void
_simulateTap
([
ActivateIntent
?
intent
])
{
_startSplash
(
context:
context
);
_handleTap
();
}
void
_simulateLongPress
()
{
_startSplash
(
context:
context
);
_handle
Tap
(
context
);
_handle
LongPress
(
);
}
@override
void
initState
()
{
super
.
initState
();
_actionMap
=
<
Type
,
Action
<
Intent
>>{
ActivateIntent:
CallbackAction
<
ActivateIntent
>(
onInvoke:
_handleAction
),
};
FocusManager
.
instance
.
addHighlightModeListener
(
_handleFocusHighlightModeChange
);
}
...
...
@@ -975,7 +980,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
updateHighlight
(
_HighlightType
.
pressed
,
value:
true
);
}
void
_handleTap
(
BuildContext
context
)
{
void
_handleTap
()
{
_currentSplash
?.
confirm
();
_currentSplash
=
null
;
updateHighlight
(
_HighlightType
.
pressed
,
value:
false
);
...
...
@@ -1002,7 +1007,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
widget
.
onDoubleTap
!();
}
void
_handleLongPress
(
BuildContext
context
)
{
void
_handleLongPress
()
{
_currentSplash
?.
confirm
();
_currentSplash
=
null
;
if
(
widget
.
onLongPress
!=
null
)
{
...
...
@@ -1096,15 +1101,19 @@ class _InkResponseState extends State<_InkResponseStateWidget>
cursor:
effectiveMouseCursor
,
onEnter:
_handleMouseEnter
,
onExit:
_handleMouseExit
,
child:
GestureDetector
(
onTapDown:
enabled
?
_handleTapDown
:
null
,
onTap:
enabled
?
()
=>
_handleTap
(
context
)
:
null
,
onTapCancel:
enabled
?
_handleTapCancel
:
null
,
onDoubleTap:
widget
.
onDoubleTap
!=
null
?
_handleDoubleTap
:
null
,
onLongPress:
widget
.
onLongPress
!=
null
?
()
=>
_handleLongPress
(
context
)
:
null
,
behavior:
HitTestBehavior
.
opaque
,
excludeFromSemantics:
widget
.
excludeFromSemantics
,
child:
widget
.
child
,
child:
Semantics
(
onTap:
widget
.
excludeFromSemantics
||
widget
.
onTap
==
null
?
null
:
_simulateTap
,
onLongPress:
widget
.
excludeFromSemantics
||
widget
.
onLongPress
==
null
?
null
:
_simulateLongPress
,
child:
GestureDetector
(
onTapDown:
enabled
?
_handleTapDown
:
null
,
onTap:
enabled
?
_handleTap
:
null
,
onTapCancel:
enabled
?
_handleTapCancel
:
null
,
onDoubleTap:
widget
.
onDoubleTap
!=
null
?
_handleDoubleTap
:
null
,
onLongPress:
widget
.
onLongPress
!=
null
?
_handleLongPress
:
null
,
behavior:
HitTestBehavior
.
opaque
,
excludeFromSemantics:
true
,
child:
widget
.
child
,
),
),
),
),
...
...
packages/flutter/test/material/ink_well_test.dart
View file @
3aba15f9
...
...
@@ -1288,4 +1288,48 @@ void main() {
await
tester
.
pumpWidget
(
buildFrame
(
enabled:
false
));
await
tester
.
pumpAndSettle
();
});
testWidgets
(
'InkWell does not attach semantics handler for onTap if it was not provided an onTap handler'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
InkWell
(
onLongPress:
()
{
},
child:
const
Text
(
'Foo'
),
),
),
),
));
expect
(
tester
.
getSemantics
(
find
.
bySemanticsLabel
(
'Foo'
)),
matchesSemantics
(
label:
'Foo'
,
hasTapAction:
false
,
hasLongPressAction:
true
,
isFocusable:
true
,
textDirection:
TextDirection
.
ltr
,
));
// Add tap handler and confirm addition to semantic actions.
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
InkWell
(
onLongPress:
()
{
},
onTap:
()
{
},
child:
const
Text
(
'Foo'
),
),
),
),
));
expect
(
tester
.
getSemantics
(
find
.
bySemanticsLabel
(
'Foo'
)),
matchesSemantics
(
label:
'Foo'
,
hasTapAction:
true
,
hasLongPressAction:
true
,
isFocusable:
true
,
textDirection:
TextDirection
.
ltr
,
));
});
}
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