mirror of
https://github.com/flutter/flutter
synced 2024-08-25 02:46:31 +00:00
Fix Cupertino Context Menu Container to Remove White Corners (#144883)
Fixes a visual glitch when CupertinoContextMenu is on a non-white background.
This commit is contained in:
parent
122849311f
commit
f91614a4b9
|
@ -172,11 +172,9 @@ class CupertinoContextMenu extends StatefulWidget {
|
||||||
///
|
///
|
||||||
/// final Animation<Decoration> boxDecorationAnimation = DecorationTween(
|
/// final Animation<Decoration> boxDecorationAnimation = DecorationTween(
|
||||||
/// begin: const BoxDecoration(
|
/// begin: const BoxDecoration(
|
||||||
/// color: Color(0xFFFFFFFF),
|
|
||||||
/// boxShadow: <BoxShadow>[],
|
/// boxShadow: <BoxShadow>[],
|
||||||
/// ),
|
/// ),
|
||||||
/// end: const BoxDecoration(
|
/// end: const BoxDecoration(
|
||||||
/// color: Color(0xFFFFFFFF),
|
|
||||||
/// boxShadow: CupertinoContextMenu.kEndBoxShadow,
|
/// boxShadow: CupertinoContextMenu.kEndBoxShadow,
|
||||||
/// ),
|
/// ),
|
||||||
/// ).animate(
|
/// ).animate(
|
||||||
|
@ -279,11 +277,9 @@ class CupertinoContextMenu extends StatefulWidget {
|
||||||
///
|
///
|
||||||
/// final Animation<Decoration> boxDecorationAnimation = DecorationTween(
|
/// final Animation<Decoration> boxDecorationAnimation = DecorationTween(
|
||||||
/// begin: const BoxDecoration(
|
/// begin: const BoxDecoration(
|
||||||
/// color: Color(0xFFFFFFFF),
|
|
||||||
/// boxShadow: <BoxShadow>[],
|
/// boxShadow: <BoxShadow>[],
|
||||||
/// ),
|
/// ),
|
||||||
/// end: const BoxDecoration(
|
/// end: const BoxDecoration(
|
||||||
/// color: Color(0xFFFFFFFF),
|
|
||||||
/// boxShadow: CupertinoContextMenu.kEndBoxShadow,
|
/// boxShadow: CupertinoContextMenu.kEndBoxShadow,
|
||||||
/// ),
|
/// ),
|
||||||
/// ).animate(
|
/// ).animate(
|
||||||
|
@ -676,11 +672,9 @@ class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin
|
||||||
|
|
||||||
_boxDecoration = DecorationTween(
|
_boxDecoration = DecorationTween(
|
||||||
begin: const BoxDecoration(
|
begin: const BoxDecoration(
|
||||||
color: Color(0xFFFFFFFF),
|
|
||||||
boxShadow: <BoxShadow>[],
|
boxShadow: <BoxShadow>[],
|
||||||
),
|
),
|
||||||
end: const BoxDecoration(
|
end: const BoxDecoration(
|
||||||
color: Color(0xFFFFFFFF),
|
|
||||||
boxShadow: _endBoxShadow,
|
boxShadow: _endBoxShadow,
|
||||||
),
|
),
|
||||||
).animate(CurvedAnimation(
|
).animate(CurvedAnimation(
|
||||||
|
|
|
@ -241,6 +241,61 @@ void main() {
|
||||||
expect(findStatic(), findsOneWidget);
|
expect(findStatic(), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('_DecoyChild preserves the child color', (WidgetTester tester) async {
|
||||||
|
final Widget child = getChild();
|
||||||
|
await tester.pumpWidget(CupertinoApp(
|
||||||
|
home: CupertinoPageScaffold(
|
||||||
|
backgroundColor: CupertinoColors.black,
|
||||||
|
child: MediaQuery(
|
||||||
|
data: const MediaQueryData(size: Size(800, 600)),
|
||||||
|
child: Center(
|
||||||
|
child: CupertinoContextMenu(
|
||||||
|
actions: const <CupertinoContextMenuAction>[
|
||||||
|
CupertinoContextMenuAction(
|
||||||
|
child: Text('CupertinoContextMenuAction'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: child
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Expect no _DecoyChild to be present before the gesture.
|
||||||
|
final Finder decoyChild = find
|
||||||
|
.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DecoyChild');
|
||||||
|
expect(decoyChild, findsNothing);
|
||||||
|
|
||||||
|
// Start press gesture on the child.
|
||||||
|
final Rect childRect = tester.getRect(find.byWidget(child));
|
||||||
|
final TestGesture gesture = await tester.startGesture(childRect.center);
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// Find the _DecoyChild by runtimeType,
|
||||||
|
// find the Container descendant with the BoxDecoration,
|
||||||
|
// then read the boxDecoration property.
|
||||||
|
final Finder decoyChildDescendant = find.descendant(
|
||||||
|
of: decoyChild,
|
||||||
|
matching: find.byType(Container));
|
||||||
|
final BoxDecoration? boxDecoration = (tester.firstWidget(decoyChildDescendant) as Container).decoration as BoxDecoration?;
|
||||||
|
const List<Color?> expectedColors = <Color?>[null, Color(0x00000000)];
|
||||||
|
|
||||||
|
// `Color(0x00000000)` -> Is `Colors.transparent`.
|
||||||
|
// `null` -> Default when no color argument is given in `BoxDecoration`.
|
||||||
|
// Any other color won't preserve the child's property.
|
||||||
|
expect(expectedColors, contains(boxDecoration?.color));
|
||||||
|
|
||||||
|
// End the gesture.
|
||||||
|
await gesture.up();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Expect no _DecoyChild to be present after ending the gesture.
|
||||||
|
final Finder decoyChildAfterEnding = find
|
||||||
|
.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DecoyChild');
|
||||||
|
expect(decoyChildAfterEnding, findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('CupertinoContextMenu with a basic builder opens and closes the same as when providing a child', (WidgetTester tester) async {
|
testWidgets('CupertinoContextMenu with a basic builder opens and closes the same as when providing a child', (WidgetTester tester) async {
|
||||||
final Widget child = getChild();
|
final Widget child = getChild();
|
||||||
await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) {
|
await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) {
|
||||||
|
|
Loading…
Reference in a new issue