Skip to content

Add a bottom app bar to the floating action button motion demo.#16196

Merged
DaveShuckerow merged 161 commits intoflutter:masterfrom
DaveShuckerow:bab-demo
Apr 4, 2018
Merged

Add a bottom app bar to the floating action button motion demo.#16196
DaveShuckerow merged 161 commits intoflutter:masterfrom
DaveShuckerow:bab-demo

Conversation

@DaveShuckerow
Copy link
Contributor

@HansMuller here is the updated demo.

Dave Shuckerow added 30 commits January 12, 2018 14:36
Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

This looks good and thanks for bringing it to the finish line!

Most of the feedback is just nit pickery.

const _FabLocationConfiguration('End, undocked above the bottom app bar', _BabMode.END_FAB, FloatingActionButtonLocation.endFloat),
const _FabLocationConfiguration('Center, docked to the bottom app bar', _BabMode.CENTER_FAB, const _CenterDockedFloatingActionButtonLocation()),
const _FabLocationConfiguration('End, docked to the bottom app bar', _BabMode.END_FAB, const _EndDockedFloatingActionButtonLocation()),
const _FabLocationConfiguration('Start, docked to the top app bar', _BabMode.CENTER_FAB, const _TopStartFloatingActionButtonLocation()),
Copy link
Contributor

Choose a reason for hiding this comment

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

In the new version of the old demo (ha!) this location is called _StartTopFloatingActionButtonLocation()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After that lands I'll sync.

final List<_FabShapeConfiguration> _fabShapeConfigurations = <_FabShapeConfiguration>[
const _FabShapeConfiguration('None', null),
new _FabShapeConfiguration('Circular',
new Builder(builder: (BuildContext context) {
Copy link
Contributor

@HansMuller HansMuller Apr 3, 2018

Choose a reason for hiding this comment

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

It's a shame that this Build is needed (to create a context from which the Scaffold can be found).

It would be slightly preferable to give the Scaffold a global _scaffoldKey and have _showSnackbar() dispense with the context argument and _scaffoldKey.currentState.showSnackBar().

This is a common pattern in the gallery demos.

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, thanks for the suggestion.

);
}

Widget controls(BuildContext context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

buildControls() for consistency.

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

// The currently-selected Color for the Bottom App Bar.
Color babColor;

List<Color> babColors = <Color> [
Copy link
Contributor

Choose a reason for hiding this comment

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

static const 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.

Done

new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
new Container(width: 96.0,
Copy link
Contributor

Choose a reason for hiding this comment

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

width: on its own line

SizedBox would be a little tider than Container.

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

}

// A bottom app bar with a menu inside it.
class MyBottomAppBar extends StatelessWidget {
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, give this a _FooBottomAppBar name

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

);
}

Widget babContents(BuildContext context, _BabMode babMode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

buildContents()

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

),
);
}
rowContents.addAll(<Widget> [
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be const <Widget> [ 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.

The widgets inside are newed because of their empty onPressed callbacks.

}

// A drawer that pops up from the bottom of the screen.
class MyDrawer extends StatelessWidget {
Copy link
Contributor

Choose a reason for hiding this comment

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

_FooDrawer

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

return new Material(
shape: const _DiamondBorder(),
color: Colors.orange,
//onPressed: widget.onPressed,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Old code. Removed.

@DaveShuckerow
Copy link
Contributor Author

PTAL

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

Just needs a few cleanups.

LGTM

const _FabShapeConfiguration('None', null),
new _FabShapeConfiguration('Circular',
new FloatingActionButton(
onPressed: () => _showSnackbar(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This can just be onPressed: _showSnackBar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tearoff applied

),
new _FabShapeConfiguration('Diamond',
new _DiamondFab(
onPressed: () => _showSnackbar(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This can just be onPressed: _showSnackBar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tearoff applied

value: color,
groupValue: babColor,
onChanged: (Color color) { setState(() { babColor = color; }); },
)
Copy link
Contributor

Choose a reason for hiding this comment

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

trailing comma (here and elsewhere)

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

}
}

// TODO: Add support for making these docked configurations handle the Bottom App Bar being absent.
Copy link
Contributor

Choose a reason for hiding this comment

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

The docked classes shouldn't be here anymore

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

@DaveShuckerow DaveShuckerow merged commit 68c77e3 into flutter:master Apr 4, 2018
@DaveShuckerow DaveShuckerow deleted the bab-demo branch April 4, 2018 02:30
@goderbauer
Copy link
Member

Has it been checked that the demo and the widgets involved are usable with TalkBack/VoiceOver?

@HansMuller
Copy link
Contributor

This demo has not been checked.

@goderbauer
Copy link
Member

Would be cool if that could be done as a follow-up and if potential issues could be fixed.

@Hixie
Copy link
Contributor

Hixie commented Apr 4, 2018

Any code review going forward should verify all of the following for any widgets and demos we commit:

  • full accessibility, so that on both Android and iOS the widget works with the native accessibility tools.
  • full localisation with default translations for all our default languages.
  • full support for both right-to-left and left-to-right layouts, driven by the ambient Directionality.
  • full support for text scaling up to at least 3.0x.
  • documentation for every member; see the section above for writing prompts to write documentation.
  • good performance even when used with large amounts of user data.
  • a complete lifecycle contract with no resource leaks (documented, if it differs from usual widgets).
  • tests for all the above as well as all the unique functionality of the widget itself.

See https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement for up-to-date guidance. Let me know if there's anything about this that we can document better! Thanks.

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.

5 participants