Skip to content

Conversation

guidezpl
Copy link
Member

@guidezpl guidezpl commented Jan 28, 2020

TLDR: Fixes a bugs on both desktop and mobile which caused demo state to be reset.
This was caused by rendering different trees; on mobile: based on whether the options/info panels were open; on desktop, based on whether the demo was in fullscreen. Additionally on desktop, it seemed that conditionally rendering the sized box (or container) preceding the demoContent caused the demoContent widget to be fully rebuilt. Instead, I always specify its width.

This PR also removes width calculations, instead specifying a max width for info and options panes. This incidentally causes the demoContent to remain the same width regardless of the chosen section on desktop. The demoContent grows with the screen size, as before. The section on the left grows until the specified max width.

Screen Shot 2020-01-28 at 11 57 23 AM

Screen Shot 2020-01-28 at 11 57 27 AM

Screen Shot 2020-01-28 at 11 57 29 AM

Screen Shot 2020-01-28 at 11 57 39 AM

Closes material-components/material-components-flutter-gallery#312

crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (!isFullScreen) Expanded(child: section),
SizedBox(width: !isFullScreen ? 48.0 : 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be easier to read as:

if (!isFullScreen) ...[
  Expanded(child: section),
  SizedBox(),
]
Expanded(child: demoContent),

Copy link
Member Author

@guidezpl guidezpl Jan 28, 2020

Choose a reason for hiding this comment

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

This is what I was saying causes the demoContent to be rebuilt from scratch. I could write it as

if (!isFullScreen) ...[
  Expanded(child: section),
  SizedBox(width: 48.0),
]
SizedBox(),
Expanded(child: demoContent),

and it works. It's puzzling

Copy link
Contributor

Choose a reason for hiding this comment

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

Very strange...ok I think I prefer what you originally had instead of the 2nd sizedbox

child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (_state != _DemoState.normal) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the gestureDetector is added always now, does this interfere with interacting with the demo?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tested on chrome, iOS and macOS, and saw no adverse effects. I'll remove behavior: HitTestBehavior.opaque because it's not doing anything here and might be confusing

color: colorScheme.onSurface,
fontSizeDelta:
isDisplayDesktop(context) ? desktopDisplay1FontDelta : 0,
return Align(
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the Align for?

Copy link
Member Author

Choose a reason for hiding this comment

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

A Container within an Expanded will fill the space, even if you set width/height constraints, unless you use an Align.

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.

Fullscreen desktop demo resets state (2)
2 participants