mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Veggie Seasons detail page update (#2425)
## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. <!-- Links --> [Flutter Style Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md [Contributors Guide]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md 
This commit is contained in:
@@ -42,97 +42,81 @@ class ServingInfoChart extends StatelessWidget {
|
|||||||
final themeData = CupertinoTheme.of(context);
|
final themeData = CupertinoTheme.of(context);
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 32),
|
||||||
Container(
|
Row(
|
||||||
padding: const EdgeInsets.all(8),
|
mainAxisSize: MainAxisSize.max,
|
||||||
child: Column(
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Table(
|
'Serving size',
|
||||||
children: [
|
style: Styles.detailsServingLabelText(themeData),
|
||||||
TableRow(
|
),
|
||||||
children: [
|
const Spacer(),
|
||||||
TableCell(
|
Text(
|
||||||
child: Text(
|
veggie.servingSize,
|
||||||
'Serving size:',
|
textAlign: TextAlign.end,
|
||||||
style: Styles.detailsServingLabelText(themeData),
|
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
TableCell(
|
),
|
||||||
child: Text(
|
const SizedBox(height: 24),
|
||||||
veggie.servingSize,
|
Row(
|
||||||
textAlign: TextAlign.end,
|
mainAxisSize: MainAxisSize.max,
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
children: [
|
||||||
),
|
Text(
|
||||||
),
|
'Calories',
|
||||||
],
|
style: Styles.detailsServingLabelText(themeData),
|
||||||
),
|
),
|
||||||
TableRow(
|
const Spacer(),
|
||||||
children: [
|
Text(
|
||||||
TableCell(
|
'${veggie.caloriesPerServing} kCal',
|
||||||
child: Text(
|
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||||
'Calories:',
|
textAlign: TextAlign.end,
|
||||||
style: Styles.detailsServingLabelText(themeData),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
TableCell(
|
const SizedBox(height: 24),
|
||||||
child: Text(
|
Row(
|
||||||
'${veggie.caloriesPerServing} kCal',
|
mainAxisSize: MainAxisSize.max,
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
children: [
|
||||||
textAlign: TextAlign.end,
|
Text(
|
||||||
),
|
'Vitamin A',
|
||||||
),
|
style: Styles.detailsServingLabelText(themeData),
|
||||||
],
|
),
|
||||||
),
|
const Spacer(),
|
||||||
TableRow(
|
_buildVitaminText(
|
||||||
children: [
|
veggie.vitaminAPercentage,
|
||||||
TableCell(
|
prefs.desiredCalories,
|
||||||
child: Text(
|
),
|
||||||
'Vitamin A:',
|
],
|
||||||
style: Styles.detailsServingLabelText(themeData),
|
),
|
||||||
),
|
const SizedBox(height: 24),
|
||||||
),
|
Row(
|
||||||
TableCell(
|
mainAxisSize: MainAxisSize.max,
|
||||||
child: _buildVitaminText(
|
children: [
|
||||||
veggie.vitaminAPercentage,
|
Text(
|
||||||
prefs.desiredCalories,
|
'Vitamin C',
|
||||||
),
|
style: Styles.detailsServingLabelText(themeData),
|
||||||
),
|
),
|
||||||
],
|
const Spacer(),
|
||||||
),
|
_buildVitaminText(
|
||||||
TableRow(
|
veggie.vitaminCPercentage,
|
||||||
children: [
|
prefs.desiredCalories,
|
||||||
TableCell(
|
),
|
||||||
child: Text(
|
],
|
||||||
'Vitamin C:',
|
),
|
||||||
style: Styles.detailsServingLabelText(themeData),
|
Padding(
|
||||||
),
|
padding: const EdgeInsets.only(top: 32),
|
||||||
),
|
child: FutureBuilder(
|
||||||
TableCell(
|
future: prefs.desiredCalories,
|
||||||
child: _buildVitaminText(
|
builder: (context, snapshot) {
|
||||||
veggie.vitaminCPercentage,
|
return Text(
|
||||||
prefs.desiredCalories,
|
'Percent daily values based on a diet of '
|
||||||
),
|
'${snapshot.data ?? '2,000'} calories.',
|
||||||
),
|
style: Styles.detailsServingNoteText(themeData),
|
||||||
],
|
);
|
||||||
),
|
},
|
||||||
],
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 16),
|
|
||||||
child: FutureBuilder(
|
|
||||||
future: prefs.desiredCalories,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
return Text(
|
|
||||||
'Percent daily values based on a diet of '
|
|
||||||
'${snapshot.data ?? '2,000'} calories.',
|
|
||||||
style: Styles.detailsServingNoteText(themeData),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -155,36 +139,6 @@ class InfoView extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
FutureBuilder<Set<VeggieCategory>>(
|
|
||||||
future: prefs.preferredCategories,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
return Text(
|
|
||||||
veggie.categoryName!.toUpperCase(),
|
|
||||||
style: (snapshot.hasData &&
|
|
||||||
snapshot.data!.contains(veggie.category))
|
|
||||||
? Styles.detailsPreferredCategoryText(themeData)
|
|
||||||
: themeData.textTheme.textStyle,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
for (Season season in veggie.seasons) ...[
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Padding(
|
|
||||||
padding: Styles.seasonIconPadding[season]!,
|
|
||||||
child: Icon(
|
|
||||||
Styles.seasonIconData[season],
|
|
||||||
semanticLabel: seasonNames[season],
|
|
||||||
color: Styles.seasonColors[season],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(
|
Text(
|
||||||
veggie.name,
|
veggie.name,
|
||||||
style: Styles.detailsTitleText(themeData),
|
style: Styles.detailsTitleText(themeData),
|
||||||
@@ -194,6 +148,40 @@ class InfoView extends StatelessWidget {
|
|||||||
veggie.shortDescription,
|
veggie.shortDescription,
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'Seasons',
|
||||||
|
style: Styles.detailsServingLabelText(themeData),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: <Widget>[
|
||||||
|
for (var season in Season.values) ...[
|
||||||
|
const Spacer(),
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Styles.seasonIconData[season],
|
||||||
|
color: veggie.seasons.contains(season)
|
||||||
|
? Styles.seasonColors[season]
|
||||||
|
: const Color.fromRGBO(128, 128, 128, 1),
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
season.name.characters.first.toUpperCase() +
|
||||||
|
season.name.characters.skip(1).string,
|
||||||
|
style: Styles.minorText(CupertinoTheme.of(context))
|
||||||
|
.copyWith(fontSize: 11),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
ServingInfoChart(veggie, prefs),
|
ServingInfoChart(veggie, prefs),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user