modal_bottom_sheet
modal_bottom_sheet copied to clipboard
Improve fidelity for CupertinoBottomSheet
This PR is a reworked version of #44 .
This PR adds the changes discussed in #41 and #138 .
The previousRoute is now wrapped with a CupertinoUserInterfaceLevel with CupertinoUserInterfaceLevel.elevated thus the CupertinoDynamicColors automatically uses the elevatedColor. The previousRoute is also wrapped with a new CupertinoTheme which enforces elevated colors and set primaryColor to gray which previously was done by the ColorFilter. This solution should result in a smoother animation.
The seconds change I made was to wrap the child of the modal with CupertinoUserInterfaceLevel and give it also an CupertinoUserInterfaceLevel.elevated.
It seems like that the animation doesn't work. I assume it's due to the changing context during the animation but can't say for sure.
I added a scaffoldBackgroundColor as a fix:
final scaffoldBackgroundColor =
CupertinoDynamicColor.withBrightnessAndContrast(
color: dynamicScaffoldBackgroundColor.color,
darkColor: dynamicScaffoldBackgroundColor.darkColor,
highContrastColor:
dynamicScaffoldBackgroundColor.highContrastColor,
darkHighContrastColor:
dynamicScaffoldBackgroundColor.darkHighContrastColor,
);
previousRouteTheme = previousRouteTheme.copyWith(
scaffoldBackgroundColor: ColorTween(
begin: scaffoldBackgroundColor.resolveFrom(context),
end: elevatedScaffoldBackgroundColor.resolveFrom(context),
).evaluate(animation),
);
It did not work with
final systemBackground = CupertinoDynamicColor.resolve(
cTheme.scaffoldBackgroundColor,
context,
);
I think that is is not animated because we are using CupertinoTheme widget, we should take care of the animation ourselves in a way similar to AnimatedTheme