Jaime Blasco
Committed by GitHub

Merge pull request #231 from bierbaumtim/clean-ios15-rebuild

Improve fidelity for CupertinoBottomSheet
@@ -4,7 +4,15 @@ @@ -4,7 +4,15 @@
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 -import 'package:flutter/cupertino.dart' show CupertinoTheme, CupertinoApp; 7 +import 'package:flutter/cupertino.dart'
  8 + show
  9 + CupertinoApp,
  10 + CupertinoColors,
  11 + CupertinoDynamicColor,
  12 + CupertinoTheme,
  13 + CupertinoThemeData,
  14 + CupertinoUserInterfaceLevel,
  15 + CupertinoUserInterfaceLevelData;
8 import 'package:flutter/material.dart' 16 import 'package:flutter/material.dart'
9 show 17 show
10 Colors, 18 Colors,
@@ -61,7 +69,10 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { @@ -61,7 +69,10 @@ class _CupertinoBottomSheetContainer extends StatelessWidget {
61 child: MediaQuery.removePadding( 69 child: MediaQuery.removePadding(
62 context: context, 70 context: context,
63 removeTop: true, //Remove top Safe Area 71 removeTop: true, //Remove top Safe Area
64 - child: child, 72 + child: CupertinoUserInterfaceLevel(
  73 + data: CupertinoUserInterfaceLevelData.elevated,
  74 + child: child,
  75 + ),
65 ), 76 ),
66 ), 77 ),
67 ), 78 ),
@@ -278,8 +289,23 @@ class _CupertinoModalTransition extends StatelessWidget { @@ -278,8 +289,23 @@ class _CupertinoModalTransition extends StatelessWidget {
278 scale: scale, 289 scale: scale,
279 alignment: Alignment.topCenter, 290 alignment: Alignment.topCenter,
280 child: ClipRRect( 291 child: ClipRRect(
281 - borderRadius: BorderRadius.circular(radius),  
282 - child: child), 292 + borderRadius: BorderRadius.circular(radius),
  293 + child: CupertinoUserInterfaceLevel(
  294 + data: CupertinoUserInterfaceLevelData.elevated,
  295 + child: Builder(
  296 + builder: (context) => CupertinoTheme(
  297 + data: createPreviousRouteTheme(
  298 + context,
  299 + curvedAnimation,
  300 + ),
  301 + child: CupertinoUserInterfaceLevel(
  302 + data: CupertinoUserInterfaceLevelData.base,
  303 + child: child!,
  304 + ),
  305 + ),
  306 + ),
  307 + ),
  308 + ),
283 ), 309 ),
284 ), 310 ),
285 ], 311 ],
@@ -288,6 +314,76 @@ class _CupertinoModalTransition extends StatelessWidget { @@ -288,6 +314,76 @@ class _CupertinoModalTransition extends StatelessWidget {
288 ), 314 ),
289 ); 315 );
290 } 316 }
  317 +
  318 + CupertinoThemeData createPreviousRouteTheme(
  319 + BuildContext context,
  320 + Animation<double> animation,
  321 + ) {
  322 + final cTheme = CupertinoTheme.of(context);
  323 +
  324 + final systemBackground = CupertinoDynamicColor.resolve(
  325 + cTheme.scaffoldBackgroundColor,
  326 + context,
  327 + );
  328 +
  329 + final barBackgroundColor = CupertinoDynamicColor.resolve(
  330 + cTheme.barBackgroundColor,
  331 + context,
  332 + );
  333 +
  334 + var previousRouteTheme = cTheme;
  335 +
  336 + if (cTheme.scaffoldBackgroundColor is CupertinoDynamicColor) {
  337 + final dynamicScaffoldBackgroundColor =
  338 + cTheme.scaffoldBackgroundColor as CupertinoDynamicColor;
  339 +
  340 + /// BackgroundColor for the previous route with forced using
  341 + /// of the elevated colors
  342 + final elevatedScaffoldBackgroundColor =
  343 + CupertinoDynamicColor.withBrightnessAndContrast(
  344 + color: dynamicScaffoldBackgroundColor.elevatedColor,
  345 + darkColor: dynamicScaffoldBackgroundColor.darkElevatedColor,
  346 + highContrastColor:
  347 + dynamicScaffoldBackgroundColor.highContrastElevatedColor,
  348 + darkHighContrastColor:
  349 + dynamicScaffoldBackgroundColor.darkHighContrastElevatedColor,
  350 + );
  351 +
  352 + previousRouteTheme = previousRouteTheme.copyWith(
  353 + scaffoldBackgroundColor: ColorTween(
  354 + begin: systemBackground,
  355 + end: elevatedScaffoldBackgroundColor.resolveFrom(context),
  356 + ).evaluate(animation),
  357 + primaryColor: CupertinoColors.placeholderText.resolveFrom(context),
  358 + );
  359 + }
  360 +
  361 + if (cTheme.barBackgroundColor is CupertinoDynamicColor) {
  362 + final dynamicBarBackgroundColor =
  363 + cTheme.barBackgroundColor as CupertinoDynamicColor;
  364 +
  365 + /// NavigationBarColor for the previous route with forced using
  366 + /// of the elevated colors
  367 + final elevatedBarBackgroundColor =
  368 + CupertinoDynamicColor.withBrightnessAndContrast(
  369 + color: dynamicBarBackgroundColor.elevatedColor,
  370 + darkColor: dynamicBarBackgroundColor.darkElevatedColor,
  371 + highContrastColor: dynamicBarBackgroundColor.highContrastElevatedColor,
  372 + darkHighContrastColor:
  373 + dynamicBarBackgroundColor.darkHighContrastElevatedColor,
  374 + );
  375 +
  376 + previousRouteTheme = previousRouteTheme.copyWith(
  377 + barBackgroundColor: ColorTween(
  378 + begin: barBackgroundColor,
  379 + end: elevatedBarBackgroundColor.resolveFrom(context),
  380 + ).evaluate(animation),
  381 + primaryColor: CupertinoColors.placeholderText.resolveFrom(context),
  382 + );
  383 + }
  384 +
  385 + return previousRouteTheme;
  386 + }
291 } 387 }
292 388
293 class CupertinoScaffoldInheirted extends InheritedWidget { 389 class CupertinoScaffoldInheirted extends InheritedWidget {