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
ff347bfd
Unverified
Commit
ff347bfd
authored
Dec 21, 2022
by
Taha Tesser
Committed by
GitHub
Dec 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `InkRipple` doesn't respect `rectCallback` when rendering ink circle (#117395)
parent
1970bc91
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
1 deletion
+91
-1
ink_ripple.dart
packages/flutter/lib/src/material/ink_ripple.dart
+5
-1
ink_paint_test.dart
packages/flutter/test/material/ink_paint_test.dart
+86
-0
No files found.
packages/flutter/lib/src/material/ink_ripple.dart
View file @
ff347bfd
...
@@ -232,10 +232,14 @@ class InkRipple extends InteractiveInkFeature {
...
@@ -232,10 +232,14 @@ class InkRipple extends InteractiveInkFeature {
void
paintFeature
(
Canvas
canvas
,
Matrix4
transform
)
{
void
paintFeature
(
Canvas
canvas
,
Matrix4
transform
)
{
final
int
alpha
=
_fadeInController
.
isAnimating
?
_fadeIn
.
value
:
_fadeOut
.
value
;
final
int
alpha
=
_fadeInController
.
isAnimating
?
_fadeIn
.
value
:
_fadeOut
.
value
;
final
Paint
paint
=
Paint
()..
color
=
color
.
withAlpha
(
alpha
);
final
Paint
paint
=
Paint
()..
color
=
color
.
withAlpha
(
alpha
);
Rect
?
rect
;
if
(
_clipCallback
!=
null
)
{
rect
=
_clipCallback
!();
}
// Splash moves to the center of the reference box.
// Splash moves to the center of the reference box.
final
Offset
center
=
Offset
.
lerp
(
final
Offset
center
=
Offset
.
lerp
(
_position
,
_position
,
referenceBox
.
size
.
center
(
Offset
.
zero
),
re
ct
!=
null
?
rect
.
center
:
re
ferenceBox
.
size
.
center
(
Offset
.
zero
),
Curves
.
ease
.
transform
(
_radiusController
.
value
),
Curves
.
ease
.
transform
(
_radiusController
.
value
),
)!;
)!;
paintInkCircle
(
paintInkCircle
(
...
...
packages/flutter/test/material/ink_paint_test.dart
View file @
ff347bfd
...
@@ -445,4 +445,90 @@ void main() {
...
@@ -445,4 +445,90 @@ void main() {
throw
'Expected: paint.color.alpha == 0, found:
${paint.color.alpha}
'
;
throw
'Expected: paint.color.alpha == 0, found:
${paint.color.alpha}
'
;
}));
}));
});
});
testWidgets
(
'Custom rectCallback renders an ink splash from its center'
,
(
WidgetTester
tester
)
async
{
const
Color
splashColor
=
Color
(
0xff00ff00
);
Widget
buildWidget
({
InteractiveInkFeatureFactory
?
splashFactory
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
SizedBox
(
width:
100.0
,
height:
200.0
,
child:
InkResponse
(
splashColor:
splashColor
,
containedInkWell:
true
,
highlightShape:
BoxShape
.
rectangle
,
splashFactory:
splashFactory
,
onTap:
()
{
},
),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildWidget
());
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
SizedBox
));
TestGesture
gesture
=
await
tester
.
startGesture
(
center
);
await
tester
.
pump
();
// start gesture
await
tester
.
pumpAndSettle
();
// Finish rendering ink splash.
RenderBox
box
=
Material
.
of
(
tester
.
element
(
find
.
byType
(
InkResponse
)))
as
RenderBox
;
expect
(
box
,
paints
..
circle
(
x:
50.0
,
y:
100.0
,
color:
splashColor
)
);
await
gesture
.
up
();
await
tester
.
pumpWidget
(
buildWidget
(
splashFactory:
_InkRippleFactory
()));
await
tester
.
pumpAndSettle
();
// Finish rendering ink splash.
gesture
=
await
tester
.
startGesture
(
center
);
await
tester
.
pump
();
// start gesture
await
tester
.
pumpAndSettle
();
// Finish rendering ink splash.
box
=
Material
.
of
(
tester
.
element
(
find
.
byType
(
InkResponse
)))
as
RenderBox
;
expect
(
box
,
paints
..
circle
(
x:
50.0
,
y:
50.0
,
color:
splashColor
)
);
});
}
class
_InkRippleFactory
extends
InteractiveInkFeatureFactory
{
@override
InteractiveInkFeature
create
({
required
MaterialInkController
controller
,
required
RenderBox
referenceBox
,
required
Offset
position
,
required
Color
color
,
required
TextDirection
textDirection
,
bool
containedInkWell
=
false
,
RectCallback
?
rectCallback
,
BorderRadius
?
borderRadius
,
ShapeBorder
?
customBorder
,
double
?
radius
,
VoidCallback
?
onRemoved
,
})
{
return
InkRipple
(
controller:
controller
,
referenceBox:
referenceBox
,
position:
position
,
color:
color
,
containedInkWell:
containedInkWell
,
rectCallback:
()
=>
Offset
.
zero
&
const
Size
(
100
,
100
),
borderRadius:
borderRadius
,
customBorder:
customBorder
,
radius:
radius
,
onRemoved:
onRemoved
,
textDirection:
textDirection
,
);
}
}
}
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