Skip to content

Conversation

ADVavvas
Copy link
Contributor

This was done to handle styling in a manner more in keeping with current SDK capabilities. (Issue #322 )

Copy link
Contributor

@redbrogdon redbrogdon left a 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?

@ADVavvas
Copy link
Contributor Author

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).

  1. Changing IOS theme while the app is running doesn't update the "In Season Today" headline color (Probably because the widget is not rebuilding?)
  2. On the 'Home' and 'Search' tabs the status bar color (time, wifi, battery) doesn't change (if you change theme while the app is running). It does change if you go to 'My Garden' or 'Settings' (probably because they have a NavigationBar)

Copy link
Contributor

@redbrogdon redbrogdon left a 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,

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.

Copy link
Contributor Author

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.

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),

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,.

Copy link
Contributor Author

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.

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),

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.

Copy link
Contributor Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On iOS 13+ UISegmentedControls 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?)

@ADVavvas
Copy link
Contributor Author

That should be all the changes (except #2).

Thanks you both! Appreciate the feedback.
Let me know if there's anything else.

Copy link
Contributor

@redbrogdon redbrogdon left a 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?

Copy link

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits.

@LongCatIsLooong
Copy link

LongCatIsLooong commented Nov 20, 2020

Ah didn't notice this

On the 'Home' and 'Search' tabs the status bar color (time, wifi, battery) doesn't change (if you change theme while the app is running). It does change if you go to 'My Garden' or 'Settings' (probably because they have a NavigationBar)

I thought this bug has long been fixed, but the status bar icons are not visible on my android device either. Taking a look.

The system chrome logic lives in the CupertinoNavigationBar class so it does not work if the page doesn't have a nav bar (such is the case of the home page and the search page). I guess we can manually add an AnnotatedRegion<SystemUiOverlayStyle> to the tree.

@ADVavvas
Copy link
Contributor Author

Added the AnnotatedRegion<SystemUiOverlayStyle> on both list.dart and search.dart. Not sure where exactly to place it in the tree, so I'd appreaciate if you could take a look @LongCatIsLooong . Works fine though. Also removed the unnecessary imports.

},
return AnnotatedRegion<SystemUiOverlayStyle>(
value:
SystemUiOverlayStyle(statusBarBrightness: themeData.brightness),

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.

Copy link
Contributor Author

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)

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.

Copy link

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ADVavvas
Copy link
Contributor Author

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?

@LongCatIsLooong
Copy link

@ADVavvas sorry for the late reply. I'm not particularly familiar with the samples repo procedures. @redbrogdon is it good to merge this PR?

@redbrogdon
Copy link
Contributor

Yes, this is ready to land. I would have done it last week, but was out for Thanksgiving. 🦃

@redbrogdon redbrogdon merged commit 7c5fecb into flutter:master Dec 2, 2020
@redbrogdon
Copy link
Contributor

@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. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants