Adds season display to details screen. (#62)

pull/64/head
Andrew Brogdon 7 years ago committed by GitHub
parent 673992f49e
commit bf3a963bdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -72,7 +72,7 @@ class LocalVeggieProvider {
'2000 B.C.E.', '2000 B.C.E.',
'6500 B.C.E.', '6500 B.C.E.',
], ],
1, 2,
), ),
Trivia( Trivia(
'What are the seed pockets inside an apple called?', 'What are the seed pockets inside an apple called?',
@ -92,7 +92,7 @@ class LocalVeggieProvider {
category: VeggieCategory.flower, category: VeggieCategory.flower,
shortDescription: 'The armadillo of vegetables.', shortDescription: 'The armadillo of vegetables.',
accentColor: Color(0x408ea26d), accentColor: Color(0x408ea26d),
seasons: [Season.autumn, Season.spring], seasons: [Season.spring, Season.autumn],
vitaminAPercentage: 0, vitaminAPercentage: 0,
vitaminCPercentage: 25, vitaminCPercentage: 25,
servingSize: '1 medium artichoke', servingSize: '1 medium artichoke',
@ -380,7 +380,7 @@ class LocalVeggieProvider {
category: VeggieCategory.leafy, category: VeggieCategory.leafy,
shortDescription: 'It\'s basically the veal of lettuce.', shortDescription: 'It\'s basically the veal of lettuce.',
accentColor: Color(0x40c5be53), accentColor: Color(0x40c5be53),
seasons: [Season.winter, Season.autumn, Season.spring], seasons: [Season.winter, Season.spring, Season.autumn],
vitaminAPercentage: 10, vitaminAPercentage: 10,
vitaminCPercentage: 2, vitaminCPercentage: 2,
servingSize: '1/2 cup, chopped', servingSize: '1/2 cup, chopped',
@ -422,7 +422,7 @@ class LocalVeggieProvider {
category: VeggieCategory.fruit, category: VeggieCategory.fruit,
shortDescription: 'Delicious when sliced and wrapped in prosciutto.', shortDescription: 'Delicious when sliced and wrapped in prosciutto.',
accentColor: Color(0x40aa6d7c), accentColor: Color(0x40aa6d7c),
seasons: [Season.autumn, Season.summer], seasons: [Season.summer, Season.autumn],
vitaminAPercentage: 2, vitaminAPercentage: 2,
vitaminCPercentage: 2, vitaminCPercentage: 2,
servingSize: '1 large fig', servingSize: '1 large fig',
@ -557,7 +557,7 @@ class LocalVeggieProvider {
category: VeggieCategory.stealthFruit, category: VeggieCategory.stealthFruit,
shortDescription: 'Delicious... in extremely small quantities.', shortDescription: 'Delicious... in extremely small quantities.',
accentColor: Color(0x40ff7a01), accentColor: Color(0x40ff7a01),
seasons: [Season.autumn, Season.summer], seasons: [Season.summer, Season.autumn],
vitaminAPercentage: 9, vitaminAPercentage: 9,
vitaminCPercentage: 100, vitaminCPercentage: 100,
servingSize: '1 pepper', servingSize: '1 pepper',
@ -1037,7 +1037,7 @@ class LocalVeggieProvider {
category: VeggieCategory.leafy, category: VeggieCategory.leafy,
shortDescription: 'It\'s that bitter taste in the salad you\'re eating.', shortDescription: 'It\'s that bitter taste in the salad you\'re eating.',
accentColor: Color(0x40d75875), accentColor: Color(0x40d75875),
seasons: [Season.autumn, Season.spring], seasons: [Season.spring, Season.autumn],
vitaminAPercentage: 0, vitaminAPercentage: 0,
vitaminCPercentage: 10, vitaminCPercentage: 10,
servingSize: '2 cups shredded', servingSize: '2 cups shredded',

@ -62,6 +62,13 @@ const Map<VeggieCategory, String> veggieCategoryNames = {
VeggieCategory.vegetable: 'Vegetable', VeggieCategory.vegetable: 'Vegetable',
}; };
const Map<Season, String> seasonNames = {
Season.winter: 'Winter',
Season.spring: 'Spring',
Season.summer: 'Summer',
Season.autumn: 'Autumn',
};
class Veggie { class Veggie {
Veggie({ Veggie({
@required this.id, @required this.id,

@ -164,11 +164,30 @@ class InfoView extends StatelessWidget {
final prefs = ScopedModel.of<Preferences>(context, rebuildOnChange: true); final prefs = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
final veggie = appState.getVeggie(id); final veggie = appState.getVeggie(id);
final seasonIcons = <Widget>[];
for (Season season in veggie.seasons) {
seasonIcons.addAll([
SizedBox(width: 12.0),
Padding(
padding: Styles.seasonIconPadding[season],
child: Icon(
Styles.seasonIconData[season],
semanticLabel: seasonNames[season],
color: Styles.seasonColors[season],
),
),
]);
}
return Padding( return Padding(
padding: const EdgeInsets.all(24.0), padding: const EdgeInsets.all(24.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
FutureBuilder( FutureBuilder(
future: prefs.preferredCategories, future: prefs.preferredCategories,
builder: (context, snapshot) { builder: (context, snapshot) {
@ -181,6 +200,9 @@ class InfoView extends StatelessWidget {
); );
}, },
), ),
Spacer(),
]..addAll(seasonIcons),
),
SizedBox(height: 8.0), SizedBox(height: 8.0),
Text( Text(
veggie.name, veggie.name,
@ -189,7 +211,7 @@ class InfoView extends StatelessWidget {
SizedBox(height: 8.0), SizedBox(height: 8.0),
Text( Text(
veggie.shortDescription, veggie.shortDescription,
style: Styles.detailsShortDescriptionText, style: Styles.detailsDescriptionText,
), ),
ServingInfoChart(veggie, prefs), ServingInfoChart(veggie, prefs),
SizedBox(height: 24.0), SizedBox(height: 24.0),
@ -261,11 +283,13 @@ class _DetailsScreenState extends State<DetailsScreen> {
return CupertinoPageScaffold( return CupertinoPageScaffold(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [ children: [
_buildHeader(context, appState), _buildHeader(context, appState),
Padding( Expanded(
padding: const EdgeInsets.only(top: 16.0), child: ListView(
child: CupertinoSegmentedControl( children: [
CupertinoSegmentedControl(
children: { children: {
0: Text('Facts & Info'), 0: Text('Facts & Info'),
1: Text('Trivia'), 1: Text('Trivia'),
@ -275,8 +299,12 @@ class _DetailsScreenState extends State<DetailsScreen> {
setState(() => _selectedViewIndex = value); setState(() => _selectedViewIndex = value);
}, },
), ),
_selectedViewIndex == 0
? InfoView(widget.id)
: TriviaView(widget.id),
],
),
), ),
_selectedViewIndex == 0 ? InfoView(widget.id) : TriviaView(widget.id),
], ],
), ),
); );

@ -4,6 +4,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:veggieseasons/data/veggie.dart'; import 'package:veggieseasons/data/veggie.dart';
abstract class Styles { abstract class Styles {
@ -87,7 +88,7 @@ abstract class Styles {
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
); );
static const detailsShortDescriptionText = TextStyle( static const detailsDescriptionText = TextStyle(
color: Color.fromRGBO(0, 0, 0, 0.9), color: Color.fromRGBO(0, 0, 0, 0.9),
fontFamily: 'NotoSans', fontFamily: 'NotoSans',
fontSize: 16.0, fontSize: 16.0,
@ -95,6 +96,14 @@ abstract class Styles {
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
); );
static const detailsBoldDescriptionText = TextStyle(
color: Color.fromRGBO(0, 0, 0, 0.9),
fontFamily: 'NotoSans',
fontSize: 16.0,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.bold,
);
static const detailsServingHeaderText = TextStyle( static const detailsServingHeaderText = TextStyle(
color: Color.fromRGBO(176, 176, 176, 1.0), color: Color.fromRGBO(176, 176, 176, 1.0),
fontFamily: 'NotoSans', fontFamily: 'NotoSans',
@ -182,6 +191,22 @@ abstract class Styles {
Season.autumn: Color(0xff724913), Season.autumn: Color(0xff724913),
}; };
// While handy, some of the Font Awesome icons sometimes bleed over their
// allotted bounds. This padding is used to adjust for that.
static const seasonIconPadding = {
Season.winter: const EdgeInsets.only(right: 0.0),
Season.spring: const EdgeInsets.only(right: 4.0),
Season.summer: const EdgeInsets.only(right: 6.0),
Season.autumn: const EdgeInsets.only(right: 0.0),
};
static const seasonIconData = {
Season.winter: FontAwesomeIcons.snowflake,
Season.spring: FontAwesomeIcons.leaf,
Season.summer: FontAwesomeIcons.umbrellaBeach,
Season.autumn: FontAwesomeIcons.canadianMapleLeaf,
};
static const seasonBorder = Border( static const seasonBorder = Border(
top: BorderSide(color: Color(0xff606060)), top: BorderSide(color: Color(0xff606060)),
left: BorderSide(color: Color(0xff606060)), left: BorderSide(color: Color(0xff606060)),

@ -11,6 +11,7 @@ dependencies:
sdk: flutter sdk: flutter
cupertino_icons: ^0.1.2 cupertino_icons: ^0.1.2
font_awesome_flutter: ^8.4.0
intl: ^0.15.7 intl: ^0.15.7
scoped_model: ^1.0.1 scoped_model: ^1.0.1
shared_preferences: ^0.4.3 shared_preferences: ^0.4.3

Loading…
Cancel
Save