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),
onRetry: () => ref.invalidate(recipeDetailProvider(recipeId)),
),
data: (recipe) => Stack(
children: [
if (recipe.imageUrl != null)
SizedBox(
height: MediaQuery.of(context).size.height * 2 / 3,
child: Image.network(
data: (recipe) => CustomScrollView(
slivers: [
SliverAppBar(
expandedHeight: MediaQuery.of(context).size.height * 2 / 3,
flexibleSpace: FlexibleSpaceBar(
background: recipe.imageUrl != null
? Image.network(
recipe.imageUrl!,
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: Column(
children: [
SizedBox(height: MediaQuery.of(context).size.height * 2 / 3),
_RecipeBody(recipe: recipe),
],
child: _RecipeBody(recipe: recipe),
),
),
],