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
e1eb1b9e
Unverified
Commit
e1eb1b9e
authored
Mar 16, 2023
by
Chinmoy
Committed by
GitHub
Mar 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added onSecondaryTap in InkWell. (#119058)
Exposes onSecondaryTap in InkWell.
parent
055769e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
2 deletions
+116
-2
ink_well.dart
packages/flutter/lib/src/material/ink_well.dart
+79
-2
ink_well_test.dart
packages/flutter/test/material/ink_well_test.dart
+37
-0
No files found.
packages/flutter/lib/src/material/ink_well.dart
View file @
e1eb1b9e
...
...
@@ -294,6 +294,10 @@ class InkResponse extends StatelessWidget {
this
.
onTapCancel
,
this
.
onDoubleTap
,
this
.
onLongPress
,
this
.
onSecondaryTap
,
this
.
onSecondaryTapUp
,
this
.
onSecondaryTapDown
,
this
.
onSecondaryTapCancel
,
this
.
onHighlightChanged
,
this
.
onHover
,
this
.
mouseCursor
,
...
...
@@ -342,6 +346,21 @@ class InkResponse extends StatelessWidget {
/// Called when the user long-presses on this part of the material.
final
GestureLongPressCallback
?
onLongPress
;
/// Called when the user taps this part of the material with a secondary button.
final
GestureTapCallback
?
onSecondaryTap
;
/// Called when the user taps down on this part of the material with a
/// secondary button.
final
GestureTapDownCallback
?
onSecondaryTapDown
;
/// Called when the user releases a secondary button tap that was started on
/// this part of the material. [onSecondaryTap] is called immediately after.
final
GestureTapUpCallback
?
onSecondaryTapUp
;
/// Called when the user cancels a secondary button tap that was started on
/// this part of the material.
final
GestureTapCallback
?
onSecondaryTapCancel
;
/// Called when this part of the material either becomes highlighted or stops
/// being highlighted.
///
...
...
@@ -599,6 +618,10 @@ class InkResponse extends StatelessWidget {
onTapCancel:
onTapCancel
,
onDoubleTap:
onDoubleTap
,
onLongPress:
onLongPress
,
onSecondaryTap:
onSecondaryTap
,
onSecondaryTapUp:
onSecondaryTapUp
,
onSecondaryTapDown:
onSecondaryTapDown
,
onSecondaryTapCancel:
onSecondaryTapCancel
,
onHighlightChanged:
onHighlightChanged
,
onHover:
onHover
,
mouseCursor:
mouseCursor
,
...
...
@@ -651,6 +674,10 @@ class _InkResponseStateWidget extends StatefulWidget {
this
.
onTapCancel
,
this
.
onDoubleTap
,
this
.
onLongPress
,
this
.
onSecondaryTap
,
this
.
onSecondaryTapUp
,
this
.
onSecondaryTapDown
,
this
.
onSecondaryTapCancel
,
this
.
onHighlightChanged
,
this
.
onHover
,
this
.
mouseCursor
,
...
...
@@ -684,6 +711,10 @@ class _InkResponseStateWidget extends StatefulWidget {
final
GestureTapCallback
?
onTapCancel
;
final
GestureTapCallback
?
onDoubleTap
;
final
GestureLongPressCallback
?
onLongPress
;
final
GestureTapCallback
?
onSecondaryTap
;
final
GestureTapUpCallback
?
onSecondaryTapUp
;
final
GestureTapDownCallback
?
onSecondaryTapDown
;
final
GestureTapCallback
?
onSecondaryTapCancel
;
final
ValueChanged
<
bool
>?
onHighlightChanged
;
final
ValueChanged
<
bool
>?
onHover
;
final
MouseCursor
?
mouseCursor
;
...
...
@@ -722,6 +753,10 @@ class _InkResponseStateWidget extends StatefulWidget {
if
(
onTapDown
!=
null
)
'tap down'
,
if
(
onTapUp
!=
null
)
'tap up'
,
if
(
onTapCancel
!=
null
)
'tap cancel'
,
if
(
onSecondaryTap
!=
null
)
'secondary tap'
,
if
(
onSecondaryTapUp
!=
null
)
'secondary tap up'
,
if
(
onSecondaryTapDown
!=
null
)
'secondary tap down'
,
if
(
onSecondaryTapCancel
!=
null
)
'secondary tap cancel'
];
properties
.
add
(
IterableProperty
<
String
>(
'gestures'
,
gestures
,
ifEmpty:
'<none>'
));
properties
.
add
(
DiagnosticsProperty
<
MouseCursor
>(
'mouseCursor'
,
mouseCursor
));
...
...
@@ -1040,11 +1075,15 @@ class _InkResponseState extends State<_InkResponseStateWidget>
widget
.
onFocusChange
?.
call
(
hasFocus
);
}
void
handleTapDown
(
TapDownDetails
details
)
{
void
handle
Any
TapDown
(
TapDownDetails
details
)
{
if
(
_anyChildInkResponsePressed
)
{
return
;
}
_startNewSplash
(
details:
details
);
}
void
handleTapDown
(
TapDownDetails
details
)
{
handleAnyTapDown
(
details
);
widget
.
onTapDown
?.
call
(
details
);
}
...
...
@@ -1052,6 +1091,15 @@ class _InkResponseState extends State<_InkResponseStateWidget>
widget
.
onTapUp
?.
call
(
details
);
}
void
handleSecondaryTapDown
(
TapDownDetails
details
)
{
handleAnyTapDown
(
details
);
widget
.
onSecondaryTapDown
?.
call
(
details
);
}
void
handleSecondaryTapUp
(
TapUpDetails
details
)
{
widget
.
onSecondaryTapUp
?.
call
(
details
);
}
void
_startNewSplash
({
TapDownDetails
?
details
,
BuildContext
?
context
})
{
assert
(
details
!=
null
||
context
!=
null
);
...
...
@@ -1110,6 +1158,20 @@ class _InkResponseState extends State<_InkResponseStateWidget>
}
}
void
handleSecondaryTap
()
{
_currentSplash
?.
confirm
();
_currentSplash
=
null
;
updateHighlight
(
_HighlightType
.
pressed
,
value:
false
);
widget
.
onSecondaryTap
?.
call
();
}
void
handleSecondaryTapCancel
()
{
_currentSplash
?.
cancel
();
_currentSplash
=
null
;
widget
.
onSecondaryTapCancel
?.
call
();
updateHighlight
(
_HighlightType
.
pressed
,
value:
false
);
}
@override
void
deactivate
()
{
if
(
_splashes
!=
null
)
{
...
...
@@ -1130,7 +1192,14 @@ class _InkResponseState extends State<_InkResponseStateWidget>
}
bool
isWidgetEnabled
(
_InkResponseStateWidget
widget
)
{
return
widget
.
onTap
!=
null
||
widget
.
onDoubleTap
!=
null
||
widget
.
onLongPress
!=
null
||
widget
.
onTapDown
!=
null
;
return
widget
.
onTap
!=
null
||
widget
.
onDoubleTap
!=
null
||
widget
.
onLongPress
!=
null
||
widget
.
onTapUp
!=
null
||
widget
.
onTapDown
!=
null
||
widget
.
onSecondaryTap
!=
null
||
widget
.
onSecondaryTapUp
!=
null
||
widget
.
onSecondaryTapDown
!=
null
;
}
bool
get
enabled
=>
isWidgetEnabled
(
widget
);
...
...
@@ -1220,6 +1289,10 @@ class _InkResponseState extends State<_InkResponseStateWidget>
onTapCancel:
enabled
?
handleTapCancel
:
null
,
onDoubleTap:
widget
.
onDoubleTap
!=
null
?
handleDoubleTap
:
null
,
onLongPress:
widget
.
onLongPress
!=
null
?
handleLongPress
:
null
,
onSecondaryTapDown:
enabled
?
handleSecondaryTapDown
:
null
,
onSecondaryTapUp:
enabled
?
handleSecondaryTapUp:
null
,
onSecondaryTap:
enabled
?
handleSecondaryTap
:
null
,
onSecondaryTapCancel:
enabled
?
handleSecondaryTapCancel
:
null
,
behavior:
HitTestBehavior
.
opaque
,
excludeFromSemantics:
true
,
child:
widget
.
child
,
...
...
@@ -1326,6 +1399,10 @@ class InkWell extends InkResponse {
super
.
onTapDown
,
super
.
onTapUp
,
super
.
onTapCancel
,
super
.
onSecondaryTap
,
super
.
onSecondaryTapUp
,
super
.
onSecondaryTapDown
,
super
.
onSecondaryTapCancel
,
super
.
onHighlightChanged
,
super
.
onHover
,
super
.
mouseCursor
,
...
...
packages/flutter/test/material/ink_well_test.dart
View file @
e1eb1b9e
...
...
@@ -2015,4 +2015,41 @@ testWidgets('InkResponse radius can be updated', (WidgetTester tester) async {
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
expect
(
inkFeatures
,
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
350.0
,
250.0
,
450.0
,
350.0
),
color:
const
Color
(
0x8000ff00
)));
});
testWidgets
(
'InkWell secondary tap test'
,
(
WidgetTester
tester
)
async
{
final
List
<
String
>
log
=
<
String
>[];
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
InkWell
(
onSecondaryTap:
()
{
log
.
add
(
'secondary-tap'
);
},
onSecondaryTapDown:
(
TapDownDetails
details
)
{
log
.
add
(
'secondary-tap-down'
);
},
onSecondaryTapUp:
(
TapUpDetails
details
)
{
log
.
add
(
'secondary-tap-up'
);
},
onSecondaryTapCancel:
()
{
log
.
add
(
'secondary-tap-cancel'
);
},
),
),
),
));
await
tester
.
tap
(
find
.
byType
(
InkWell
),
pointer:
1
,
buttons:
kSecondaryButton
);
expect
(
log
,
equals
(<
String
>[
'secondary-tap-down'
,
'secondary-tap-up'
,
'secondary-tap'
]));
log
.
clear
();
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
InkWell
)),
pointer:
2
,
buttons:
kSecondaryButton
);
await
gesture
.
moveTo
(
const
Offset
(
100
,
100
));
await
gesture
.
up
();
expect
(
log
,
equals
(<
String
>[
'secondary-tap-down'
,
'secondary-tap-cancel'
]));
});
}
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