Unverified Commit 62db22d1 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

CupertinoDynamicColor improvements (#44317)

parent 604f1761
...@@ -165,11 +165,11 @@ class _ListItem extends StatelessWidget { ...@@ -165,11 +165,11 @@ class _ListItem extends StatelessWidget {
Container( Container(
width: 38.0, width: 38.0,
child: called child: called
? const Align( ? Align(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
child: Icon( child: Icon(
CupertinoIcons.phone_solid, CupertinoIcons.phone_solid,
color: CupertinoColors.inactiveGray, color: CupertinoColors.inactiveGray.resolveFrom(context),
size: 18.0, size: 18.0,
), ),
) )
...@@ -203,10 +203,10 @@ class _ListItem extends StatelessWidget { ...@@ -203,10 +203,10 @@ class _ListItem extends StatelessWidget {
place, place,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: const TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
letterSpacing: -0.24, letterSpacing: -0.24,
color: CupertinoColors.inactiveGray, color: CupertinoColors.inactiveGray.resolveFrom(context),
), ),
), ),
], ],
...@@ -214,8 +214,8 @@ class _ListItem extends StatelessWidget { ...@@ -214,8 +214,8 @@ class _ListItem extends StatelessWidget {
), ),
Text( Text(
date, date,
style: const TextStyle( style: TextStyle(
color: CupertinoColors.inactiveGray, color: CupertinoColors.inactiveGray.resolveFrom(context),
fontSize: 15.0, fontSize: 15.0,
letterSpacing: -0.41, letterSpacing: -0.41,
), ),
......
...@@ -289,7 +289,7 @@ class _CupertinoAppState extends State<CupertinoApp> { ...@@ -289,7 +289,7 @@ class _CupertinoAppState extends State<CupertinoApp> {
builder: widget.builder, builder: widget.builder,
title: widget.title, title: widget.title,
onGenerateTitle: widget.onGenerateTitle, onGenerateTitle: widget.onGenerateTitle,
textStyle: effectiveThemeData.textTheme.textStyle, textStyle: CupertinoTheme.of(context).textTheme.textStyle,
color: CupertinoDynamicColor.resolve(widget.color ?? effectiveThemeData.primaryColor, context), color: CupertinoDynamicColor.resolve(widget.color ?? effectiveThemeData.primaryColor, context),
locale: widget.locale, locale: widget.locale,
localizationsDelegates: _localizationsDelegates, localizationsDelegates: _localizationsDelegates,
......
...@@ -16,10 +16,7 @@ const Color _kDefaultTabBarBorderColor = CupertinoDynamicColor.withBrightness( ...@@ -16,10 +16,7 @@ const Color _kDefaultTabBarBorderColor = CupertinoDynamicColor.withBrightness(
color: Color(0x4C000000), color: Color(0x4C000000),
darkColor: Color(0x29000000), darkColor: Color(0x29000000),
); );
const Color _kDefaultTabBarInactiveColor = CupertinoDynamicColor.withBrightness( const Color _kDefaultTabBarInactiveColor = CupertinoColors.inactiveGray;
color: Color(0xFF999999),
darkColor: Color(0xFF757575),
);
/// An iOS-styled bottom navigation tab bar. /// An iOS-styled bottom navigation tab bar.
/// ///
......
...@@ -79,7 +79,8 @@ class CupertinoColors { ...@@ -79,7 +79,8 @@ class CupertinoColors {
/// Not the same grey as disabled buttons etc. /// Not the same grey as disabled buttons etc.
/// ///
/// This is the disabled color in the iOS palette. /// This is the disabled color in the iOS palette.
static const Color inactiveGray = CupertinoDynamicColor.withBrightness( static const CupertinoDynamicColor inactiveGray = CupertinoDynamicColor.withBrightness(
debugLabel: 'inactiveGray',
color: Color(0xFF999999), color: Color(0xFF999999),
darkColor: Color(0xFF757575), darkColor: Color(0xFF757575),
); );
...@@ -100,6 +101,7 @@ class CupertinoColors { ...@@ -100,6 +101,7 @@ class CupertinoColors {
/// * [UIColor.systemBlue](https://developer.apple.com/documentation/uikit/uicolor/3173141-systemblue), /// * [UIColor.systemBlue](https://developer.apple.com/documentation/uikit/uicolor/3173141-systemblue),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemBlue = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemBlue = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemBlue',
color: Color.fromARGB(255, 0, 122, 255), color: Color.fromARGB(255, 0, 122, 255),
darkColor: Color.fromARGB(255, 10, 132, 255), darkColor: Color.fromARGB(255, 10, 132, 255),
highContrastColor: Color.fromARGB(255, 0, 64, 221), highContrastColor: Color.fromARGB(255, 0, 64, 221),
...@@ -113,6 +115,7 @@ class CupertinoColors { ...@@ -113,6 +115,7 @@ class CupertinoColors {
/// * [UIColor.systemGreen](https://developer.apple.com/documentation/uikit/uicolor/3173144-systemgreen), /// * [UIColor.systemGreen](https://developer.apple.com/documentation/uikit/uicolor/3173144-systemgreen),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGreen = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemGreen = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGreen',
color: Color.fromARGB(255, 52, 199, 89), color: Color.fromARGB(255, 52, 199, 89),
darkColor: Color.fromARGB(255, 48, 209, 88), darkColor: Color.fromARGB(255, 48, 209, 88),
highContrastColor: Color.fromARGB(255, 36, 138, 61), highContrastColor: Color.fromARGB(255, 36, 138, 61),
...@@ -126,6 +129,7 @@ class CupertinoColors { ...@@ -126,6 +129,7 @@ class CupertinoColors {
/// * [UIColor.systemIndigo](https://developer.apple.com/documentation/uikit/uicolor/3173146-systemindigo), /// * [UIColor.systemIndigo](https://developer.apple.com/documentation/uikit/uicolor/3173146-systemindigo),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemIndigo = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemIndigo = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemIndigo',
color: Color.fromARGB(255, 88, 86, 214), color: Color.fromARGB(255, 88, 86, 214),
darkColor: Color.fromARGB(255, 94, 92, 230), darkColor: Color.fromARGB(255, 94, 92, 230),
highContrastColor: Color.fromARGB(255, 54, 52, 163), highContrastColor: Color.fromARGB(255, 54, 52, 163),
...@@ -139,6 +143,7 @@ class CupertinoColors { ...@@ -139,6 +143,7 @@ class CupertinoColors {
/// * [UIColor.systemOrange](https://developer.apple.com/documentation/uikit/uicolor/3173147-systemorange), /// * [UIColor.systemOrange](https://developer.apple.com/documentation/uikit/uicolor/3173147-systemorange),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemOrange = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemOrange = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemOrange',
color: Color.fromARGB(255, 255, 149, 0), color: Color.fromARGB(255, 255, 149, 0),
darkColor: Color.fromARGB(255, 255, 159, 10), darkColor: Color.fromARGB(255, 255, 159, 10),
highContrastColor: Color.fromARGB(255, 201, 52, 0), highContrastColor: Color.fromARGB(255, 201, 52, 0),
...@@ -152,6 +157,7 @@ class CupertinoColors { ...@@ -152,6 +157,7 @@ class CupertinoColors {
/// * [UIColor.systemPink](https://developer.apple.com/documentation/uikit/uicolor/3173148-systempink), /// * [UIColor.systemPink](https://developer.apple.com/documentation/uikit/uicolor/3173148-systempink),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemPink = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemPink = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemPink',
color: Color.fromARGB(255, 255, 45, 85), color: Color.fromARGB(255, 255, 45, 85),
darkColor: Color.fromARGB(255, 255, 55, 95), darkColor: Color.fromARGB(255, 255, 55, 95),
highContrastColor: Color.fromARGB(255, 211, 15, 69), highContrastColor: Color.fromARGB(255, 211, 15, 69),
...@@ -165,6 +171,7 @@ class CupertinoColors { ...@@ -165,6 +171,7 @@ class CupertinoColors {
/// * [UIColor.systemPurple](https://developer.apple.com/documentation/uikit/uicolor/3173149-systempurple), /// * [UIColor.systemPurple](https://developer.apple.com/documentation/uikit/uicolor/3173149-systempurple),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemPurple = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemPurple = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemPurple',
color: Color.fromARGB(255, 175, 82, 222), color: Color.fromARGB(255, 175, 82, 222),
darkColor: Color.fromARGB(255, 191, 90, 242), darkColor: Color.fromARGB(255, 191, 90, 242),
highContrastColor: Color.fromARGB(255, 137, 68, 171), highContrastColor: Color.fromARGB(255, 137, 68, 171),
...@@ -178,6 +185,7 @@ class CupertinoColors { ...@@ -178,6 +185,7 @@ class CupertinoColors {
/// * [UIColor.systemRed](https://developer.apple.com/documentation/uikit/uicolor/3173150-systemred), /// * [UIColor.systemRed](https://developer.apple.com/documentation/uikit/uicolor/3173150-systemred),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemRed = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemRed = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemRed',
color: Color.fromARGB(255, 255, 59, 48), color: Color.fromARGB(255, 255, 59, 48),
darkColor: Color.fromARGB(255, 255, 69, 58), darkColor: Color.fromARGB(255, 255, 69, 58),
highContrastColor: Color.fromARGB(255, 215, 0, 21), highContrastColor: Color.fromARGB(255, 215, 0, 21),
...@@ -191,6 +199,7 @@ class CupertinoColors { ...@@ -191,6 +199,7 @@ class CupertinoColors {
/// * [UIColor.systemTeal](https://developer.apple.com/documentation/uikit/uicolor/3173151-systemteal), /// * [UIColor.systemTeal](https://developer.apple.com/documentation/uikit/uicolor/3173151-systemteal),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemTeal = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemTeal = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemTeal',
color: Color.fromARGB(255, 90, 200, 250), color: Color.fromARGB(255, 90, 200, 250),
darkColor: Color.fromARGB(255, 100, 210, 255), darkColor: Color.fromARGB(255, 100, 210, 255),
highContrastColor: Color.fromARGB(255, 0, 113, 164), highContrastColor: Color.fromARGB(255, 0, 113, 164),
...@@ -204,6 +213,7 @@ class CupertinoColors { ...@@ -204,6 +213,7 @@ class CupertinoColors {
/// * [UIColor.systemYellow](https://developer.apple.com/documentation/uikit/uicolor/3173152-systemyellow), /// * [UIColor.systemYellow](https://developer.apple.com/documentation/uikit/uicolor/3173152-systemyellow),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemYellow = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemYellow = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemYellow',
color: Color.fromARGB(255, 255, 204, 0), color: Color.fromARGB(255, 255, 204, 0),
darkColor: Color.fromARGB(255, 255, 214, 10), darkColor: Color.fromARGB(255, 255, 214, 10),
highContrastColor: Color.fromARGB(255, 160, 90, 0), highContrastColor: Color.fromARGB(255, 160, 90, 0),
...@@ -217,6 +227,7 @@ class CupertinoColors { ...@@ -217,6 +227,7 @@ class CupertinoColors {
/// * [UIColor.systemGray](https://developer.apple.com/documentation/uikit/uicolor/3173143-systemgray), /// * [UIColor.systemGray](https://developer.apple.com/documentation/uikit/uicolor/3173143-systemgray),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemGrey = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey',
color: Color.fromARGB(255, 142, 142, 147), color: Color.fromARGB(255, 142, 142, 147),
darkColor: Color.fromARGB(255, 142, 142, 147), darkColor: Color.fromARGB(255, 142, 142, 147),
highContrastColor: Color.fromARGB(255, 108, 108, 112), highContrastColor: Color.fromARGB(255, 108, 108, 112),
...@@ -230,6 +241,7 @@ class CupertinoColors { ...@@ -230,6 +241,7 @@ class CupertinoColors {
/// * [UIColor.systemGray2](https://developer.apple.com/documentation/uikit/uicolor/3255071-systemgray2), /// * [UIColor.systemGray2](https://developer.apple.com/documentation/uikit/uicolor/3255071-systemgray2),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey2 = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemGrey2 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey2',
color: Color.fromARGB(255, 174, 174, 178), color: Color.fromARGB(255, 174, 174, 178),
darkColor: Color.fromARGB(255, 99, 99, 102), darkColor: Color.fromARGB(255, 99, 99, 102),
highContrastColor: Color.fromARGB(255, 142, 142, 147), highContrastColor: Color.fromARGB(255, 142, 142, 147),
...@@ -243,6 +255,7 @@ class CupertinoColors { ...@@ -243,6 +255,7 @@ class CupertinoColors {
/// * [UIColor.systemGray3](https://developer.apple.com/documentation/uikit/uicolor/3255072-systemgray3), /// * [UIColor.systemGray3](https://developer.apple.com/documentation/uikit/uicolor/3255072-systemgray3),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey3 = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemGrey3 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey3',
color: Color.fromARGB(255, 199, 199, 204), color: Color.fromARGB(255, 199, 199, 204),
darkColor: Color.fromARGB(255, 72, 72, 74), darkColor: Color.fromARGB(255, 72, 72, 74),
highContrastColor: Color.fromARGB(255, 174, 174, 178), highContrastColor: Color.fromARGB(255, 174, 174, 178),
...@@ -256,6 +269,7 @@ class CupertinoColors { ...@@ -256,6 +269,7 @@ class CupertinoColors {
/// * [UIColor.systemGray4](https://developer.apple.com/documentation/uikit/uicolor/3255073-systemgray4), /// * [UIColor.systemGray4](https://developer.apple.com/documentation/uikit/uicolor/3255073-systemgray4),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey4 = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemGrey4 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey4',
color: Color.fromARGB(255, 209, 209, 214), color: Color.fromARGB(255, 209, 209, 214),
darkColor: Color.fromARGB(255, 58, 58, 60), darkColor: Color.fromARGB(255, 58, 58, 60),
highContrastColor: Color.fromARGB(255, 188, 188, 192), highContrastColor: Color.fromARGB(255, 188, 188, 192),
...@@ -269,6 +283,7 @@ class CupertinoColors { ...@@ -269,6 +283,7 @@ class CupertinoColors {
/// * [UIColor.systemGray5](https://developer.apple.com/documentation/uikit/uicolor/3255074-systemgray5), /// * [UIColor.systemGray5](https://developer.apple.com/documentation/uikit/uicolor/3255074-systemgray5),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey5 = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemGrey5 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey5',
color: Color.fromARGB(255, 229, 229, 234), color: Color.fromARGB(255, 229, 229, 234),
darkColor: Color.fromARGB(255, 44, 44, 46), darkColor: Color.fromARGB(255, 44, 44, 46),
highContrastColor: Color.fromARGB(255, 216, 216, 220), highContrastColor: Color.fromARGB(255, 216, 216, 220),
...@@ -282,6 +297,7 @@ class CupertinoColors { ...@@ -282,6 +297,7 @@ class CupertinoColors {
/// * [UIColor.systemGray6](https://developer.apple.com/documentation/uikit/uicolor/3255075-systemgray6), /// * [UIColor.systemGray6](https://developer.apple.com/documentation/uikit/uicolor/3255075-systemgray6),
/// the `UIKit` equivalent. /// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey6 = CupertinoDynamicColor.withBrightnessAndContrast( static const CupertinoDynamicColor systemGrey6 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey6',
color: Color.fromARGB(255, 242, 242, 247), color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 28, 28, 30), darkColor: Color.fromARGB(255, 28, 28, 30),
highContrastColor: Color.fromARGB(255, 235, 235, 240), highContrastColor: Color.fromARGB(255, 235, 235, 240),
...@@ -291,6 +307,7 @@ class CupertinoColors { ...@@ -291,6 +307,7 @@ class CupertinoColors {
/// The color for text labels containing primary content, equivalent to /// The color for text labels containing primary content, equivalent to
/// [UIColor.label](https://developer.apple.com/documentation/uikit/uicolor/3173131-label). /// [UIColor.label](https://developer.apple.com/documentation/uikit/uicolor/3173131-label).
static const CupertinoDynamicColor label = CupertinoDynamicColor( static const CupertinoDynamicColor label = CupertinoDynamicColor(
debugLabel: 'label',
color: Color.fromARGB(255, 0, 0, 0), color: Color.fromARGB(255, 0, 0, 0),
darkColor: Color.fromARGB(255, 255, 255, 255), darkColor: Color.fromARGB(255, 255, 255, 255),
highContrastColor: Color.fromARGB(255, 0, 0, 0), highContrastColor: Color.fromARGB(255, 0, 0, 0),
...@@ -304,6 +321,7 @@ class CupertinoColors { ...@@ -304,6 +321,7 @@ class CupertinoColors {
/// The color for text labels containing secondary content, equivalent to /// The color for text labels containing secondary content, equivalent to
/// [UIColor.secondaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173136-secondarylabel). /// [UIColor.secondaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173136-secondarylabel).
static const CupertinoDynamicColor secondaryLabel = CupertinoDynamicColor( static const CupertinoDynamicColor secondaryLabel = CupertinoDynamicColor(
debugLabel: 'secondaryLabel',
color: Color.fromARGB(153, 60, 60, 67), color: Color.fromARGB(153, 60, 60, 67),
darkColor: Color.fromARGB(153, 235, 235, 245), darkColor: Color.fromARGB(153, 235, 235, 245),
highContrastColor: Color.fromARGB(173, 60, 60, 67), highContrastColor: Color.fromARGB(173, 60, 60, 67),
...@@ -317,6 +335,7 @@ class CupertinoColors { ...@@ -317,6 +335,7 @@ class CupertinoColors {
/// The color for text labels containing tertiary content, equivalent to /// The color for text labels containing tertiary content, equivalent to
/// [UIColor.tertiaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173153-tertiarylabel). /// [UIColor.tertiaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173153-tertiarylabel).
static const CupertinoDynamicColor tertiaryLabel = CupertinoDynamicColor( static const CupertinoDynamicColor tertiaryLabel = CupertinoDynamicColor(
debugLabel: 'tertiaryLabel',
color: Color.fromARGB(76, 60, 60, 67), color: Color.fromARGB(76, 60, 60, 67),
darkColor: Color.fromARGB(76, 235, 235, 245), darkColor: Color.fromARGB(76, 235, 235, 245),
highContrastColor: Color.fromARGB(96, 60, 60, 67), highContrastColor: Color.fromARGB(96, 60, 60, 67),
...@@ -330,6 +349,7 @@ class CupertinoColors { ...@@ -330,6 +349,7 @@ class CupertinoColors {
/// The color for text labels containing quaternary content, equivalent to /// The color for text labels containing quaternary content, equivalent to
/// [UIColor.quaternaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173135-quaternarylabel). /// [UIColor.quaternaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173135-quaternarylabel).
static const CupertinoDynamicColor quaternaryLabel = CupertinoDynamicColor( static const CupertinoDynamicColor quaternaryLabel = CupertinoDynamicColor(
debugLabel: 'quaternaryLabel',
color: Color.fromARGB(45, 60, 60, 67), color: Color.fromARGB(45, 60, 60, 67),
darkColor: Color.fromARGB(40, 235, 235, 245), darkColor: Color.fromARGB(40, 235, 235, 245),
highContrastColor: Color.fromARGB(66, 60, 60, 67), highContrastColor: Color.fromARGB(66, 60, 60, 67),
...@@ -343,6 +363,7 @@ class CupertinoColors { ...@@ -343,6 +363,7 @@ class CupertinoColors {
/// An overlay fill color for thin and small shapes, equivalent to /// An overlay fill color for thin and small shapes, equivalent to
/// [UIColor.systemFill](https://developer.apple.com/documentation/uikit/uicolor/3255070-systemfill). /// [UIColor.systemFill](https://developer.apple.com/documentation/uikit/uicolor/3255070-systemfill).
static const CupertinoDynamicColor systemFill = CupertinoDynamicColor( static const CupertinoDynamicColor systemFill = CupertinoDynamicColor(
debugLabel: 'systemFill',
color: Color.fromARGB(51, 120, 120, 128), color: Color.fromARGB(51, 120, 120, 128),
darkColor: Color.fromARGB(91, 120, 120, 128), darkColor: Color.fromARGB(91, 120, 120, 128),
highContrastColor: Color.fromARGB(71, 120, 120, 128), highContrastColor: Color.fromARGB(71, 120, 120, 128),
...@@ -356,6 +377,7 @@ class CupertinoColors { ...@@ -356,6 +377,7 @@ class CupertinoColors {
/// An overlay fill color for medium-size shapes, equivalent to /// An overlay fill color for medium-size shapes, equivalent to
/// [UIColor.secondarySystemFill](https://developer.apple.com/documentation/uikit/uicolor/3255069-secondarysystemfill). /// [UIColor.secondarySystemFill](https://developer.apple.com/documentation/uikit/uicolor/3255069-secondarysystemfill).
static const CupertinoDynamicColor secondarySystemFill = CupertinoDynamicColor( static const CupertinoDynamicColor secondarySystemFill = CupertinoDynamicColor(
debugLabel: 'secondarySystemFill',
color: Color.fromARGB(40, 120, 120, 128), color: Color.fromARGB(40, 120, 120, 128),
darkColor: Color.fromARGB(81, 120, 120, 128), darkColor: Color.fromARGB(81, 120, 120, 128),
highContrastColor: Color.fromARGB(61, 120, 120, 128), highContrastColor: Color.fromARGB(61, 120, 120, 128),
...@@ -369,6 +391,7 @@ class CupertinoColors { ...@@ -369,6 +391,7 @@ class CupertinoColors {
/// An overlay fill color for large shapes, equivalent to /// An overlay fill color for large shapes, equivalent to
/// [UIColor.tertiarySystemFill](https://developer.apple.com/documentation/uikit/uicolor/3255076-tertiarysystemfill). /// [UIColor.tertiarySystemFill](https://developer.apple.com/documentation/uikit/uicolor/3255076-tertiarysystemfill).
static const CupertinoDynamicColor tertiarySystemFill = CupertinoDynamicColor( static const CupertinoDynamicColor tertiarySystemFill = CupertinoDynamicColor(
debugLabel: 'tertiarySystemFill',
color: Color.fromARGB(30, 118, 118, 128), color: Color.fromARGB(30, 118, 118, 128),
darkColor: Color.fromARGB(61, 118, 118, 128), darkColor: Color.fromARGB(61, 118, 118, 128),
highContrastColor: Color.fromARGB(51, 118, 118, 128), highContrastColor: Color.fromARGB(51, 118, 118, 128),
...@@ -382,6 +405,7 @@ class CupertinoColors { ...@@ -382,6 +405,7 @@ class CupertinoColors {
/// An overlay fill color for large areas containing complex content, equivalent /// An overlay fill color for large areas containing complex content, equivalent
/// to [UIColor.quaternarySystemFill](https://developer.apple.com/documentation/uikit/uicolor/3255068-quaternarysystemfill). /// to [UIColor.quaternarySystemFill](https://developer.apple.com/documentation/uikit/uicolor/3255068-quaternarysystemfill).
static const CupertinoDynamicColor quaternarySystemFill = CupertinoDynamicColor( static const CupertinoDynamicColor quaternarySystemFill = CupertinoDynamicColor(
debugLabel: 'quaternarySystemFill',
color: Color.fromARGB(20, 116, 116, 128), color: Color.fromARGB(20, 116, 116, 128),
darkColor: Color.fromARGB(45, 118, 118, 128), darkColor: Color.fromARGB(45, 118, 118, 128),
highContrastColor: Color.fromARGB(40, 116, 116, 128), highContrastColor: Color.fromARGB(40, 116, 116, 128),
...@@ -395,6 +419,7 @@ class CupertinoColors { ...@@ -395,6 +419,7 @@ class CupertinoColors {
/// The color for placeholder text in controls or text views, equivalent to /// The color for placeholder text in controls or text views, equivalent to
/// [UIColor.placeholderText](https://developer.apple.com/documentation/uikit/uicolor/3173134-placeholdertext). /// [UIColor.placeholderText](https://developer.apple.com/documentation/uikit/uicolor/3173134-placeholdertext).
static const CupertinoDynamicColor placeholderText = CupertinoDynamicColor( static const CupertinoDynamicColor placeholderText = CupertinoDynamicColor(
debugLabel: 'placeholderText',
color: Color.fromARGB(76, 60, 60, 67), color: Color.fromARGB(76, 60, 60, 67),
darkColor: Color.fromARGB(76, 235, 235, 245), darkColor: Color.fromARGB(76, 235, 235, 245),
highContrastColor: Color.fromARGB(96, 60, 60, 67), highContrastColor: Color.fromARGB(96, 60, 60, 67),
...@@ -410,6 +435,7 @@ class CupertinoColors { ...@@ -410,6 +435,7 @@ class CupertinoColors {
/// ///
/// Typically used for designs that have a white primary background in a light environment. /// Typically used for designs that have a white primary background in a light environment.
static const CupertinoDynamicColor systemBackground = CupertinoDynamicColor( static const CupertinoDynamicColor systemBackground = CupertinoDynamicColor(
debugLabel: 'systemBackground',
color: Color.fromARGB(255, 255, 255, 255), color: Color.fromARGB(255, 255, 255, 255),
darkColor: Color.fromARGB(255, 0, 0, 0), darkColor: Color.fromARGB(255, 0, 0, 0),
highContrastColor: Color.fromARGB(255, 255, 255, 255), highContrastColor: Color.fromARGB(255, 255, 255, 255),
...@@ -425,6 +451,7 @@ class CupertinoColors { ...@@ -425,6 +451,7 @@ class CupertinoColors {
/// ///
/// Typically used for designs that have a white primary background in a light environment. /// Typically used for designs that have a white primary background in a light environment.
static const CupertinoDynamicColor secondarySystemBackground = CupertinoDynamicColor( static const CupertinoDynamicColor secondarySystemBackground = CupertinoDynamicColor(
debugLabel: 'secondarySystemBackground',
color: Color.fromARGB(255, 242, 242, 247), color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 28, 28, 30), darkColor: Color.fromARGB(255, 28, 28, 30),
highContrastColor: Color.fromARGB(255, 235, 235, 240), highContrastColor: Color.fromARGB(255, 235, 235, 240),
...@@ -440,6 +467,7 @@ class CupertinoColors { ...@@ -440,6 +467,7 @@ class CupertinoColors {
/// ///
/// Typically used for designs that have a white primary background in a light environment. /// Typically used for designs that have a white primary background in a light environment.
static const CupertinoDynamicColor tertiarySystemBackground = CupertinoDynamicColor( static const CupertinoDynamicColor tertiarySystemBackground = CupertinoDynamicColor(
debugLabel: 'tertiarySystemBackground',
color: Color.fromARGB(255, 255, 255, 255), color: Color.fromARGB(255, 255, 255, 255),
darkColor: Color.fromARGB(255, 44, 44, 46), darkColor: Color.fromARGB(255, 44, 44, 46),
highContrastColor: Color.fromARGB(255, 255, 255, 255), highContrastColor: Color.fromARGB(255, 255, 255, 255),
...@@ -455,6 +483,7 @@ class CupertinoColors { ...@@ -455,6 +483,7 @@ class CupertinoColors {
/// ///
/// Typically used for grouped content, including table views and platter-based designs. /// Typically used for grouped content, including table views and platter-based designs.
static const CupertinoDynamicColor systemGroupedBackground = CupertinoDynamicColor( static const CupertinoDynamicColor systemGroupedBackground = CupertinoDynamicColor(
debugLabel: 'systemGroupedBackground',
color: Color.fromARGB(255, 242, 242, 247), color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 0, 0, 0), darkColor: Color.fromARGB(255, 0, 0, 0),
highContrastColor: Color.fromARGB(255, 235, 235, 240), highContrastColor: Color.fromARGB(255, 235, 235, 240),
...@@ -470,6 +499,7 @@ class CupertinoColors { ...@@ -470,6 +499,7 @@ class CupertinoColors {
/// ///
/// Typically used for grouped content, including table views and platter-based designs. /// Typically used for grouped content, including table views and platter-based designs.
static const CupertinoDynamicColor secondarySystemGroupedBackground = CupertinoDynamicColor( static const CupertinoDynamicColor secondarySystemGroupedBackground = CupertinoDynamicColor(
debugLabel: 'secondarySystemGroupedBackground',
color: Color.fromARGB(255, 255, 255, 255), color: Color.fromARGB(255, 255, 255, 255),
darkColor: Color.fromARGB(255, 28, 28, 30), darkColor: Color.fromARGB(255, 28, 28, 30),
highContrastColor: Color.fromARGB(255, 255, 255, 255), highContrastColor: Color.fromARGB(255, 255, 255, 255),
...@@ -485,6 +515,7 @@ class CupertinoColors { ...@@ -485,6 +515,7 @@ class CupertinoColors {
/// ///
/// Typically used for grouped content, including table views and platter-based designs. /// Typically used for grouped content, including table views and platter-based designs.
static const CupertinoDynamicColor tertiarySystemGroupedBackground = CupertinoDynamicColor( static const CupertinoDynamicColor tertiarySystemGroupedBackground = CupertinoDynamicColor(
debugLabel: 'tertiarySystemGroupedBackground',
color: Color.fromARGB(255, 242, 242, 247), color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 44, 44, 46), darkColor: Color.fromARGB(255, 44, 44, 46),
highContrastColor: Color.fromARGB(255, 235, 235, 240), highContrastColor: Color.fromARGB(255, 235, 235, 240),
...@@ -498,6 +529,7 @@ class CupertinoColors { ...@@ -498,6 +529,7 @@ class CupertinoColors {
/// The color for thin borders or divider lines that allows some underlying content to be visible, /// The color for thin borders or divider lines that allows some underlying content to be visible,
/// equivalent to [UIColor.separator](https://developer.apple.com/documentation/uikit/uicolor/3173139-separator). /// equivalent to [UIColor.separator](https://developer.apple.com/documentation/uikit/uicolor/3173139-separator).
static const CupertinoDynamicColor separator = CupertinoDynamicColor( static const CupertinoDynamicColor separator = CupertinoDynamicColor(
debugLabel: 'separator',
color: Color.fromARGB(73, 60, 60, 67), color: Color.fromARGB(73, 60, 60, 67),
darkColor: Color.fromARGB(153, 84, 84, 88), darkColor: Color.fromARGB(153, 84, 84, 88),
highContrastColor: Color.fromARGB(94, 60, 60, 67), highContrastColor: Color.fromARGB(94, 60, 60, 67),
...@@ -511,6 +543,7 @@ class CupertinoColors { ...@@ -511,6 +543,7 @@ class CupertinoColors {
/// The color for borders or divider lines that hide any underlying content, /// The color for borders or divider lines that hide any underlying content,
/// equivalent to [UIColor.opaqueSeparator](https://developer.apple.com/documentation/uikit/uicolor/3173133-opaqueseparator). /// equivalent to [UIColor.opaqueSeparator](https://developer.apple.com/documentation/uikit/uicolor/3173133-opaqueseparator).
static const CupertinoDynamicColor opaqueSeparator = CupertinoDynamicColor( static const CupertinoDynamicColor opaqueSeparator = CupertinoDynamicColor(
debugLabel: 'opaqueSeparator',
color: Color.fromARGB(255, 198, 198, 200), color: Color.fromARGB(255, 198, 198, 200),
darkColor: Color.fromARGB(255, 56, 56, 58), darkColor: Color.fromARGB(255, 56, 56, 58),
highContrastColor: Color.fromARGB(255, 198, 198, 200), highContrastColor: Color.fromARGB(255, 198, 198, 200),
...@@ -524,6 +557,7 @@ class CupertinoColors { ...@@ -524,6 +557,7 @@ class CupertinoColors {
/// The color for links, equivalent to /// The color for links, equivalent to
/// [UIColor.link](https://developer.apple.com/documentation/uikit/uicolor/3173132-link). /// [UIColor.link](https://developer.apple.com/documentation/uikit/uicolor/3173132-link).
static const CupertinoDynamicColor link = CupertinoDynamicColor( static const CupertinoDynamicColor link = CupertinoDynamicColor(
debugLabel: 'link',
color: Color.fromARGB(255, 0, 122, 255), color: Color.fromARGB(255, 0, 122, 255),
darkColor: Color.fromARGB(255, 9, 132, 255), darkColor: Color.fromARGB(255, 9, 132, 255),
highContrastColor: Color.fromARGB(255, 0, 122, 255), highContrastColor: Color.fromARGB(255, 0, 122, 255),
...@@ -547,7 +581,7 @@ class CupertinoColors { ...@@ -547,7 +581,7 @@ class CupertinoColors {
/// Sometimes manually resolving a [CupertinoDynamicColor] is not necessary, because /// Sometimes manually resolving a [CupertinoDynamicColor] is not necessary, because
/// the Cupertino Library provides built-in support for it. /// the Cupertino Library provides built-in support for it.
/// ///
/// ### Using a [CupertinoDynamicColor] in a Cupertino widget /// ### Using [CupertinoDynamicColor] in a Cupertino widget
/// ///
/// When a Cupertino widget is provided with a [CupertinoDynamicColor], either /// When a Cupertino widget is provided with a [CupertinoDynamicColor], either
/// directly in its constructor, or from an [InheritedWidget] it depends on (for example, /// directly in its constructor, or from an [InheritedWidget] it depends on (for example,
...@@ -638,12 +672,13 @@ class CupertinoColors { ...@@ -638,12 +672,13 @@ class CupertinoColors {
/// * [CupertinoTheme.of], a static method that retrieves the ambient [CupertinoThemeData], /// * [CupertinoTheme.of], a static method that retrieves the ambient [CupertinoThemeData],
/// and then resolves [CupertinoDynamicColor]s used in the retrieved data. /// and then resolves [CupertinoDynamicColor]s used in the retrieved data.
@immutable @immutable
class CupertinoDynamicColor extends Color { class CupertinoDynamicColor extends Color with DiagnosticableMixin implements Diagnosticable {
/// Creates an adaptive [Color] that changes its effective color based on the /// Creates an adaptive [Color] that changes its effective color based on the
/// [BuildContext] given. The default effective color is [color]. /// [BuildContext] given. The default effective color is [color].
/// ///
/// All the colors must not be null. /// All the colors must not be null.
const CupertinoDynamicColor({ const CupertinoDynamicColor({
String debugLabel,
@required Color color, @required Color color,
@required Color darkColor, @required Color darkColor,
@required Color highContrastColor, @required Color highContrastColor,
...@@ -662,6 +697,8 @@ class CupertinoDynamicColor extends Color { ...@@ -662,6 +697,8 @@ class CupertinoDynamicColor extends Color {
darkElevatedColor, darkElevatedColor,
highContrastElevatedColor, highContrastElevatedColor,
darkHighContrastElevatedColor, darkHighContrastElevatedColor,
null,
debugLabel,
); );
/// Creates an adaptive [Color] that changes its effective color based on the /// Creates an adaptive [Color] that changes its effective color based on the
...@@ -671,11 +708,13 @@ class CupertinoDynamicColor extends Color { ...@@ -671,11 +708,13 @@ class CupertinoDynamicColor extends Color {
/// ///
/// All the colors must not be null. /// All the colors must not be null.
const CupertinoDynamicColor.withBrightnessAndContrast({ const CupertinoDynamicColor.withBrightnessAndContrast({
String debugLabel,
@required Color color, @required Color color,
@required Color darkColor, @required Color darkColor,
@required Color highContrastColor, @required Color highContrastColor,
@required Color darkHighContrastColor, @required Color darkHighContrastColor,
}) : this( }) : this(
debugLabel: debugLabel,
color: color, color: color,
darkColor: darkColor, darkColor: darkColor,
highContrastColor: highContrastColor, highContrastColor: highContrastColor,
...@@ -692,9 +731,11 @@ class CupertinoDynamicColor extends Color { ...@@ -692,9 +731,11 @@ class CupertinoDynamicColor extends Color {
/// ///
/// All the colors must not be null. /// All the colors must not be null.
const CupertinoDynamicColor.withBrightness({ const CupertinoDynamicColor.withBrightness({
String debugLabel,
@required Color color, @required Color color,
@required Color darkColor, @required Color darkColor,
}) : this( }) : this(
debugLabel: debugLabel,
color: color, color: color,
darkColor: darkColor, darkColor: darkColor,
highContrastColor: color, highContrastColor: color,
...@@ -715,6 +756,8 @@ class CupertinoDynamicColor extends Color { ...@@ -715,6 +756,8 @@ class CupertinoDynamicColor extends Color {
this.darkElevatedColor, this.darkElevatedColor,
this.highContrastElevatedColor, this.highContrastElevatedColor,
this.darkHighContrastElevatedColor, this.darkHighContrastElevatedColor,
this._debugResolveContext,
this._debugLabel,
) : assert(color != null), ) : assert(color != null),
assert(darkColor != null), assert(darkColor != null),
assert(highContrastColor != null), assert(highContrastColor != null),
...@@ -729,11 +772,19 @@ class CupertinoDynamicColor extends Color { ...@@ -729,11 +772,19 @@ class CupertinoDynamicColor extends Color {
// The field `value` is overriden in the class implementation. // The field `value` is overriden in the class implementation.
super(0); super(0);
/// The current effective color.
///
/// Must not be null. Defaults to [color] if this [CupertinoDynamicColor] has
/// never been resolved.
final Color _effectiveColor; final Color _effectiveColor;
@override @override
int get value => _effectiveColor.value; int get value => _effectiveColor.value;
final String _debugLabel;
final Element _debugResolveContext;
/// The color to use when the [BuildContext] implies a combination of light mode, /// The color to use when the [BuildContext] implies a combination of light mode,
/// normal contrast, and base interface elevation. /// normal contrast, and base interface elevation.
/// ///
...@@ -925,7 +976,11 @@ class CupertinoDynamicColor extends Color { ...@@ -925,7 +976,11 @@ class CupertinoDynamicColor extends Color {
} }
} }
assert(resolved != null); Element _debugContext;
assert(() {
_debugContext = context;
return true;
}());
return CupertinoDynamicColor._( return CupertinoDynamicColor._(
resolved, resolved,
color, color,
...@@ -936,6 +991,8 @@ class CupertinoDynamicColor extends Color { ...@@ -936,6 +991,8 @@ class CupertinoDynamicColor extends Color {
darkElevatedColor, darkElevatedColor,
highContrastElevatedColor, highContrastElevatedColor,
darkHighContrastElevatedColor, darkHighContrastElevatedColor,
_debugContext,
_debugLabel,
); );
} }
...@@ -972,9 +1029,9 @@ class CupertinoDynamicColor extends Color { ...@@ -972,9 +1029,9 @@ class CupertinoDynamicColor extends Color {
} }
@override @override
String toString() { String toString({ DiagnosticLevel minLevel = DiagnosticLevel.debug }) {
String toString(String name, Color color) { String toString(String name, Color color) {
final String marker = color.value == value ? '*' : ''; final String marker = color == _effectiveColor ? '*' : '';
return '$marker$name = $color$marker'; return '$marker$name = $color$marker';
} }
...@@ -988,6 +1045,64 @@ class CupertinoDynamicColor extends Color { ...@@ -988,6 +1045,64 @@ class CupertinoDynamicColor extends Color {
if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent) toString('darkHighContrastElevatedColor', darkHighContrastElevatedColor), if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent) toString('darkHighContrastElevatedColor', darkHighContrastElevatedColor),
]; ];
return '$runtimeType(${xs.join(', ')})'; return '${_debugLabel ?? runtimeType.toString()}(${xs.join(', ')}, resolved by: ${_debugResolveContext?.widget ?? "UNRESOLVED"})';
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
if (_debugLabel != null)
properties.add(MessageProperty('debugLabel', _debugLabel));
properties.add(createCupertinoColorProperty('color', color));
if (_isPlatformBrightnessDependent)
properties.add(createCupertinoColorProperty('darkColor', darkColor));
if (_isHighContrastDependent)
properties.add(createCupertinoColorProperty('highContrastColor', highContrastColor));
if (_isPlatformBrightnessDependent && _isHighContrastDependent)
properties.add(createCupertinoColorProperty('darkHighContrastColor', darkHighContrastColor));
if (_isInterfaceElevationDependent)
properties.add(createCupertinoColorProperty('elevatedColor', elevatedColor));
if (_isPlatformBrightnessDependent && _isInterfaceElevationDependent)
properties.add(createCupertinoColorProperty('darkElevatedColor', darkElevatedColor));
if (_isHighContrastDependent && _isInterfaceElevationDependent)
properties.add(createCupertinoColorProperty('highContrastElevatedColor', highContrastElevatedColor));
if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent)
properties.add(createCupertinoColorProperty('darkHighContrastElevatedColor', darkHighContrastElevatedColor));
if (_debugResolveContext != null)
properties.add(DiagnosticsProperty<Element>('last resolved', _debugResolveContext));
}
}
/// Creates a diagnostics property for [CupertinoDynamicColor].
///
/// The [showName], [style], and [level] arguments must not be null.
DiagnosticsProperty<Color> createCupertinoColorProperty(
String name,
Color value, {
bool showName = true,
Object defaultValue = kNoDefaultValue,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.shallow,
DiagnosticLevel level = DiagnosticLevel.info,
}) {
if (value is CupertinoDynamicColor) {
return DiagnosticsProperty<CupertinoDynamicColor>(
name,
value,
description: value._debugLabel,
showName: showName,
defaultValue: defaultValue,
style: style,
level: level,
);
} else {
return ColorProperty(
name,
value,
showName: showName,
defaultValue: defaultValue,
style: style,
level: level,
);
} }
} }
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'colors.dart'; import 'colors.dart';
/// An [IconThemeData] subclass that automatically resolves its [color] when retrieved /// An [IconThemeData] subclass that automatically resolves its [color] when retrieved
/// using [IconTheme.of]. /// using [IconTheme.of].
class CupertinoIconThemeData extends IconThemeData { class CupertinoIconThemeData extends IconThemeData with DiagnosticableMixin {
/// Creates a [CupertinoIconThemeData]. /// Creates a [CupertinoIconThemeData].
/// ///
/// The opacity applies to both explicit and default icon colors. The value /// The opacity applies to both explicit and default icon colors. The value
...@@ -24,4 +25,21 @@ class CupertinoIconThemeData extends IconThemeData { ...@@ -24,4 +25,21 @@ class CupertinoIconThemeData extends IconThemeData {
final Color resolvedColor = CupertinoDynamicColor.resolve(color, context); final Color resolvedColor = CupertinoDynamicColor.resolve(color, context);
return resolvedColor == color ? this : copyWith(color: resolvedColor); return resolvedColor == color ? this : copyWith(color: resolvedColor);
} }
/// Creates a copy of this icon theme but with the given fields replaced with
/// the new values.
@override
CupertinoIconThemeData copyWith({ Color color, double opacity, double size }) {
return CupertinoIconThemeData(
color: color ?? this.color,
opacity: opacity ?? this.opacity,
size: size ?? this.size,
);
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(createCupertinoColorProperty('color', color, defaultValue: null));
}
} }
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/foundation.dart';
import '../widgets/framework.dart'; import '../widgets/framework.dart';
/// Indicates the visual level for a piece of content. Equivalent to `UIUserInterfaceLevel` /// Indicates the visual level for a piece of content. Equivalent to `UIUserInterfaceLevel`
...@@ -73,4 +75,10 @@ class CupertinoUserInterfaceLevel extends InheritedWidget { ...@@ -73,4 +75,10 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
' $context' ' $context'
); );
} }
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(EnumProperty<CupertinoUserInterfaceLevelData>('user interface level', _data));
}
} }
...@@ -573,7 +573,7 @@ class CupertinoTextField extends StatefulWidget { ...@@ -573,7 +573,7 @@ class CupertinoTextField extends StatefulWidget {
properties.add(DiagnosticsProperty<bool>('expands', expands, defaultValue: false)); properties.add(DiagnosticsProperty<bool>('expands', expands, defaultValue: false));
properties.add(IntProperty('maxLength', maxLength, defaultValue: null)); properties.add(IntProperty('maxLength', maxLength, defaultValue: null));
properties.add(FlagProperty('maxLengthEnforced', value: maxLengthEnforced, ifTrue: 'max length enforced')); properties.add(FlagProperty('maxLengthEnforced', value: maxLengthEnforced, ifTrue: 'max length enforced'));
properties.add(ColorProperty('cursorColor', cursorColor, defaultValue: null)); properties.add(createCupertinoColorProperty('cursorColor', cursorColor, defaultValue: null));
properties.add(FlagProperty('selectionEnabled', value: selectionEnabled, defaultValue: true, ifFalse: 'selection disabled')); properties.add(FlagProperty('selectionEnabled', value: selectionEnabled, defaultValue: true, ifFalse: 'selection disabled'));
properties.add(DiagnosticsProperty<ScrollController>('scrollController', scrollController, defaultValue: null)); properties.add(DiagnosticsProperty<ScrollController>('scrollController', scrollController, defaultValue: null));
properties.add(DiagnosticsProperty<ScrollPhysics>('scrollPhysics', scrollPhysics, defaultValue: null)); properties.add(DiagnosticsProperty<ScrollPhysics>('scrollPhysics', scrollPhysics, defaultValue: null));
......
...@@ -8,9 +8,9 @@ import 'package:flutter/widgets.dart'; ...@@ -8,9 +8,9 @@ import 'package:flutter/widgets.dart';
import 'colors.dart'; import 'colors.dart';
// Please update _DefaultCupertinoTextThemeData and _DefaultCupertinoTextThemeData // Please update _TextThemeDefaultsBuilder accordingly after changing the default
// accordingly after changing the default color here, as their implementation // color here, as their implementation depends on the default value of the color
// depends on the default value of the color field. // field.
// //
// Values derived from https://developer.apple.com/design/resources/. // Values derived from https://developer.apple.com/design/resources/.
const TextStyle _kDefaultTextStyle = TextStyle( const TextStyle _kDefaultTextStyle = TextStyle(
...@@ -22,9 +22,9 @@ const TextStyle _kDefaultTextStyle = TextStyle( ...@@ -22,9 +22,9 @@ const TextStyle _kDefaultTextStyle = TextStyle(
decoration: TextDecoration.none, decoration: TextDecoration.none,
); );
// Please update _DefaultCupertinoTextThemeData and _DefaultCupertinoTextThemeData // Please update _TextThemeDefaultsBuilder accordingly after changing the default
// accordingly after changing the default color here, as their implementation // color here, as their implementation depends on the default value of the color
// depends on the default value of the color field. // field.
// //
// Values derived from https://developer.apple.com/design/resources/. // Values derived from https://developer.apple.com/design/resources/.
const TextStyle _kDefaultActionTextStyle = TextStyle( const TextStyle _kDefaultActionTextStyle = TextStyle(
...@@ -36,9 +36,9 @@ const TextStyle _kDefaultActionTextStyle = TextStyle( ...@@ -36,9 +36,9 @@ const TextStyle _kDefaultActionTextStyle = TextStyle(
decoration: TextDecoration.none, decoration: TextDecoration.none,
); );
// Please update _DefaultCupertinoTextThemeData and _DefaultCupertinoTextThemeData // Please update _TextThemeDefaultsBuilder accordingly after changing the default
// accordingly after changing the default color here, as their implementation // color here, as their implementation depends on the default value of the color
// depends on the default value of the color field. // field.
// //
// Values derived from https://developer.apple.com/design/resources/. // Values derived from https://developer.apple.com/design/resources/.
const TextStyle _kDefaultTabLabelTextStyle = TextStyle( const TextStyle _kDefaultTabLabelTextStyle = TextStyle(
...@@ -49,9 +49,6 @@ const TextStyle _kDefaultTabLabelTextStyle = TextStyle( ...@@ -49,9 +49,6 @@ const TextStyle _kDefaultTabLabelTextStyle = TextStyle(
color: CupertinoColors.inactiveGray, color: CupertinoColors.inactiveGray,
); );
// Please update _DefaultCupertinoTextThemeData and _DefaultCupertinoTextThemeData
// accordingly after changing the default color here, as their implementation
// depends on the default value of the color field.
const TextStyle _kDefaultMiddleTitleTextStyle = TextStyle( const TextStyle _kDefaultMiddleTitleTextStyle = TextStyle(
inherit: false, inherit: false,
fontFamily: '.SF Pro Text', fontFamily: '.SF Pro Text',
...@@ -61,9 +58,6 @@ const TextStyle _kDefaultMiddleTitleTextStyle = TextStyle( ...@@ -61,9 +58,6 @@ const TextStyle _kDefaultMiddleTitleTextStyle = TextStyle(
color: CupertinoColors.label, color: CupertinoColors.label,
); );
// Please update _DefaultCupertinoTextThemeData and _DefaultCupertinoTextThemeData
// accordingly after changing the default color here, as their implementation
// depends on the default value of the color field.
const TextStyle _kDefaultLargeTitleTextStyle = TextStyle( const TextStyle _kDefaultLargeTitleTextStyle = TextStyle(
inherit: false, inherit: false,
fontFamily: '.SF Pro Display', fontFamily: '.SF Pro Display',
...@@ -73,9 +67,9 @@ const TextStyle _kDefaultLargeTitleTextStyle = TextStyle( ...@@ -73,9 +67,9 @@ const TextStyle _kDefaultLargeTitleTextStyle = TextStyle(
color: CupertinoColors.label, color: CupertinoColors.label,
); );
// Please update _DefaultCupertinoTextThemeData and _DefaultCupertinoTextThemeData // Please update _TextThemeDefaultsBuilder accordingly after changing the default
// accordingly after changing the default color here, as their implementation // color here, as their implementation depends on the default value of the color
// depends on the default value of the color field. // field.
// //
// Inspected on iOS 13 simulator with "Debug View Hierarchy". // Inspected on iOS 13 simulator with "Debug View Hierarchy".
// Value extracted from off-center labels. Centered labels have a font size of 25pt. // Value extracted from off-center labels. Centered labels have a font size of 25pt.
...@@ -88,9 +82,9 @@ const TextStyle _kDefaultPickerTextStyle = TextStyle( ...@@ -88,9 +82,9 @@ const TextStyle _kDefaultPickerTextStyle = TextStyle(
color: CupertinoColors.label, color: CupertinoColors.label,
); );
// Please update _DefaultCupertinoTextThemeData and _DefaultCupertinoTextThemeData // Please update _TextThemeDefaultsBuilder accordingly after changing the default
// accordingly after changing the default color here, as their implementation // color here, as their implementation depends on the default value of the color
// depends on the default value of the color field. // field.
// //
// Inspected on iOS 13 simulator with "Debug View Hierarchy". // Inspected on iOS 13 simulator with "Debug View Hierarchy".
// Value extracted from off-center labels. Centered labels have a font size of 25pt. // Value extracted from off-center labels. Centered labels have a font size of 25pt.
...@@ -135,7 +129,7 @@ class CupertinoTextThemeData extends Diagnosticable { ...@@ -135,7 +129,7 @@ class CupertinoTextThemeData extends Diagnosticable {
TextStyle pickerTextStyle, TextStyle pickerTextStyle,
TextStyle dateTimePickerTextStyle, TextStyle dateTimePickerTextStyle,
}) : this._raw( }) : this._raw(
const _DefaultCupertinoTextThemeData(), const _TextThemeDefaultsBuilder(CupertinoColors.label, CupertinoColors.inactiveGray),
primaryColor, primaryColor,
textStyle, textStyle,
actionTextStyle, actionTextStyle,
...@@ -160,7 +154,7 @@ class CupertinoTextThemeData extends Diagnosticable { ...@@ -160,7 +154,7 @@ class CupertinoTextThemeData extends Diagnosticable {
this._dateTimePickerTextStyle, this._dateTimePickerTextStyle,
) : assert((_navActionTextStyle != null && _actionTextStyle != null) || _primaryColor != null); ) : assert((_navActionTextStyle != null && _actionTextStyle != null) || _primaryColor != null);
final _DefaultCupertinoTextThemeData _defaults; final _TextThemeDefaultsBuilder _defaults;
final Color _primaryColor; final Color _primaryColor;
final TextStyle _textStyle; final TextStyle _textStyle;
...@@ -248,15 +242,30 @@ class CupertinoTextThemeData extends Diagnosticable { ...@@ -248,15 +242,30 @@ class CupertinoTextThemeData extends Diagnosticable {
dateTimePickerTextStyle ?? _dateTimePickerTextStyle, dateTimePickerTextStyle ?? _dateTimePickerTextStyle,
); );
} }
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
const CupertinoTextThemeData defaultData = CupertinoTextThemeData();
properties.add(DiagnosticsProperty<TextStyle>('textStyle', textStyle, defaultValue: defaultData.textStyle));
properties.add(DiagnosticsProperty<TextStyle>('actionTextStyle', actionTextStyle, defaultValue: defaultData.actionTextStyle));
properties.add(DiagnosticsProperty<TextStyle>('tabLabelTextStyle', tabLabelTextStyle, defaultValue: defaultData.tabLabelTextStyle));
properties.add(DiagnosticsProperty<TextStyle>('navTitleTextStyle', navTitleTextStyle, defaultValue: defaultData.navTitleTextStyle));
properties.add(DiagnosticsProperty<TextStyle>('navLargeTitleTextStyle', navLargeTitleTextStyle, defaultValue: defaultData.navLargeTitleTextStyle));
properties.add(DiagnosticsProperty<TextStyle>('navActionTextStyle', navActionTextStyle, defaultValue: defaultData.navActionTextStyle));
properties.add(DiagnosticsProperty<TextStyle>('pickerTextStyle', pickerTextStyle, defaultValue: defaultData.pickerTextStyle));
properties.add(DiagnosticsProperty<TextStyle>('dateTimePickerTextStyle', dateTimePickerTextStyle, defaultValue: defaultData.dateTimePickerTextStyle));
}
} }
@immutable @immutable
class _DefaultCupertinoTextThemeData extends Diagnosticable { class _TextThemeDefaultsBuilder {
const _DefaultCupertinoTextThemeData({ const _TextThemeDefaultsBuilder(
this.labelColor = CupertinoColors.label, this.labelColor,
this.inactiveGrayColor = CupertinoColors.inactiveGray, this.inactiveGrayColor,
}) : assert(labelColor != null), ) : assert(labelColor != null),
assert(inactiveGrayColor != null); assert(inactiveGrayColor != null);
final Color labelColor; final Color labelColor;
final Color inactiveGrayColor; final Color inactiveGrayColor;
...@@ -277,11 +286,11 @@ class _DefaultCupertinoTextThemeData extends Diagnosticable { ...@@ -277,11 +286,11 @@ class _DefaultCupertinoTextThemeData extends Diagnosticable {
TextStyle actionTextStyle({ Color primaryColor }) => _kDefaultActionTextStyle.copyWith(color: primaryColor); TextStyle actionTextStyle({ Color primaryColor }) => _kDefaultActionTextStyle.copyWith(color: primaryColor);
TextStyle navActionTextStyle({ Color primaryColor }) => actionTextStyle(primaryColor: primaryColor); TextStyle navActionTextStyle({ Color primaryColor }) => actionTextStyle(primaryColor: primaryColor);
_DefaultCupertinoTextThemeData resolveFrom(BuildContext context, bool nullOk) { _TextThemeDefaultsBuilder resolveFrom(BuildContext context, bool nullOk) {
final Color resolvedLabelColor = CupertinoDynamicColor.resolve(labelColor, context, nullOk: nullOk); final Color resolvedLabelColor = CupertinoDynamicColor.resolve(labelColor, context, nullOk: nullOk);
final Color resolvedInactiveGray = CupertinoDynamicColor.resolve(inactiveGrayColor, context, nullOk: nullOk); final Color resolvedInactiveGray = CupertinoDynamicColor.resolve(inactiveGrayColor, context, nullOk: nullOk);
return resolvedLabelColor == labelColor && resolvedInactiveGray == CupertinoColors.inactiveGray return resolvedLabelColor == labelColor && resolvedInactiveGray == CupertinoColors.inactiveGray
? this ? this
: _DefaultCupertinoTextThemeData(labelColor: resolvedLabelColor, inactiveGrayColor: resolvedInactiveGray); : _TextThemeDefaultsBuilder(resolvedLabelColor, resolvedInactiveGray);
} }
} }
...@@ -99,6 +99,12 @@ class CupertinoTheme extends StatelessWidget { ...@@ -99,6 +99,12 @@ class CupertinoTheme extends StatelessWidget {
), ),
); );
} }
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
data.debugFillProperties(properties);
}
} }
class _InheritedCupertinoTheme extends InheritedWidget { class _InheritedCupertinoTheme extends InheritedWidget {
...@@ -284,10 +290,10 @@ class CupertinoThemeData extends Diagnosticable { ...@@ -284,10 +290,10 @@ class CupertinoThemeData extends Diagnosticable {
_brightness, _brightness,
convertColor(_primaryColor), convertColor(_primaryColor),
convertColor(_primaryContrastingColor), convertColor(_primaryContrastingColor),
textTheme?.resolveFrom(context, nullOk: nullOk), _textTheme?.resolveFrom(context, nullOk: nullOk),
convertColor(_barBackgroundColor), convertColor(_barBackgroundColor),
convertColor(_scaffoldBackgroundColor), convertColor(_scaffoldBackgroundColor),
_defaults.resolveFrom(context, nullOk: nullOk), _defaults.resolveFrom(context, _textTheme == null, nullOk: nullOk),
); );
} }
...@@ -322,11 +328,11 @@ class CupertinoThemeData extends Diagnosticable { ...@@ -322,11 +328,11 @@ class CupertinoThemeData extends Diagnosticable {
super.debugFillProperties(properties); super.debugFillProperties(properties);
const CupertinoThemeData defaultData = CupertinoThemeData(); const CupertinoThemeData defaultData = CupertinoThemeData();
properties.add(EnumProperty<Brightness>('brightness', brightness, defaultValue: defaultData.brightness)); properties.add(EnumProperty<Brightness>('brightness', brightness, defaultValue: defaultData.brightness));
properties.add(ColorProperty('primaryColor', primaryColor, defaultValue: defaultData.primaryColor)); properties.add(createCupertinoColorProperty('primaryColor', primaryColor, defaultValue: defaultData.primaryColor));
properties.add(ColorProperty('primaryContrastingColor', primaryContrastingColor, defaultValue: defaultData.primaryContrastingColor)); properties.add(createCupertinoColorProperty('primaryContrastingColor', primaryContrastingColor, defaultValue: defaultData.primaryContrastingColor));
properties.add(DiagnosticsProperty<CupertinoTextThemeData>('textTheme', textTheme, defaultValue: defaultData.textTheme)); properties.add(createCupertinoColorProperty('barBackgroundColor', barBackgroundColor, defaultValue: defaultData.barBackgroundColor));
properties.add(ColorProperty('barBackgroundColor', barBackgroundColor, defaultValue: defaultData.barBackgroundColor)); properties.add(createCupertinoColorProperty('scaffoldBackgroundColor', scaffoldBackgroundColor, defaultValue: defaultData.scaffoldBackgroundColor));
properties.add(ColorProperty('scaffoldBackgroundColor', scaffoldBackgroundColor, defaultValue: defaultData.scaffoldBackgroundColor)); textTheme.debugFillProperties(properties);
} }
} }
...@@ -413,7 +419,7 @@ class _CupertinoThemeDefaults { ...@@ -413,7 +419,7 @@ class _CupertinoThemeDefaults {
final Color scaffoldBackgroundColor; final Color scaffoldBackgroundColor;
final _CupertinoTextThemeDefaults textThemeDefaults; final _CupertinoTextThemeDefaults textThemeDefaults;
_CupertinoThemeDefaults resolveFrom(BuildContext context, { @required bool nullOk }) { _CupertinoThemeDefaults resolveFrom(BuildContext context, bool resolveTextTheme, { @required bool nullOk }) {
assert(nullOk != null); assert(nullOk != null);
Color convertColor(Color color) => CupertinoDynamicColor.resolve(color, context, nullOk: nullOk); Color convertColor(Color color) => CupertinoDynamicColor.resolve(color, context, nullOk: nullOk);
...@@ -423,7 +429,7 @@ class _CupertinoThemeDefaults { ...@@ -423,7 +429,7 @@ class _CupertinoThemeDefaults {
convertColor(primaryContrastingColor), convertColor(primaryContrastingColor),
convertColor(barBackgroundColor), convertColor(barBackgroundColor),
convertColor(scaffoldBackgroundColor), convertColor(scaffoldBackgroundColor),
textThemeDefaults?.resolveFrom(context, nullOk: nullOk), resolveTextTheme ? textThemeDefaults?.resolveFrom(context, nullOk: nullOk) : textThemeDefaults,
); );
} }
} }
......
...@@ -60,7 +60,13 @@ class IconTheme extends InheritedTheme { ...@@ -60,7 +60,13 @@ class IconTheme extends InheritedTheme {
/// ``` /// ```
static IconThemeData of(BuildContext context) { static IconThemeData of(BuildContext context) {
final IconThemeData iconThemeData = _getInheritedIconThemeData(context).resolve(context); final IconThemeData iconThemeData = _getInheritedIconThemeData(context).resolve(context);
return iconThemeData.isConcrete ? iconThemeData : const IconThemeData.fallback().merge(iconThemeData); return iconThemeData.isConcrete
? iconThemeData
: iconThemeData.copyWith(
size: iconThemeData.size ?? const IconThemeData.fallback().size,
color: iconThemeData.color ?? const IconThemeData.fallback().color,
opacity: iconThemeData.opacity ?? const IconThemeData.fallback().opacity,
);
} }
static IconThemeData _getInheritedIconThemeData(BuildContext context) { static IconThemeData _getInheritedIconThemeData(BuildContext context) {
...@@ -80,6 +86,6 @@ class IconTheme extends InheritedTheme { ...@@ -80,6 +86,6 @@ class IconTheme extends InheritedTheme {
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<IconThemeData>('data', data, showName: false)); data.debugFillProperties(properties);
} }
} }
...@@ -132,19 +132,21 @@ void main() { ...@@ -132,19 +132,21 @@ void main() {
test('CupertinoDynamicColor.toString() works', () { test('CupertinoDynamicColor.toString() works', () {
expect( expect(
dynamicColor.toString(), dynamicColor.toString(),
'CupertinoDynamicColor(*color = Color(0xff000000)*, ' contains(
'darkColor = Color(0xff000001), ' 'CupertinoDynamicColor(*color = Color(0xff000000)*, '
'highContrastColor = Color(0xff000003), ' 'darkColor = Color(0xff000001), '
'darkHighContrastColor = Color(0xff000005), ' 'highContrastColor = Color(0xff000003), '
'elevatedColor = Color(0xff000002), ' 'darkHighContrastColor = Color(0xff000005), '
'darkElevatedColor = Color(0xff000004), ' 'elevatedColor = Color(0xff000002), '
'highContrastElevatedColor = Color(0xff000006), ' 'darkElevatedColor = Color(0xff000004), '
'darkHighContrastElevatedColor = Color(0xff000007))', 'highContrastElevatedColor = Color(0xff000006), '
'darkHighContrastElevatedColor = Color(0xff000007)',
),
); );
expect(notSoDynamicColor1.toString(), 'CupertinoDynamicColor(*color = Color(0xff000000)*)'); expect(notSoDynamicColor1.toString(), contains('CupertinoDynamicColor(*color = Color(0xff000000)*'));
expect(vibrancyDependentColor1.toString(), 'CupertinoDynamicColor(*color = Color(0xff000001)*, darkColor = Color(0xff000000))'); expect(vibrancyDependentColor1.toString(), contains('CupertinoDynamicColor(*color = Color(0xff000001)*, darkColor = Color(0xff000000)'));
expect(contrastDependentColor1.toString(), 'CupertinoDynamicColor(*color = Color(0xff000001)*, highContrastColor = Color(0xff000000))'); expect(contrastDependentColor1.toString(), contains('CupertinoDynamicColor(*color = Color(0xff000001)*, highContrastColor = Color(0xff000000)'));
expect(elevationDependentColor1.toString(), 'CupertinoDynamicColor(*color = Color(0xff000001)*, elevatedColor = Color(0xff000000))'); expect(elevationDependentColor1.toString(), contains('CupertinoDynamicColor(*color = Color(0xff000001)*, elevatedColor = Color(0xff000000)'));
expect( expect(
const CupertinoDynamicColor.withBrightnessAndContrast( const CupertinoDynamicColor.withBrightnessAndContrast(
...@@ -153,10 +155,12 @@ void main() { ...@@ -153,10 +155,12 @@ void main() {
highContrastColor: color2, highContrastColor: color2,
darkHighContrastColor: color3, darkHighContrastColor: color3,
).toString(), ).toString(),
'CupertinoDynamicColor(*color = Color(0xff000000)*, ' contains(
'darkColor = Color(0xff000001), ' 'CupertinoDynamicColor(*color = Color(0xff000000)*, '
'highContrastColor = Color(0xff000002), ' 'darkColor = Color(0xff000001), '
'darkHighContrastColor = Color(0xff000003))', 'highContrastColor = Color(0xff000002), '
'darkHighContrastColor = Color(0xff000003)',
),
); );
}); });
......
...@@ -692,7 +692,7 @@ void main() { ...@@ -692,7 +692,7 @@ void main() {
// 2017 has 28 days in Feb so 29 is greyed out. // 2017 has 28 days in Feb so 29 is greyed out.
expect( expect(
tester.widget<Text>(find.text('29')).style.color, tester.widget<Text>(find.text('29')).style.color,
isSameColorAs(CupertinoColors.inactiveGray), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
await tester.drag(find.text('2017'), const Offset(0.0, 32.0), touchSlopY: 0.0); await tester.drag(find.text('2017'), const Offset(0.0, 32.0), touchSlopY: 0.0);
...@@ -707,7 +707,7 @@ void main() { ...@@ -707,7 +707,7 @@ void main() {
// 2016 has 29 days in Feb so 29 is not greyed out. // 2016 has 29 days in Feb so 29 is not greyed out.
expect( expect(
tester.widget<Text>(find.text('29')).style.color, tester.widget<Text>(find.text('29')).style.color,
isNot(isSameColorAs(CupertinoColors.inactiveGray)), isNot(isSameColorAs(CupertinoColors.inactiveGray.color)),
); );
await tester.drag(find.text('2016'), const Offset(0.0, -32.0), touchSlopY: 0.0); await tester.drag(find.text('2016'), const Offset(0.0, -32.0), touchSlopY: 0.0);
...@@ -721,7 +721,7 @@ void main() { ...@@ -721,7 +721,7 @@ void main() {
expect( expect(
tester.widget<Text>(find.text('29')).style.color, tester.widget<Text>(find.text('29')).style.color,
isSameColorAs(CupertinoColors.inactiveGray), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
}); });
......
...@@ -60,7 +60,7 @@ void main() { ...@@ -60,7 +60,7 @@ void main() {
final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle)); final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));
expect(widget.style.color.withAlpha(255).value, CupertinoColors.destructiveRed.value); expect(widget.style.color.withAlpha(255), CupertinoColors.systemRed.color);
}); });
testWidgets('Dialog dark theme', (WidgetTester tester) async { testWidgets('Dialog dark theme', (WidgetTester tester) async {
...@@ -183,7 +183,7 @@ void main() { ...@@ -183,7 +183,7 @@ void main() {
final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle)); final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));
expect(widget.style.color.withAlpha(255).value, CupertinoColors.destructiveRed.value); expect(widget.style.color.withAlpha(255), CupertinoColors.systemRed.color);
expect(widget.style.fontWeight, equals(FontWeight.w600)); expect(widget.style.fontWeight, equals(FontWeight.w600));
}); });
......
...@@ -173,12 +173,12 @@ void main() { ...@@ -173,12 +173,12 @@ void main() {
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
leading: CupertinoButton( leading: CupertinoButton(
onPressed: () { }, onPressed: () { },
child: const _ExpectStyles(color: CupertinoColors.activeBlue, index: 0x000001), child: _ExpectStyles(color: CupertinoColors.systemBlue.color, index: 0x000001),
), ),
middle: const _ExpectStyles(color: CupertinoColors.black, index: 0x000100), middle: const _ExpectStyles(color: CupertinoColors.black, index: 0x000100),
trailing: CupertinoButton( trailing: CupertinoButton(
onPressed: () { }, onPressed: () { },
child: const _ExpectStyles(color: CupertinoColors.activeBlue, index: 0x010000), child: _ExpectStyles(color: CupertinoColors.systemBlue.color, index: 0x010000),
), ),
), ),
), ),
......
...@@ -369,7 +369,7 @@ void main() { ...@@ -369,7 +369,7 @@ void main() {
}, },
groupValue: sharedValue, groupValue: sharedValue,
unselectedColor: CupertinoColors.lightBackgroundGray, unselectedColor: CupertinoColors.lightBackgroundGray,
selectedColor: CupertinoColors.activeGreen, selectedColor: CupertinoColors.activeGreen.color,
borderColor: CupertinoColors.black, borderColor: CupertinoColors.black,
pressedColor: const Color(0x638CFC7B), pressedColor: const Color(0x638CFC7B),
), ),
...@@ -383,8 +383,8 @@ void main() { ...@@ -383,8 +383,8 @@ void main() {
expect(getRenderSegmentedControl(tester).borderColor, CupertinoColors.black); expect(getRenderSegmentedControl(tester).borderColor, CupertinoColors.black);
expect(textStyle.style.color, CupertinoColors.lightBackgroundGray); expect(textStyle.style.color, CupertinoColors.lightBackgroundGray);
expect(iconTheme.data.color, CupertinoColors.activeGreen); expect(iconTheme.data.color, CupertinoColors.activeGreen.color);
expect(getBackgroundColor(tester, 0), CupertinoColors.activeGreen); expect(getBackgroundColor(tester, 0), CupertinoColors.activeGreen.color);
expect(getBackgroundColor(tester, 1), CupertinoColors.lightBackgroundGray); expect(getBackgroundColor(tester, 1), CupertinoColors.lightBackgroundGray);
await tester.tap(find.widgetWithIcon(IconTheme, const IconData(1))); await tester.tap(find.widgetWithIcon(IconTheme, const IconData(1)));
...@@ -393,17 +393,17 @@ void main() { ...@@ -393,17 +393,17 @@ void main() {
textStyle = tester.widget(find.widgetWithText(DefaultTextStyle, 'Child 1')); textStyle = tester.widget(find.widgetWithText(DefaultTextStyle, 'Child 1'));
iconTheme = tester.widget(find.widgetWithIcon(IconTheme, const IconData(1))); iconTheme = tester.widget(find.widgetWithIcon(IconTheme, const IconData(1)));
expect(textStyle.style.color, CupertinoColors.activeGreen); expect(textStyle.style.color, CupertinoColors.activeGreen.color);
expect(iconTheme.data.color, CupertinoColors.lightBackgroundGray); expect(iconTheme.data.color, CupertinoColors.lightBackgroundGray);
expect(getBackgroundColor(tester, 0), CupertinoColors.lightBackgroundGray); expect(getBackgroundColor(tester, 0), CupertinoColors.lightBackgroundGray);
expect(getBackgroundColor(tester, 1), CupertinoColors.activeGreen); expect(getBackgroundColor(tester, 1), CupertinoColors.activeGreen.color);
final Offset center = tester.getCenter(find.text('Child 1')); final Offset center = tester.getCenter(find.text('Child 1'));
await tester.startGesture(center); await tester.startGesture(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(getBackgroundColor(tester, 0), const Color(0x638CFC7B)); expect(getBackgroundColor(tester, 0), const Color(0x638CFC7B));
expect(getBackgroundColor(tester, 1), CupertinoColors.activeGreen); expect(getBackgroundColor(tester, 1), CupertinoColors.activeGreen.color);
}); });
testWidgets('Widgets are centered within segments', (WidgetTester tester) async { testWidgets('Widgets are centered within segments', (WidgetTester tester) async {
......
...@@ -3391,7 +3391,7 @@ void main() { ...@@ -3391,7 +3391,7 @@ void main() {
children: <Widget>[ children: <Widget>[
Container( Container(
height: 100, height: 100,
color: CupertinoColors.activeOrange, color: CupertinoColors.black,
), ),
Expanded( Expanded(
child: Navigator( child: Navigator(
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
import 'dart:async'; import 'dart:async';
import 'package:collection/collection.dart' show SetEquality;
import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -56,10 +59,10 @@ void main() { ...@@ -56,10 +59,10 @@ void main() {
testWidgets('Theme attributes cascade', (WidgetTester tester) async { testWidgets('Theme attributes cascade', (WidgetTester tester) async {
final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData( final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData(
primaryColor: CupertinoColors.destructiveRed, primaryColor: CupertinoColors.systemRed,
)); ));
expect(theme.textTheme.actionTextStyle.color, isSameColorAs(CupertinoColors.destructiveRed)); expect(theme.textTheme.actionTextStyle.color, isSameColorAs(CupertinoColors.systemRed.color));
}); });
testWidgets('Dependent attribute can be overridden from cascaded value', (WidgetTester tester) async { testWidgets('Dependent attribute can be overridden from cascaded value', (WidgetTester tester) async {
...@@ -137,12 +140,12 @@ void main() { ...@@ -137,12 +140,12 @@ void main() {
); );
testWidgets("Theme has default IconThemeData, which is derived from the theme's primary color", (WidgetTester tester) async { testWidgets("Theme has default IconThemeData, which is derived from the theme's primary color", (WidgetTester tester) async {
const CupertinoDynamicColor primaryColor = CupertinoColors.destructiveRed; const CupertinoDynamicColor primaryColor = CupertinoColors.systemRed;
const CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor); const CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor);
final IconThemeData resultingIconTheme = await testIconTheme(tester, themeData); final IconThemeData resultingIconTheme = await testIconTheme(tester, themeData);
expect(resultingIconTheme.color, themeData.primaryColor); expect(resultingIconTheme.color, isSameColorAs(primaryColor));
// Works in dark mode if primaryColor is a CupertinoDynamicColor. // Works in dark mode if primaryColor is a CupertinoDynamicColor.
final Color darkColor = (await testIconTheme( final Color darkColor = (await testIconTheme(
...@@ -164,6 +167,36 @@ void main() { ...@@ -164,6 +167,36 @@ void main() {
expect(iconTheme.color, CupertinoColors.activeOrange); expect(iconTheme.color, CupertinoColors.activeOrange);
}); });
testWidgets('CupertinoTheme diagnostics', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const CupertinoThemeData().debugFillProperties(builder);
final Set<String> description = builder.properties
.map((DiagnosticsNode node) => node.name.toString())
.toSet();
expect(
const SetEquality<String>().equals(
description,
<String>{ 'brightness',
'primaryColor',
'primaryContrastingColor',
'barBackgroundColor',
'scaffoldBackgroundColor',
'textStyle',
'actionTextStyle',
'tabLabelTextStyle',
'navTitleTextStyle',
'navLargeTitleTextStyle',
'navActionTextStyle',
'pickerTextStyle',
'dateTimePickerTextStyle'
}
),
isTrue,
);
});
Brightness currentBrightness; Brightness currentBrightness;
void colorMatches(Color componentColor, CupertinoDynamicColor expectedDynamicColor) { void colorMatches(Color componentColor, CupertinoDynamicColor expectedDynamicColor) {
switch (currentBrightness) { switch (currentBrightness) {
...@@ -181,7 +214,7 @@ void main() { ...@@ -181,7 +214,7 @@ void main() {
final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: CupertinoColors.systemRed); final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: CupertinoColors.systemRed);
final CupertinoThemeData theme = await testTheme(tester, data); final CupertinoThemeData theme = await testTheme(tester, data);
expect(data.primaryColor, isSameColorAs(CupertinoColors.systemRed.color)); expect(data.primaryColor, isSameColorAs(CupertinoColors.systemRed));
colorMatches(theme.primaryColor, CupertinoColors.systemRed); colorMatches(theme.primaryColor, CupertinoColors.systemRed);
}); });
......
...@@ -1625,7 +1625,7 @@ class _ColorMatcher extends Matcher { ...@@ -1625,7 +1625,7 @@ class _ColorMatcher extends Matcher {
@override @override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) { bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
if (item is Color) if (item is Color)
return item.value == targetColor.value; return item == targetColor || item.value == targetColor.value;
return false; return false;
} }
......
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