Skip to content

Create a CupertinoScaffold#10543

Merged
xster merged 10 commits into
flutter:masterfrom
xster:cupertino-scaffold
Jun 13, 2017
Merged

Create a CupertinoScaffold#10543
xster merged 10 commits into
flutter:masterfrom
xster:cupertino-scaffold

Conversation

@xster

@xster xster commented Jun 7, 2017

Copy link
Copy Markdown
Member

#10466

In this PR:

  • Basic layout structure, positions nav bar and tab bar in it
  • A tabbed content area that connects with a tab bar automatically

Not in this PR:

  • Navigation and gestures
  • Different navigator stack per tab

@xster
xster requested review from HansMuller, Hixie and cbracken June 7, 2017 03:06
@xster
xster force-pushed the cupertino-scaffold branch from a121c89 to af90fca Compare June 7, 2017 03:09

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This works but isn't very efficient. The IndexedStack builds all of them right at the beginning. Don't know if there's something reusable to not build them until needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah we definitely don't want to use an IndexedStack here.
...
...
(long in-person discussion)
...
...
We concluded we want to use a Stack, lazily inflate the children so that you only inflate them once they've been picked, then keep them in the tree, and you want to use TickerMode and Offstage to keep them cheaper.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe instead of a Stack use a CustomMultiChildLayout so you can stop them being laid out as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe I'm misapplying it. Did you mean give it a MultiChildLayoutDelegate and have it just layout and position the active tab only? I'm getting

The _TabViewLayout custom multichild layout delegate forgot to lay out the following child:
  1: RenderOffstage#1048774387 NEEDS-LAYOUT NEEDS-PAINT
Each child must be laid out exactly once.

Or did you just mean to layout all the children with the delegate but don't do any complex calculations, just let them have the size of the parent all the time?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think you got a merge error here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we normally call this copyWith()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

...and list all the arguments. Search for examples of "copyWith" to crib from.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah right, should have remembered the convention. Thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems dangerous... what if you keep applying it to the object you get back? Eventually you'll have this really long chain of callbacks...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ya, made the copyWith generic, put the logic to the caller in scaffold

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s/the/a/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are built

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Usually you want the first paragraph to be just one sentence. The first paragraph is what ends up being used as the "short doc" in the API doc summaries.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing comma before "is"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and and

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this last sentence is confusing. I'm not sure it's worth including, honestly, but if you do want to be explicit about this I think it needs to be clearer what this means.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

reworded

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[.tabbed] should be [new CupertinoScaffold.tabbed] I believe

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks! Adam told me once but I forgot how it worked

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

offline chat summary:
Make a custom private mechanism that uses offstage, tickermode and a custom lazy builder

motivations:

  • lazy build initially
  • stop animations for offscreen
  • keep offscreen subtrees alive

@xster xster left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not really ready for review again yet. Needs more testing. Just sending a batch review replies (and pushing from my home repo)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah right, should have remembered the convention. Thanks

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ya, made the copyWith generic, put the logic to the caller in scaffold

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks! Adam told me once but I forgot how it worked

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

reworded

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe I'm misapplying it. Did you mean give it a MultiChildLayoutDelegate and have it just layout and position the active tab only? I'm getting

The _TabViewLayout custom multichild layout delegate forgot to lay out the following child:
  1: RenderOffstage#1048774387 NEEDS-LAYOUT NEEDS-PAINT
Each child must be laid out exactly once.

Or did you just mean to layout all the children with the delegate but don't do any complex calculations, just let them have the size of the parent all the time?

@xster xster closed this Jun 9, 2017
@xster xster changed the title Create a CupertinoScaffold [Draft] Create a CupertinoScaffold Jun 9, 2017
@xster

xster commented Jun 9, 2017

Copy link
Copy Markdown
Member Author

Ummm it doesn't properly update to my branch anymore once I close it. I'll reopen it, mainly to get some broader feedback. The classes documentations aren't updated yet.

@xster xster reopened this Jun 9, 2017
@xster
xster force-pushed the cupertino-scaffold branch from 8c66e4b to 2083a28 Compare June 9, 2017 02:04
@Hixie

Hixie commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

I guess I was wrong about MultiChildCustomLayout. Disregard me. :-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: here and below, put the colon on the same line as the }), as in

}) : tabBar = null,
     rootTabPageBuilder = null,
...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. I must have triggered the formatter without selecting a text range at some point

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think this would be easier to read on one line...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oops, drive by change. I gotta find a way to disable the formatter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should also rebuild it if we've ever built it before, otherwise we'll be leaving stale widgets in the tree and no way to remove them (e.g. suppose one is a video, and the build function only includes the video if the tab is active -- if you don't rebuild the tab, you'll be leaving an active video and no way to remove it).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was hoping we can keep it as simple as possible let the user handle edge cases by listening to their own supplied tab bar's onTap callbacks if needed.

But I think I may have to address it anyway with some version of solution to the problem you're describing in the next PR once I start putting in the Navigators. I think I'd like to tie that API together with the various page routes' maintainState concepts etc.

Adding todo to the issues

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These aren't edge cases. The contract when you have a builder is that you'll call it any time you build. Putting in old widgets is going to be a weird quirk that will lead to bugs. We should just call the builders.

It's fine to not call them until you need them, but once you're including them, you should call them (or not use a builder).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ok, done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: extraneous space

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the docs for child and rootTabPageBuilder should clarify that they can't both be non-null, that one must be non-null, and they should each point to the relevant constructor.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

@Hixie

Hixie commented Jun 12, 2017

Copy link
Copy Markdown
Contributor

LGTM

@xster
xster force-pushed the cupertino-scaffold branch from 5fe0e92 to 6e7944a Compare June 12, 2017 19:39
@xster xster changed the title [Draft] Create a CupertinoScaffold Create a CupertinoScaffold Jun 12, 2017
@xster

xster commented Jun 12, 2017

Copy link
Copy Markdown
Member Author

For posterity, moved back to Stack for readability simplicity. Tweaked docs and added tests.
Performance behaviour looks as expected.
ky2bgr2dwby

No frames are triggered until tabs are changed and only one frame is redrawn per tab.

@xster
xster force-pushed the cupertino-scaffold branch from 0a9d0e6 to f07d4ab Compare June 12, 2017 20:16
@xster
xster merged commit e38f92d into flutter:master Jun 13, 2017
@xster
xster deleted the cupertino-scaffold branch June 13, 2017 05:48
@Hixie

Hixie commented Jun 13, 2017

Copy link
Copy Markdown
Contributor

(This raised our technical debt by about $9,000. This is fine, just reporting this for transparency.)

@xster

xster commented Jun 13, 2017

Copy link
Copy Markdown
Member Author

Ha, was it all the TODOs? Hope the interest rates aren't too high for a week or so.

@Hixie

Hixie commented Jun 13, 2017

Copy link
Copy Markdown
Contributor

Yup. :-)

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants