1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

Make in-season and not-in-season cards different (#67)

This commit is contained in:
xster
2019-04-10 01:23:57 -07:00
committed by GitHub
parent 1ade80f948
commit 46a62e252b
3 changed files with 33 additions and 8 deletions

View File

@@ -76,11 +76,15 @@ class _PressableCardState extends State<PressableCard> {
}
class VeggieCard extends StatelessWidget {
VeggieCard(this.veggie, this.isPreferredCategory);
VeggieCard(this.veggie, this.isInSeason, this.isPreferredCategory);
/// Veggie to be displayed by the card.
final Veggie veggie;
/// If the veggie is in season, it's displayed more prominently and the
/// image is fully saturated. Otherwise, it's reduced and de-saturated.
final bool isInSeason;
/// Whether [veggie] falls into one of user's preferred [VeggieCategory]s
final bool isPreferredCategory;
@@ -119,10 +123,22 @@ class VeggieCard extends StatelessWidget {
},
child: Stack(
children: [
Image.asset(
veggie.imageAssetPath,
fit: BoxFit.cover,
semanticLabel: 'A card background featuring ${veggie.name}',
Semantics(
label: 'A card background featuring ${veggie.name}',
child: Container(
height: isInSeason ? 350 : 150,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
colorFilter: isInSeason
? null
: Styles.desaturatedColorFilter,
image: AssetImage(
veggie.imageAssetPath,
),
),
),
),
),
Positioned(
bottom: 0.0,