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

pull/70/head
xster 6 years ago committed by GitHub
parent 1ade80f948
commit 46a62e252b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,7 +13,11 @@ import 'package:veggieseasons/styles.dart';
import 'package:veggieseasons/widgets/veggie_card.dart';
class ListScreen extends StatelessWidget {
List<Widget> _generateVeggieRows(List<Veggie> veggies, Preferences prefs) {
List<Widget> _generateVeggieRows(
List<Veggie> veggies,
Preferences prefs,
{ bool inSeason = true }
) {
final cards = List<Widget>();
for (Veggie veggie in veggies) {
@ -23,7 +27,7 @@ class ListScreen extends StatelessWidget {
future: prefs.preferredCategories,
builder: (context, snapshot) {
final data = snapshot.data ?? Set<VeggieCategory>();
return VeggieCard(veggie, data.contains(veggie.category));
return VeggieCard(veggie, inSeason, data.contains(veggie.category));
}),
));
}
@ -65,7 +69,7 @@ class ListScreen extends StatelessWidget {
),
);
rows.addAll(_generateVeggieRows(appState.unavailableVeggies, prefs));
rows.addAll(_generateVeggieRows(appState.unavailableVeggies, prefs, inSeason: false));
return DecoratedBox(
decoration: BoxDecoration(color: Color(0xffffffff)),

@ -269,4 +269,9 @@ abstract class Styles {
);
static const servingInfoBorderColor = Color(0xffb0b0b0);
static const ColorFilter desaturatedColorFilter =
// 222222 is a random color that has low color saturation.
ColorFilter.mode(Color(0xFF222222), BlendMode.saturation);
}

@ -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,

Loading…
Cancel
Save