Add transparent color to Cupertino colors (#150149)
The Cupertino library doesn't have the transparent color constant that the Material library has. Added to increase code readability. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes
This commit is contained in:
parent
e110fdd1c9
commit
0aadb89764
@ -76,6 +76,13 @@ abstract final class CupertinoColors {
|
||||
/// * [white], opaque white in the [CupertinoColors] palette.
|
||||
static const Color black = Color(0xFF000000);
|
||||
|
||||
/// A fully-transparent color, completely invisible.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [material.Colors.transparent], the same color, in the Material Design palette.
|
||||
static const Color transparent = Color(0x00000000);
|
||||
|
||||
/// Used in iOS 10 for light background fills such as the chat bubble background.
|
||||
///
|
||||
/// This is SystemLightGrayColor in the iOS palette.
|
||||
|
@ -854,7 +854,7 @@ class _CupertinoEdgeShadowDecoration extends Decoration {
|
||||
// Eyeballed gradient used to mimic a drop shadow on the start side only.
|
||||
<Color>[
|
||||
Color(0x04000000),
|
||||
Color(0x00000000),
|
||||
CupertinoColors.transparent,
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -465,7 +465,7 @@ class _RenderCupertinoTextSelectionToolbarShape extends RenderShiftedBox {
|
||||
..shader = ui.Gradient.linear(
|
||||
Offset.zero,
|
||||
const Offset(10.0, 10.0),
|
||||
const <Color>[Color(0x00000000), Color(0xFFFF00FF), Color(0xFFFF00FF), Color(0x00000000)],
|
||||
const <Color>[CupertinoColors.transparent, Color(0xFFFF00FF), Color(0xFFFF00FF), CupertinoColors.transparent],
|
||||
const <double>[0.25, 0.25, 0.75, 0.75],
|
||||
TileMode.repeated,
|
||||
)
|
||||
|
@ -132,9 +132,9 @@ class _CupertinoTextSelectionToolbarButtonState extends State<CupertinoTextSelec
|
||||
final Widget child = CupertinoButton(
|
||||
color: isPressed
|
||||
? _kToolbarPressedColor.resolveFrom(context)
|
||||
: const Color(0x00000000),
|
||||
: CupertinoColors.transparent,
|
||||
borderRadius: null,
|
||||
disabledColor: const Color(0x00000000),
|
||||
disabledColor: CupertinoColors.transparent,
|
||||
// This CupertinoButton does not actually handle the onPressed callback,
|
||||
// this is only here to correctly enable/disable the button (see
|
||||
// GestureDetector comment below).
|
||||
|
@ -283,7 +283,7 @@ void main() {
|
||||
final BoxDecoration? boxDecoration = (tester.firstWidget(decoyChildDescendant) as Container).decoration as BoxDecoration?;
|
||||
const List<Color?> expectedColors = <Color?>[null, Color(0x00000000)];
|
||||
|
||||
// `Color(0x00000000)` -> Is `Colors.transparent`.
|
||||
// `Color(0x00000000)` -> Is `CupertinoColors.transparent`.
|
||||
// `null` -> Default when no color argument is given in `BoxDecoration`.
|
||||
// Any other color won't preserve the child's property.
|
||||
expect(expectedColors, contains(boxDecoration?.color));
|
||||
|
@ -1489,11 +1489,11 @@ void main() {
|
||||
final RenderBox box = tester.firstRenderObject<RenderBox>(find.byType(CustomPaint));
|
||||
|
||||
// Animation starts with effectively no shadow
|
||||
expect(box, paintsShadowRect(dx: 795, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 785, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 775, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 765, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 755, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 795, color: CupertinoColors.transparent));
|
||||
expect(box, paintsShadowRect(dx: 785, color: CupertinoColors.transparent));
|
||||
expect(box, paintsShadowRect(dx: 775, color: CupertinoColors.transparent));
|
||||
expect(box, paintsShadowRect(dx: 765, color: CupertinoColors.transparent));
|
||||
expect(box, paintsShadowRect(dx: 755, color: CupertinoColors.transparent));
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
@ -1501,8 +1501,8 @@ void main() {
|
||||
expect(box, paintsShadowRect(dx: 296, color: const Color(0x03000000)));
|
||||
expect(box, paintsShadowRect(dx: 286, color: const Color(0x02000000)));
|
||||
expect(box, paintsShadowRect(dx: 276, color: const Color(0x01000000)));
|
||||
expect(box, paintsShadowRect(dx: 266, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 266, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 266, color: CupertinoColors.transparent));
|
||||
expect(box, paintsShadowRect(dx: 266, color: CupertinoColors.transparent));
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@ -1512,7 +1512,7 @@ void main() {
|
||||
expect(box, paintsShadowRect(dx: -10, color: const Color(0x03000000)));
|
||||
expect(box, paintsShadowRect(dx: -20, color: const Color(0x02000000)));
|
||||
expect(box, paintsShadowRect(dx: -30, color: const Color(0x01000000)));
|
||||
expect(box, paintsShadowRect(dx: -40, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: -40, color: CupertinoColors.transparent));
|
||||
|
||||
// Start animation in reverse
|
||||
tester.state<NavigatorState>(find.byType(Navigator)).pop();
|
||||
@ -1523,16 +1523,16 @@ void main() {
|
||||
expect(box, paintsShadowRect(dx: 488, color: const Color(0x03000000)));
|
||||
expect(box, paintsShadowRect(dx: 478, color: const Color(0x02000000)));
|
||||
expect(box, paintsShadowRect(dx: 468, color: const Color(0x01000000)));
|
||||
expect(box, paintsShadowRect(dx: 458, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 458, color: CupertinoColors.transparent));
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 150));
|
||||
|
||||
// At the end of the animation, the shadow approaches full transparency
|
||||
expect(box, paintsShadowRect(dx: 794, color: const Color(0x01000000)));
|
||||
expect(box, paintsShadowRect(dx: 784, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 774, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 764, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 754, color: const Color(0x00000000)));
|
||||
expect(box, paintsShadowRect(dx: 784, color: CupertinoColors.transparent));
|
||||
expect(box, paintsShadowRect(dx: 774, color: CupertinoColors.transparent));
|
||||
expect(box, paintsShadowRect(dx: 764, color: CupertinoColors.transparent));
|
||||
expect(box, paintsShadowRect(dx: 754, color: CupertinoColors.transparent));
|
||||
});
|
||||
|
||||
testWidgets('when route is fullscreenDialog, it has no visible _CupertinoEdgeShadowDecoration', (WidgetTester tester) async {
|
||||
@ -2020,8 +2020,6 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup transparent barrier color is transparent', (WidgetTester tester) async {
|
||||
const Color kTransparentColor = Color(0x00000000);
|
||||
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: Builder(builder: (BuildContext context) {
|
||||
@ -2030,7 +2028,7 @@ void main() {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const SizedBox(),
|
||||
barrierColor: kTransparentColor,
|
||||
barrierColor: CupertinoColors.transparent,
|
||||
);
|
||||
},
|
||||
child: const Text('tap'),
|
||||
|
@ -47,7 +47,7 @@ void main() {
|
||||
matching: find.byType(DecoratedBox),
|
||||
));
|
||||
BoxDecoration boxDecoration = decoratedBox.decoration as BoxDecoration;
|
||||
expect(boxDecoration.color, const Color(0x00000000));
|
||||
expect(boxDecoration.color, CupertinoColors.transparent);
|
||||
|
||||
// Make a "down" gesture on the button.
|
||||
final Offset center = tester.getCenter(find.byType(CupertinoTextSelectionToolbarButton));
|
||||
@ -72,7 +72,7 @@ void main() {
|
||||
matching: find.byType(DecoratedBox),
|
||||
));
|
||||
boxDecoration = decoratedBox.decoration as BoxDecoration;
|
||||
expect(boxDecoration.color, const Color(0x00000000));
|
||||
expect(boxDecoration.color, CupertinoColors.transparent);
|
||||
});
|
||||
|
||||
testWidgets('passing null to onPressed disables the button', (WidgetTester tester) async {
|
||||
|
@ -205,7 +205,7 @@ void main() {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/47651.
|
||||
expect(
|
||||
const CupertinoTheme(
|
||||
data: CupertinoThemeData(primaryColor: Color(0x00000000)),
|
||||
data: CupertinoThemeData(primaryColor: CupertinoColors.transparent),
|
||||
child: SizedBox(),
|
||||
).toStringDeep().trimRight(),
|
||||
isNot(contains('\n')),
|
||||
|
Loading…
x
Reference in New Issue
Block a user