feat: refactor recipe detail screen to use CustomScrollView and SliverAppBar for improved layout

This commit is contained in:
Nils-Johan Gynther
2026-04-24 10:45:19 +02:00
parent 931336f048
commit 0cc56d65b7
@@ -45,24 +45,31 @@ class RecipeDetailScreen extends ConsumerWidget {
message: mapErrorToUserMessage(error, context), message: mapErrorToUserMessage(error, context),
onRetry: () => ref.invalidate(recipeDetailProvider(recipeId)), onRetry: () => ref.invalidate(recipeDetailProvider(recipeId)),
), ),
data: (recipe) => Stack( data: (recipe) => CustomScrollView(
children: [ slivers: [
if (recipe.imageUrl != null) SliverAppBar(
SizedBox( expandedHeight: MediaQuery.of(context).size.height * 2 / 3,
height: MediaQuery.of(context).size.height * 2 / 3, flexibleSpace: FlexibleSpaceBar(
child: Image.network( background: recipe.imageUrl != null
? Image.network(
recipe.imageUrl!, recipe.imageUrl!,
fit: BoxFit.cover, fit: BoxFit.cover,
width: double.infinity, )
alignment: Alignment.topCenter, : Container(color: Colors.grey[200]),
),
pinned: true,
floating: false,
),
SliverToBoxAdapter(
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
), ),
), ),
SingleChildScrollView( child: _RecipeBody(recipe: recipe),
child: Column(
children: [
SizedBox(height: MediaQuery.of(context).size.height * 2 / 3),
_RecipeBody(recipe: recipe),
],
), ),
), ),
], ],