Make AppBar a Hero (#5214)
This patch improves the Post and Shrine transitions by making the AppBar into a Hero and changing the default MaterialPageTransition. Now the AppBar transitions smoothly between screens and the MaterialPageTransition doesn't involve a fade effect. Also, rejigger the bounds of the image header in Pesto to avoid the "pop" at the end of the animation by laying out the image header at its final visual size instead of relying on occlusion to size the image header. Fixes #5202 Fixes #5204
This commit is contained in:
@@ -59,11 +59,9 @@ class GridDemoPhotoItem extends StatelessWidget {
|
||||
appBar: new AppBar(
|
||||
title: new Text(photo.title)
|
||||
),
|
||||
body: new Material(
|
||||
child: new Hero(
|
||||
tag: photoHeroTag,
|
||||
child: new Image.asset(photo.assetName, fit: ImageFit.cover)
|
||||
)
|
||||
body: new Hero(
|
||||
tag: photoHeroTag,
|
||||
child: new Image.asset(photo.assetName, fit: ImageFit.cover)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -325,9 +325,10 @@ class _RecipePageState extends State<_RecipePage> {
|
||||
// adjusts based on the size of the screen. If the recipe sheet touches
|
||||
// the edge of the screen, use a slightly different layout.
|
||||
Widget _buildContainer(BuildContext context) {
|
||||
bool isFavorite = favoriteRecipes.contains(config.recipe);
|
||||
Size screenSize = MediaQuery.of(context).size;
|
||||
bool fullWidth = (screenSize.width < _kRecipePageMaxWidth);
|
||||
final bool isFavorite = favoriteRecipes.contains(config.recipe);
|
||||
final Size screenSize = MediaQuery.of(context).size;
|
||||
final bool fullWidth = (screenSize.width < _kRecipePageMaxWidth);
|
||||
final double appBarHeight = _getAppBarHeight(context);
|
||||
const double fabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size
|
||||
return new Stack(
|
||||
children: <Widget>[
|
||||
@@ -335,6 +336,7 @@ class _RecipePageState extends State<_RecipePage> {
|
||||
top: 0.0,
|
||||
left: 0.0,
|
||||
right: 0.0,
|
||||
height: appBarHeight + fabHalfSize,
|
||||
child: new Hero(
|
||||
tag: config.recipe.imagePath,
|
||||
child: new Image.asset(
|
||||
@@ -346,7 +348,7 @@ class _RecipePageState extends State<_RecipePage> {
|
||||
new ScrollableViewport(
|
||||
child: new RepaintBoundary(
|
||||
child: new Padding(
|
||||
padding: new EdgeInsets.only(top: _getAppBarHeight(context)),
|
||||
padding: new EdgeInsets.only(top: appBarHeight),
|
||||
child: new Stack(
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
|
||||
Reference in New Issue
Block a user