Skip to content

Commit

Permalink
Veggie Seasons detail page update (#2425)
Browse files Browse the repository at this point in the history
## 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

![Simulator Screenshot - iPhone 15 Pro - 2024-09-02 at 17 02
35](https://github.com/user-attachments/assets/186936f2-0098-4552-8c66-62f920ba0600)
  • Loading branch information
domesticmouse authored Sep 2, 2024
1 parent 70db134 commit 01036f8
Showing 1 changed file with 108 additions and 120 deletions.
228 changes: 108 additions & 120 deletions veggieseasons/lib/screens/details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,97 +42,81 @@ class ServingInfoChart extends StatelessWidget {
final themeData = CupertinoTheme.of(context);
return Column(
children: [
const SizedBox(height: 16),
Container(
padding: const EdgeInsets.all(8),
child: Column(
children: [
Table(
children: [
TableRow(
children: [
TableCell(
child: Text(
'Serving size:',
style: Styles.detailsServingLabelText(themeData),
),
),
TableCell(
child: Text(
veggie.servingSize,
textAlign: TextAlign.end,
style: CupertinoTheme.of(context).textTheme.textStyle,
),
),
],
),
TableRow(
children: [
TableCell(
child: Text(
'Calories:',
style: Styles.detailsServingLabelText(themeData),
),
),
TableCell(
child: Text(
'${veggie.caloriesPerServing} kCal',
style: CupertinoTheme.of(context).textTheme.textStyle,
textAlign: TextAlign.end,
),
),
],
),
TableRow(
children: [
TableCell(
child: Text(
'Vitamin A:',
style: Styles.detailsServingLabelText(themeData),
),
),
TableCell(
child: _buildVitaminText(
veggie.vitaminAPercentage,
prefs.desiredCalories,
),
),
],
),
TableRow(
children: [
TableCell(
child: Text(
'Vitamin C:',
style: Styles.detailsServingLabelText(themeData),
),
),
TableCell(
child: _buildVitaminText(
veggie.vitaminCPercentage,
prefs.desiredCalories,
),
),
],
),
],
),
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),
);
},
),
),
],
const SizedBox(height: 32),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
'Serving size',
style: Styles.detailsServingLabelText(themeData),
),
const Spacer(),
Text(
veggie.servingSize,
textAlign: TextAlign.end,
style: CupertinoTheme.of(context).textTheme.textStyle,
),
],
),
const SizedBox(height: 24),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
'Calories',
style: Styles.detailsServingLabelText(themeData),
),
const Spacer(),
Text(
'${veggie.caloriesPerServing} kCal',
style: CupertinoTheme.of(context).textTheme.textStyle,
textAlign: TextAlign.end,
),
],
),
const SizedBox(height: 24),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
'Vitamin A',
style: Styles.detailsServingLabelText(themeData),
),
const Spacer(),
_buildVitaminText(
veggie.vitaminAPercentage,
prefs.desiredCalories,
),
],
),
const SizedBox(height: 24),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
'Vitamin C',
style: Styles.detailsServingLabelText(themeData),
),
const Spacer(),
_buildVitaminText(
veggie.vitaminCPercentage,
prefs.desiredCalories,
),
],
),
Padding(
padding: const EdgeInsets.only(top: 32),
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),
);
},
),
)
),
],
);
}
Expand All @@ -155,36 +139,6 @@ class InfoView extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
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(
veggie.name,
style: Styles.detailsTitleText(themeData),
Expand All @@ -194,6 +148,40 @@ class InfoView extends StatelessWidget {
veggie.shortDescription,
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),
],
),
Expand Down

0 comments on commit 01036f8

Please sign in to comment.