Unverified Commit f91614a4 authored by Dhikshith's avatar Dhikshith Committed by GitHub

Fix Cupertino Context Menu Container to Remove White Corners (#144883)

Fixes a visual glitch when CupertinoContextMenu is on a non-white background.
parent 12284931
......@@ -172,11 +172,9 @@ class CupertinoContextMenu extends StatefulWidget {
///
/// final Animation<Decoration> boxDecorationAnimation = DecorationTween(
/// begin: const BoxDecoration(
/// color: Color(0xFFFFFFFF),
/// boxShadow: <BoxShadow>[],
/// ),
/// end: const BoxDecoration(
/// color: Color(0xFFFFFFFF),
/// boxShadow: CupertinoContextMenu.kEndBoxShadow,
/// ),
/// ).animate(
......@@ -279,11 +277,9 @@ class CupertinoContextMenu extends StatefulWidget {
///
/// final Animation<Decoration> boxDecorationAnimation = DecorationTween(
/// begin: const BoxDecoration(
/// color: Color(0xFFFFFFFF),
/// boxShadow: <BoxShadow>[],
/// ),
/// end: const BoxDecoration(
/// color: Color(0xFFFFFFFF),
/// boxShadow: CupertinoContextMenu.kEndBoxShadow,
/// ),
/// ).animate(
......@@ -676,11 +672,9 @@ class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin
_boxDecoration = DecorationTween(
begin: const BoxDecoration(
color: Color(0xFFFFFFFF),
boxShadow: <BoxShadow>[],
),
end: const BoxDecoration(
color: Color(0xFFFFFFFF),
boxShadow: _endBoxShadow,
),
).animate(CurvedAnimation(
......
......@@ -241,6 +241,61 @@ void main() {
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 {
final Widget child = getChild();
await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment