-
Notifications
You must be signed in to change notification settings - Fork 29.8k
CupertinoDatePicker & CupertinoTimerPicker dark mode #39919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b53e3cf to
93dcac2
Compare
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
| (widget.backgroundColor.alpha * _kForegroundScreenOpacityFraction).toInt() | ||
| Widget _buildMagnifierScreen(Color resolved) { | ||
| final Color foreground = resolved?.withAlpha( | ||
| (resolved.alpha * _kForegroundScreenOpacityFraction).toInt() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comma at the end here if you have time, I know it was already like that :) Also the identical line below.
|
As we roll out these color changes, is the plan to change default background colors everywhere to transparent if they're white? |
HansMuller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| /// Background color of date picker. | ||
| /// | ||
| /// Defaults to [CupertinoColors.white] when null. | ||
| /// Defaults to null, which disables background painting entirely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include this detail in the issue's description, explain that we're making the change to improve fidelity wrt native iOS, and include before/after screenshots to help developers understand what's changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the description
| @override | ||
| Widget build(BuildContext context) { | ||
| Widget result = DefaultTextStyle( | ||
| final Color resolvedBackgroundColor = widget.backgroundColor == null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this idiom crops up enough, maybe we should allow CupertinoDyanmicColor.resolve(null, context)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything to change now that that PR has been merged?
The main reason the picker is made transparent in this PR is that the native iOS |
|
@HansMuller @justinmc updated |
|
It includes changes from #33070, in order for the opacity layer to work properly. |
|
The new changes look good to me; just had a few small comments. |
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The only important thing to check is a potentially incorrect > commented above.
| color: foreground, | ||
| ), | ||
| ), | ||
| Expanded(child: Container()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you still need the container now that there is no color? Or, could the Expanded be replaced with a Spacer? Also line 265 below.
I'm not sure, just throwing some ideas out there :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah makes sense. I'm going to just center the middle Container
| double _offCenterOpacity = 1.0; | ||
| set offCenterOpacity(double value) { | ||
| assert(value != null); | ||
| assert(value > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be value >= 0? Looking at your comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah forgot to change it. nice catch!
| @override | ||
| Widget build(BuildContext context) { | ||
| Widget result = DefaultTextStyle( | ||
| final Color resolvedBackgroundColor = widget.backgroundColor == null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything to change now that that PR has been merged?
bin/internal/goldens.version
Outdated
| @@ -1 +1 @@ | |||
| 49f8198b72f6e12c65fe1db2e46162de0204e671 | |||
| 38e117bcd79860a3f239872c579acac716e70d49 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit does not appear to exist in https://github.com/flutter/goldens/commits/master which is causing these golden file tests to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry I haven't merged the golden PR yet. I changed the golden hash to prevent flutter test from resetting the head to master so I can test with my golden fork. I'll update it once the golden PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
| _paintChildCylindrically(context, offset, child, transform, offsetToCenter); | ||
| else | ||
| final bool shouldApplyOffCenterDim = offCenterOpacity < 1; | ||
| if (useMagnifier || shouldApplyOffCenterDim) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good place for extra curly braces
| magnifierTopLinePosition); | ||
|
|
||
| // Clipping the part in the center. | ||
| context.pushClipRect( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting suggestion:
context.pushClipRect(
needsCompositing,
offset,
centerRect,
(PaintingContext context, Offset offset) {
context.pushTransform(
needsCompositing,
offset,
_magnifyTransform(),
(PaintingContext context, Offset offset) {
context.paintChild(child, offset + untransformedPaintingCoordinates);
},
);
},
);
| }, | ||
| offCenterOpacity == 1 | ||
| ? innerPainter | ||
| : (PaintingContext context, Offset offset) => context.pushOpacity(offset, (offCenterOpacity * 255).round(), innerPainter), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factoring innerPaint out into a local function (with a helpful comment!) seems like a good idea. Maybe do the same for the other clause. Also: prefer => for one-liners that return a value.
| /// | ||
| /// Must be greater than or equal to 0, and less than or equal to 1. | ||
| /// {@endtemplate} | ||
| double get offCenterOpacity => _offCenterOpacity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we had a better name for this property - "off center" sounds a bit like askew.
Maybe overAndUnderCenterOpacity?
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goldens look good to me! Thanks! The bot may notify you about triage on Flutter Gold when this lands. Let me know if you have any questions. :)
This reverts commit 97b27fa.
|
9c6dd0d seems to cause the golden test to fail |
…#39919)" (flutter#41521)" This reverts commit 5f9c262.
|
@LongCatIsLooong which to me means that gradient painting is only disabled when background is null, however, it seems like you removed the gradient entirely, and it's now impossible to get the same gradient effect as before. Am I right? If so, this causes a problem for me and how I was using this widget. Is there a reason for that? Thanks! |
|
@dannyvalentesonos yes the gradient was removed entirely. The gradient has hardcoded colors that didn't work well with a dark background so it was removed. |
Description
CupertinoDatePickerandCupertinoTimerPickertonull, which disables background painting entirely (i.e. the picker is going to have a completely transparent background), to match the nativeUIPickerandUIDatePicker.backgroundColor = nullGolden Changes
https://github.com/flutter/goldens/pull/43/files?short_path=0bfad5e#diff-0bfad5e92f7d3a6380af2f64b62d3cf2
Related Issues
#35541
Mitigates #39685
TODO: #16831
Screenshots over black background, with
backgroundColor = null.The font color is set to blue so it's visible in both screenshots.
Tests
I added the following tests:
picker dark mode
Fixed goldens.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?