Jaime Blasco
Committed by GitHub

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

Improve fidelity for CupertinoBottomSheet
... ... @@ -4,7 +4,15 @@
import 'dart:async';
import 'package:flutter/cupertino.dart' show CupertinoTheme, CupertinoApp;
import 'package:flutter/cupertino.dart'
show
CupertinoApp,
CupertinoColors,
CupertinoDynamicColor,
CupertinoTheme,
CupertinoThemeData,
CupertinoUserInterfaceLevel,
CupertinoUserInterfaceLevelData;
import 'package:flutter/material.dart'
show
Colors,
... ... @@ -61,7 +69,10 @@ class _CupertinoBottomSheetContainer extends StatelessWidget {
child: MediaQuery.removePadding(
context: context,
removeTop: true, //Remove top Safe Area
child: child,
child: CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevated,
child: child,
),
),
),
),
... ... @@ -278,8 +289,23 @@ class _CupertinoModalTransition extends StatelessWidget {
scale: scale,
alignment: Alignment.topCenter,
child: ClipRRect(
borderRadius: BorderRadius.circular(radius),
child: child),
borderRadius: BorderRadius.circular(radius),
child: CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevated,
child: Builder(
builder: (context) => CupertinoTheme(
data: createPreviousRouteTheme(
context,
curvedAnimation,
),
child: CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.base,
child: child!,
),
),
),
),
),
),
),
],
... ... @@ -288,6 +314,76 @@ class _CupertinoModalTransition extends StatelessWidget {
),
);
}
CupertinoThemeData createPreviousRouteTheme(
BuildContext context,
Animation<double> animation,
) {
final cTheme = CupertinoTheme.of(context);
final systemBackground = CupertinoDynamicColor.resolve(
cTheme.scaffoldBackgroundColor,
context,
);
final barBackgroundColor = CupertinoDynamicColor.resolve(
cTheme.barBackgroundColor,
context,
);
var previousRouteTheme = cTheme;
if (cTheme.scaffoldBackgroundColor is CupertinoDynamicColor) {
final dynamicScaffoldBackgroundColor =
cTheme.scaffoldBackgroundColor as CupertinoDynamicColor;
/// BackgroundColor for the previous route with forced using
/// of the elevated colors
final elevatedScaffoldBackgroundColor =
CupertinoDynamicColor.withBrightnessAndContrast(
color: dynamicScaffoldBackgroundColor.elevatedColor,
darkColor: dynamicScaffoldBackgroundColor.darkElevatedColor,
highContrastColor:
dynamicScaffoldBackgroundColor.highContrastElevatedColor,
darkHighContrastColor:
dynamicScaffoldBackgroundColor.darkHighContrastElevatedColor,
);
previousRouteTheme = previousRouteTheme.copyWith(
scaffoldBackgroundColor: ColorTween(
begin: systemBackground,
end: elevatedScaffoldBackgroundColor.resolveFrom(context),
).evaluate(animation),
primaryColor: CupertinoColors.placeholderText.resolveFrom(context),
);
}
if (cTheme.barBackgroundColor is CupertinoDynamicColor) {
final dynamicBarBackgroundColor =
cTheme.barBackgroundColor as CupertinoDynamicColor;
/// NavigationBarColor for the previous route with forced using
/// of the elevated colors
final elevatedBarBackgroundColor =
CupertinoDynamicColor.withBrightnessAndContrast(
color: dynamicBarBackgroundColor.elevatedColor,
darkColor: dynamicBarBackgroundColor.darkElevatedColor,
highContrastColor: dynamicBarBackgroundColor.highContrastElevatedColor,
darkHighContrastColor:
dynamicBarBackgroundColor.darkHighContrastElevatedColor,
);
previousRouteTheme = previousRouteTheme.copyWith(
barBackgroundColor: ColorTween(
begin: barBackgroundColor,
end: elevatedBarBackgroundColor.resolveFrom(context),
).evaluate(animation),
primaryColor: CupertinoColors.placeholderText.resolveFrom(context),
);
}
return previousRouteTheme;
}
}
class CupertinoScaffoldInheirted extends InheritedWidget {
... ...