Update cupertino demos in gallery (#43841)
This commit is contained in:
@@ -33,7 +33,7 @@ class CupertinoButton extends StatefulWidget {
|
||||
this.color,
|
||||
this.disabledColor = CupertinoColors.quaternarySystemFill,
|
||||
this.minSize = kMinInteractiveDimensionCupertino,
|
||||
this.pressedOpacity = 0.1,
|
||||
this.pressedOpacity = 0.4,
|
||||
this.borderRadius = const BorderRadius.all(Radius.circular(8.0)),
|
||||
@required this.onPressed,
|
||||
}) : assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0)),
|
||||
@@ -53,7 +53,7 @@ class CupertinoButton extends StatefulWidget {
|
||||
this.padding,
|
||||
this.disabledColor = CupertinoColors.quaternarySystemFill,
|
||||
this.minSize = kMinInteractiveDimensionCupertino,
|
||||
this.pressedOpacity = 0.1,
|
||||
this.pressedOpacity = 0.4,
|
||||
this.borderRadius = const BorderRadius.all(Radius.circular(8.0)),
|
||||
@required this.onPressed,
|
||||
}) : assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0)),
|
||||
@@ -102,7 +102,7 @@ class CupertinoButton extends StatefulWidget {
|
||||
/// The opacity that the button will fade to when it is pressed.
|
||||
/// The button will have an opacity of 1.0 when it is not pressed.
|
||||
///
|
||||
/// This defaults to 0.1. If null, opacity will not change on pressed if using
|
||||
/// This defaults to 0.4. If null, opacity will not change on pressed if using
|
||||
/// your own custom effects is desired.
|
||||
final double pressedOpacity;
|
||||
|
||||
|
||||
@@ -304,15 +304,15 @@ class CupertinoColors {
|
||||
/// The color for text labels containing secondary content, equivalent to
|
||||
/// [UIColor.secondaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173136-secondarylabel).
|
||||
static const CupertinoDynamicColor secondaryLabel = CupertinoDynamicColor(
|
||||
color: Color.fromARGB(255, 0, 0, 0),
|
||||
darkColor: Color.fromARGB(255, 255, 255, 255),
|
||||
highContrastColor: Color.fromARGB(255, 0, 0, 0),
|
||||
darkHighContrastColor: Color.fromARGB(255, 255, 255, 255),
|
||||
elevatedColor: Color.fromARGB(255, 0, 0, 0),
|
||||
darkElevatedColor: Color.fromARGB(255, 255, 255, 255),
|
||||
highContrastElevatedColor: Color.fromARGB(255, 0, 0, 0),
|
||||
darkHighContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
|
||||
);
|
||||
color: Color.fromARGB(153, 60, 60, 67),
|
||||
darkColor: Color.fromARGB(153, 235, 235, 245),
|
||||
highContrastColor: Color.fromARGB(173, 60, 60, 67),
|
||||
darkHighContrastColor: Color.fromARGB(173, 235, 235, 245),
|
||||
elevatedColor: Color.fromARGB(153, 60, 60, 67),
|
||||
darkElevatedColor: Color.fromARGB(153, 235, 235, 245),
|
||||
highContrastElevatedColor: Color.fromARGB(173, 60, 60, 67),
|
||||
darkHighContrastElevatedColor: Color.fromARGB(173, 235, 235, 245),
|
||||
);
|
||||
|
||||
/// The color for text labels containing tertiary content, equivalent to
|
||||
/// [UIColor.tertiaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173153-tertiarylabel).
|
||||
@@ -889,7 +889,7 @@ class CupertinoDynamicColor extends Color {
|
||||
/// brightness, normal contrast, [CupertinoUserInterfaceLevelData.base] elevation
|
||||
/// level), unless [nullOk] is set to false, in which case an exception will be
|
||||
/// thrown.
|
||||
CupertinoDynamicColor resolveFrom(BuildContext context, { bool nullOk = false }) {
|
||||
CupertinoDynamicColor resolveFrom(BuildContext context, { bool nullOk = true }) {
|
||||
final Brightness brightness = _isPlatformBrightnessDependent
|
||||
? CupertinoTheme.brightnessOf(context, nullOk: nullOk) ?? Brightness.light
|
||||
: Brightness.light;
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/animation.dart' show Curves;
|
||||
|
||||
import 'colors.dart';
|
||||
import 'interface_level.dart';
|
||||
|
||||
const double _kBackGestureWidth = 20.0;
|
||||
const double _kMinFlingVelocity = 1.0; // Screen widths per second.
|
||||
@@ -840,7 +841,10 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> {
|
||||
|
||||
@override
|
||||
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
|
||||
return builder(context);
|
||||
return CupertinoUserInterfaceLevel(
|
||||
data: CupertinoUserInterfaceLevelData.elevated,
|
||||
child: Builder(builder: builder),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -63,6 +63,44 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
// TODO(LongCatIsLoong): Uncomment once https://github.com/flutter/flutter/issues/44115
|
||||
// is fixed.
|
||||
/*
|
||||
testWidgets(
|
||||
'CupertinoButton.filled default color contrast meets guideline',
|
||||
(WidgetTester tester) async {
|
||||
// The native color combination systemBlue text over white background fails
|
||||
// to pass the color contrast guideline.
|
||||
//await tester.pumpWidget(
|
||||
// CupertinoTheme(
|
||||
// data: const CupertinoThemeData(),
|
||||
// child: Directionality(
|
||||
// textDirection: TextDirection.ltr,
|
||||
// child: CupertinoButton.filled(
|
||||
// child: const Text('Button'),
|
||||
// onPressed: () {},
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
//);
|
||||
//await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(
|
||||
child: CupertinoButton.filled(
|
||||
child: const Text('Button'),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await expectLater(tester, meetsGuideline(textContrastGuideline));
|
||||
});
|
||||
*/
|
||||
|
||||
testWidgets('Button with background is wider', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(boilerplate(child: const CupertinoButton(
|
||||
child: Text('X', style: testStyle),
|
||||
@@ -145,7 +183,7 @@ void main() {
|
||||
of: find.byType(CupertinoButton),
|
||||
matching: find.byType(FadeTransition),
|
||||
));
|
||||
expect(opacity.opacity.value, 0.1);
|
||||
expect(opacity.opacity.value, 0.4);
|
||||
});
|
||||
|
||||
testWidgets('pressedOpacity parameter', (WidgetTester tester) async {
|
||||
|
||||
@@ -978,19 +978,19 @@ void main() {
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 25));
|
||||
transition = tester.firstWidget(find.byType(FadeTransition));
|
||||
expect(transition.opacity.value, closeTo(0.10, 0.001));
|
||||
expect(transition.opacity.value, closeTo(0.40, 0.001));
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 25));
|
||||
transition = tester.firstWidget(find.byType(FadeTransition));
|
||||
expect(transition.opacity.value, closeTo(0.156, 0.001));
|
||||
expect(transition.opacity.value, closeTo(0.437, 0.001));
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 25));
|
||||
transition = tester.firstWidget(find.byType(FadeTransition));
|
||||
expect(transition.opacity.value, closeTo(0.324, 0.001));
|
||||
expect(transition.opacity.value, closeTo(0.55, 0.001));
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 25));
|
||||
transition = tester.firstWidget(find.byType(FadeTransition));
|
||||
expect(transition.opacity.value, closeTo(0.606, 0.001));
|
||||
expect(transition.opacity.value, closeTo(0.737, 0.001));
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 25));
|
||||
transition = tester.firstWidget(find.byType(FadeTransition));
|
||||
|
||||
Reference in New Issue
Block a user