1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-28 10:36:37 +00:00

Refactors detail view in advance of trivia (#60)

This commit is contained in:
Andrew Brogdon
2019-03-20 15:59:59 -07:00
committed by GitHub
parent a2419b3dcf
commit dcca6e44b2
7 changed files with 434 additions and 128 deletions

View File

@@ -15,6 +15,10 @@ class LocalVeggieProvider {
shortDescription: 'Green or red, they\'re generally round and tasty.',
accentColor: Color(0x40de8c66),
seasons: [Season.winter, Season.spring, Season.summer, Season.autumn],
vitaminAPercentage: 2,
vitaminCPercentage: 8,
servingSize: 'One large apple',
caloriesPerServing: 130,
),
Veggie(
id: 2,
@@ -24,6 +28,10 @@ class LocalVeggieProvider {
shortDescription: 'The armadillo of vegetables.',
accentColor: Color(0x408ea26d),
seasons: [Season.autumn, Season.spring],
vitaminAPercentage: 0,
vitaminCPercentage: 25,
servingSize: '1 medium artichoke',
caloriesPerServing: 60,
),
Veggie(
id: 3,
@@ -33,6 +41,10 @@ class LocalVeggieProvider {
shortDescription: 'It\'s been used a food and medicine for millenia.',
accentColor: Color(0x408cb437),
seasons: [Season.spring],
vitaminAPercentage: 10,
vitaminCPercentage: 15,
servingSize: '5 spears',
caloriesPerServing: 20,
),
Veggie(
id: 4,
@@ -42,6 +54,10 @@ class LocalVeggieProvider {
shortDescription: 'One of the oiliest, richest vegetables money can buy.',
accentColor: Color(0x40b0ba59),
seasons: [Season.winter, Season.spring, Season.summer],
vitaminAPercentage: 0,
vitaminCPercentage: 4,
servingSize: '1/5 medium avocado',
caloriesPerServing: 50,
),
Veggie(
id: 5,
@@ -51,6 +67,10 @@ class LocalVeggieProvider {
shortDescription: 'Find them on backroads and fences in the Northwest.',
accentColor: Color(0x409d5adb),
seasons: [Season.summer],
vitaminAPercentage: 6,
vitaminCPercentage: 4,
servingSize: '1 cup',
caloriesPerServing: 62,
),
Veggie(
id: 6,
@@ -60,6 +80,10 @@ class LocalVeggieProvider {
shortDescription: 'A fruit so tasty there\'s a utensil just for it.',
accentColor: Color(0x40f6bd56),
seasons: [Season.summer],
vitaminAPercentage: 120,
vitaminCPercentage: 80,
servingSize: '1/4 medium canteloupe',
caloriesPerServing: 50,
),
Veggie(
id: 7,
@@ -69,6 +93,10 @@ class LocalVeggieProvider {
shortDescription: 'Looks like white broccoli and explodes when cut.',
accentColor: Color(0x40c891a8),
seasons: [Season.autumn],
vitaminAPercentage: 0,
vitaminCPercentage: 100,
servingSize: '1/6 medium head',
caloriesPerServing: 25,
),
Veggie(
id: 8,
@@ -78,6 +106,10 @@ class LocalVeggieProvider {
shortDescription: 'It\'s basically the veal of lettuce.',
accentColor: Color(0x40c5be53),
seasons: [Season.winter, Season.autumn, Season.spring],
vitaminAPercentage: 10,
vitaminCPercentage: 2,
servingSize: '1/2 cup, chopped',
caloriesPerServing: 4,
),
Veggie(
id: 9,
@@ -87,6 +119,10 @@ class LocalVeggieProvider {
shortDescription: 'Delicious when sliced and wrapped in prosciutto.',
accentColor: Color(0x40aa6d7c),
seasons: [Season.autumn, Season.summer],
vitaminAPercentage: 2,
vitaminCPercentage: 2,
servingSize: '1 large fig',
caloriesPerServing: 50,
),
Veggie(
id: 10,
@@ -96,6 +132,10 @@ class LocalVeggieProvider {
shortDescription: 'Couldn\'t have wine without them.',
accentColor: Color(0x40ac708a),
seasons: [Season.autumn],
vitaminAPercentage: 0,
vitaminCPercentage: 2,
servingSize: '3/4 cup',
caloriesPerServing: 90,
),
Veggie(
id: 11,
@@ -105,6 +145,10 @@ class LocalVeggieProvider {
shortDescription: 'Pleasantly bitter, like a sad movie.',
accentColor: Color(0x408eb332),
seasons: [Season.summer],
vitaminAPercentage: 4,
vitaminCPercentage: 190,
servingSize: '1 medium pepper',
caloriesPerServing: 25,
),
Veggie(
id: 12,
@@ -114,6 +158,10 @@ class LocalVeggieProvider {
shortDescription: 'Delicious... in extremely small quantities.',
accentColor: Color(0x40ff7a01),
seasons: [Season.autumn, Season.summer],
vitaminAPercentage: 9,
vitaminCPercentage: 100,
servingSize: '1 pepper',
caloriesPerServing: 20,
),
Veggie(
id: 13,
@@ -123,6 +171,10 @@ class LocalVeggieProvider {
shortDescription: 'The meanest vegetable. Does not want to be eaten.',
accentColor: Color(0x40a86bd8),
seasons: [Season.winter, Season.autumn],
vitaminAPercentage: 133,
vitaminCPercentage: 134,
servingSize: '1 cup, chopped',
caloriesPerServing: 33,
),
Veggie(
id: 14,
@@ -132,6 +184,10 @@ class LocalVeggieProvider {
shortDescription: 'Also known as Chinese gooseberry.',
accentColor: Color(0x40b47b37),
seasons: [Season.summer],
vitaminAPercentage: 2,
vitaminCPercentage: 240,
servingSize: '2 medium kiwis',
caloriesPerServing: 90,
),
Veggie(
id: 15,
@@ -141,6 +197,10 @@ class LocalVeggieProvider {
shortDescription: 'Similar to limes, only yellow.',
accentColor: Color(0x40e2a500),
seasons: [Season.winter],
vitaminAPercentage: 0,
vitaminCPercentage: 40,
servingSize: '1 medium lemon',
caloriesPerServing: 15,
),
Veggie(
id: 16,
@@ -150,6 +210,10 @@ class LocalVeggieProvider {
shortDescription: 'Couldn\'t have ceviche and margaritas without them.',
accentColor: Color(0x4089b733),
seasons: [Season.winter],
vitaminAPercentage: 0,
vitaminCPercentage: 35,
servingSize: '1 medium lime',
caloriesPerServing: 20,
),
Veggie(
id: 17,
@@ -159,6 +223,10 @@ class LocalVeggieProvider {
shortDescription: 'A fun orange fruit popular with smoothie enthusiasts.',
accentColor: Color(0x40fcc93c),
seasons: [Season.summer, Season.autumn],
vitaminAPercentage: 72,
vitaminCPercentage: 203,
servingSize: '1 fruit',
caloriesPerServing: 201,
),
Veggie(
id: 18,
@@ -168,6 +236,10 @@ class LocalVeggieProvider {
shortDescription: 'They\'re not truffles, but they\'re still tasty.',
accentColor: Color(0x40ba754b),
seasons: [Season.spring, Season.autumn],
vitaminAPercentage: 0,
vitaminCPercentage: 2,
servingSize: '5 medium \'shrooms',
caloriesPerServing: 20,
),
Veggie(
id: 19,
@@ -177,6 +249,10 @@ class LocalVeggieProvider {
shortDescription: 'Tiny, bald peaches.',
accentColor: Color(0x40e45b3b),
seasons: [Season.summer],
vitaminAPercentage: 8,
vitaminCPercentage: 15,
servingSize: '1 medium nectarine',
caloriesPerServing: 60,
),
Veggie(
id: 20,
@@ -186,6 +262,10 @@ class LocalVeggieProvider {
shortDescription: 'It\'s like a plum and an apple had a baby together.',
accentColor: Color(0x40979852),
seasons: [Season.winter, Season.autumn],
vitaminAPercentage: 0,
vitaminCPercentage: 27,
servingSize: '1 fruit',
caloriesPerServing: 32,
),
Veggie(
id: 21,
@@ -195,6 +275,10 @@ class LocalVeggieProvider {
shortDescription: 'Popular in fruit salads and children\'s tales.',
accentColor: Color(0x40e48b47),
seasons: [Season.summer],
vitaminAPercentage: 8,
vitaminCPercentage: 10,
servingSize: '2 medium plums',
caloriesPerServing: 70,
),
Veggie(
id: 22,
@@ -204,6 +288,10 @@ class LocalVeggieProvider {
shortDescription: 'King of starches and giver of french fries.',
accentColor: Color(0x40c65c63),
seasons: [Season.winter, Season.autumn],
vitaminAPercentage: 0,
vitaminCPercentage: 45,
servingSize: '1 medium spud',
caloriesPerServing: 110,
),
Veggie(
id: 23,
@@ -213,6 +301,10 @@ class LocalVeggieProvider {
shortDescription: 'It\'s that bitter taste in the salad you\'re eating.',
accentColor: Color(0x40d75875),
seasons: [Season.autumn, Season.spring],
vitaminAPercentage: 0,
vitaminCPercentage: 10,
servingSize: '2 cups shredded',
caloriesPerServing: 20,
),
Veggie(
id: 24,
@@ -222,6 +314,10 @@ class LocalVeggieProvider {
shortDescription: 'Try roasting them in addition to slicing them up raw.',
accentColor: Color(0x40819e4e),
seasons: [Season.spring, Season.autumn],
vitaminAPercentage: 0,
vitaminCPercentage: 30,
servingSize: '7 radishes',
caloriesPerServing: 10,
),
Veggie(
id: 25,
@@ -231,6 +327,10 @@ class LocalVeggieProvider {
shortDescription: 'Just slather them in butter and pop \'em in the oven.',
accentColor: Color(0x40dbb721),
seasons: [Season.winter, Season.autumn],
vitaminAPercentage: 297,
vitaminCPercentage: 48,
servingSize: '1 cup diced butternut',
caloriesPerServing: 63,
),
Veggie(
id: 26,
@@ -241,6 +341,10 @@ class LocalVeggieProvider {
'A delicious fruit that keeps its seeds on the outside.',
accentColor: Color(0x40f06a44),
seasons: [Season.spring, Season.summer],
vitaminAPercentage: 0,
vitaminCPercentage: 160,
servingSize: '8 medium strawberries',
caloriesPerServing: 50,
),
Veggie(
id: 27,
@@ -250,6 +354,10 @@ class LocalVeggieProvider {
shortDescription: 'No one\'s sure what they are or where they came from.',
accentColor: Color(0x40f88c06),
seasons: [Season.winter, Season.autumn],
vitaminAPercentage: 6,
vitaminCPercentage: 181,
servingSize: '1 medium tangelo',
caloriesPerServing: 60,
),
Veggie(
id: 28,
@@ -259,6 +367,10 @@ class LocalVeggieProvider {
shortDescription: 'A new world food with old world tradition.',
accentColor: Color(0x40ea3628),
seasons: [Season.summer],
vitaminAPercentage: 20,
vitaminCPercentage: 40,
servingSize: '1 medium tomato',
caloriesPerServing: 25,
),
Veggie(
id: 29,
@@ -268,6 +380,10 @@ class LocalVeggieProvider {
shortDescription: 'Everyone\'s favorite closing act at the picnic.',
accentColor: Color(0x40fa8c75),
seasons: [Season.summer],
vitaminAPercentage: 30,
vitaminCPercentage: 25,
servingSize: '2 cups diced',
caloriesPerServing: 80,
),
Veggie(
id: 30,
@@ -277,6 +393,10 @@ class LocalVeggieProvider {
shortDescription: 'Like green pepper, but nicer.',
accentColor: Color(0x40fd8e00),
seasons: [Season.summer],
vitaminAPercentage: 4,
vitaminCPercentage: 190,
servingSize: '1 medium pepper',
caloriesPerServing: 25,
),
];
}

View File

@@ -70,7 +70,7 @@ class Preferences extends Model {
_preferredCategories.clear();
final names = prefs.getString(_preferredCategoriesKey);
if (names != null) {
if (names != null && names.isNotEmpty) {
for (final name in names.split(',')) {
final index = int.tryParse(name) ?? -1;
if (VeggieCategory.values[index] != null) {

View File

@@ -63,6 +63,10 @@ class Veggie {
@required this.shortDescription,
@required this.accentColor,
@required this.seasons,
@required this.vitaminAPercentage,
@required this.vitaminCPercentage,
@required this.servingSize,
@required this.caloriesPerServing,
this.isFavorite = false,
});
@@ -76,6 +80,7 @@ class Veggie {
final VeggieCategory category;
/// A short, snappy line, possibly with trivia.
final String shortDescription;
/// A color value to use when constructing UI elements to match the image
@@ -85,6 +90,20 @@ class Veggie {
/// Seasons during which a veggie is harvested.
final List<Season> seasons;
/// Percentage of the FDA's recommended daily value of vitamin A for someone
/// with a 2,000 calorie diet.
final int vitaminAPercentage;
/// Percentage of the FDA's recommended daily value of vitamin C for someone
/// with a 2,000 calorie diet.
final int vitaminCPercentage;
/// A text description of a single serving (e.g. '1 apple' or '1/2 cup').
final String servingSize;
/// Calories per serving (as described in [servingSize]).
final int caloriesPerServing;
/// Whether or not the veggie has been saved to the user's garden (i.e. marked
/// as a favorite).
bool isFavorite;