Commit 0dacc5e1 authored by Matt Perry's avatar Matt Perry Committed by GitHub

Use a Scaffold for the Pesto recipe page for better appbar behavior. (#4951)

The appbar now scrolls off screen when you scroll the page far enough.

BUG=https://github.com/flutter/flutter/issues/4410
parent ebc7e4b7
...@@ -238,7 +238,7 @@ class _RecipeCard extends StatelessWidget { ...@@ -238,7 +238,7 @@ class _RecipeCard extends StatelessWidget {
children: <Widget>[ children: <Widget>[
new Image( new Image(
image: new AssetImage(recipe.imagePath), image: new AssetImage(recipe.imagePath),
fit: ImageFit.scaleDown fit: ImageFit.contain
), ),
new Flexible( new Flexible(
child: new Row( child: new Row(
...@@ -282,25 +282,18 @@ class _RecipePage extends StatefulWidget { ...@@ -282,25 +282,18 @@ class _RecipePage extends StatefulWidget {
} }
class _RecipePageState extends State<_RecipePage> { class _RecipePageState extends State<_RecipePage> {
static final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
final TextStyle menuItemStyle = _textStyle(15.0).copyWith(color: Colors.black54, height: 24.0/15.0); final TextStyle menuItemStyle = _textStyle(15.0).copyWith(color: Colors.black54, height: 24.0/15.0);
double _getAppBarHeight(BuildContext context) => MediaQuery.of(context).size.height * 0.3;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Overlays a transparent app bar onto the page. We can't use a Scaffold return new Scaffold(
// here because that doesn't allow us to overlap the app bar on top of the key: _scaffoldKey,
// content. appBarBehavior: AppBarBehavior.scroll,
final double statusBarHeight = MediaQuery.of(context).padding.top; appBar: new AppBar(
return new Stack( expandedHeight: _getAppBarHeight(context),
children: <Widget>[
_buildContainer(context),
new Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
child: new Container(
height: kToolBarHeight + statusBarHeight,
padding: new EdgeInsets.only(top: statusBarHeight),
child: new AppBar(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
elevation: 0, elevation: 0,
leading: new IconButton( leading: new IconButton(
...@@ -318,11 +311,12 @@ class _RecipePageState extends State<_RecipePage> { ...@@ -318,11 +311,12 @@ class _RecipePageState extends State<_RecipePage> {
_buildMenuItem(Icons.people, 'Share on Facebook'), _buildMenuItem(Icons.people, 'Share on Facebook'),
] ]
) )
] ],
) // This empty space keeps the app bar from moving until the screen is
) // scrolled at least _getAppBarHeight().
) flexibleSpace: new Container()
] ),
body: _buildContainer(context)
); );
} }
...@@ -350,7 +344,7 @@ class _RecipePageState extends State<_RecipePage> { ...@@ -350,7 +344,7 @@ class _RecipePageState extends State<_RecipePage> {
child: new Block( child: new Block(
children: <Widget>[ children: <Widget>[
new Padding( new Padding(
padding: new EdgeInsets.only(top: screenSize.height*0.3), padding: new EdgeInsets.only(top: _getAppBarHeight(context)),
child: new Stack( child: new Stack(
children: <Widget>[ children: <Widget>[
new Padding( new Padding(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment