-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Styling revamp using CupertinoThemeData and CupertinoTextThemeData #593
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
Styling revamp using CupertinoThemeData and CupertinoTextThemeData #593
Conversation
… handle dark mode
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.
Thanks for the PR, @ADVavvas. Has this been tested with both light and dark mode?
Hi, forgot to include an important addition to my PR. Should be working fine now for both light and dark mode. There are still 2 issues with the light/dark theme (although I'm not too sure how to deal with them).
|
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.
Thanks, @ADVavvas. This PR looks pretty good. I just have a few comments, which are inline.
For #2, I am able to replicate the issue, but I'm not sure whether it's something wrong with this app or an SDK bug. @LongCatIsLooong, would you mind taking a look? Steps to reproduce are:
- Launch Veggieseasons in light mode.
- Switch to the "My Garden" screen using the bottom navigation bar.
- Switch back to the "Home" screen.
- Change from light mode to dark mode using iOS developer settings.
- Return to the app, and the status bar across the top will have no visible text for time, battery, etc.
- Switch to the "My Garden" screen, and white text will appear in the status bar.
- Return to the "Home" screen, and the white text will remain.
This is on an iPhone SE Simulator running iOS 14, with this flutter doctor
output:
[✓] Flutter (Channel master, 1.24.0-8.0.pre.267, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Community Edition (version 2020.1.2)
[✓] VS Code (version 1.50.1)
[✓] Connected device (4 available)
Is that WAI and there's something we're doing wrong in this app, or is the SDK not behaving itself?
|
||
return Text( | ||
'$percent% DV', | ||
style: CupertinoTheme.of(context).textTheme.textStyle, |
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.
nit: is it needed to explicitly specify the text style? I'd expect the Text
widget to inherit the style from the theme.
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.
Perhaps I've done something wrong in assigning the theme to the whole app, but removing the style
makes the text black regardless of the IOS brightness.
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.
Does it work if you wrap the DetailsScreen
widget in a DefaultTextStyle(style: CupertinoTheme.of(context).textTheme.textStyle)
widget? Anyways not a big deal it just makes the code a little bit more verbose.
); | ||
static TextStyle minorText(CupertinoThemeData themeData) => | ||
themeData.textTheme.textStyle.copyWith( | ||
color: Color.fromRGBO(128, 128, 128, 1), |
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.
It seems like we're using a regular color. Is "minorText" supposed to use the same color when you switch from light mode to dark mode? Same with "cardTitleText" and "cardCategoryText", etc,.
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.
minorText
is used for the date in the Home Screen. It looks okay with both themes since it's grey.
The cards are all white with black text, which also works fine since they have a picture (and shadows).
I haven't changed any of these values. I assume it was intentional.
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 see. The cards all have very bright backgrounds because of the images they used. Make sense to opt-out of dark mode on the cards.
1: Text( | ||
'Trivia', | ||
) | ||
//style: CupertinoTheme.of(context).textTheme.textStyle), |
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 vaguely remember CupertinoSegmentedControl
doesn't work well with dark mode, because the UI component no longer exists on iOS 13 and above.
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.
Seems okay on IOS 13.1.
Blue background with black letters for selected. Black background with blue letters for unselected.
Have not applied any styling to the its children.
Not sure what it's supposed to look like.
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.
On iOS 13+ UISegmentedControl
s have a different look so I'm not sure either what it is supposed to look like. I'm okay with this since there's no actual code change (could you remove the lines that are commented out?)
That should be all the changes (except #2). Thanks you both! Appreciate the feedback. |
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 LGTM. @LongCatIsLooong, WDYT?
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 with nits.
Ah didn't notice this
The system chrome logic lives in the |
Added the |
}, | ||
return AnnotatedRegion<SystemUiOverlayStyle>( | ||
value: | ||
SystemUiOverlayStyle(statusBarBrightness: themeData.brightness), |
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.
CupertinoThemeData.brightness
is the brightness override and it's nullable. I think this should be MediaQuerty.brightnessOf(context)
. Same with the search page.
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.
Done! Ignore the first commit (wrote MediaQuery.of(context).platformBrightness
instead. Not sure if that makes any difference)
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.
IIRC they're the same.
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.
Thank you!
Quick question since this is my 1st PR: Do I need to do anything else or is it going to be merged at some point? |
@ADVavvas sorry for the late reply. I'm not particularly familiar with the samples repo procedures. @redbrogdon is it good to merge this PR? |
Yes, this is ready to land. I would have done it last week, but was out for Thanksgiving. 🦃 |
@ADVavvas, thanks for sticking with this PR through all the review. It's definitely an improvement. I wrote that original text styling two years ago -- it was seriously out of date, but I had no time to fix it. 😄 |
This was done to handle styling in a manner more in keeping with current SDK capabilities. (Issue #322 )