Skip to content

Commit 01036f8

Browse files
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 ![Simulator Screenshot - iPhone 15 Pro - 2024-09-02 at 17 02 35](https://github.com/user-attachments/assets/186936f2-0098-4552-8c66-62f920ba0600)
1 parent 70db134 commit 01036f8

File tree

1 file changed

+108
-120
lines changed

1 file changed

+108
-120
lines changed

veggieseasons/lib/screens/details.dart

Lines changed: 108 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -42,97 +42,81 @@ class ServingInfoChart extends StatelessWidget {
4242
final themeData = CupertinoTheme.of(context);
4343
return Column(
4444
children: [
45-
const SizedBox(height: 16),
46-
Container(
47-
padding: const EdgeInsets.all(8),
48-
child: Column(
49-
children: [
50-
Table(
51-
children: [
52-
TableRow(
53-
children: [
54-
TableCell(
55-
child: Text(
56-
'Serving size:',
57-
style: Styles.detailsServingLabelText(themeData),
58-
),
59-
),
60-
TableCell(
61-
child: Text(
62-
veggie.servingSize,
63-
textAlign: TextAlign.end,
64-
style: CupertinoTheme.of(context).textTheme.textStyle,
65-
),
66-
),
67-
],
68-
),
69-
TableRow(
70-
children: [
71-
TableCell(
72-
child: Text(
73-
'Calories:',
74-
style: Styles.detailsServingLabelText(themeData),
75-
),
76-
),
77-
TableCell(
78-
child: Text(
79-
'${veggie.caloriesPerServing} kCal',
80-
style: CupertinoTheme.of(context).textTheme.textStyle,
81-
textAlign: TextAlign.end,
82-
),
83-
),
84-
],
85-
),
86-
TableRow(
87-
children: [
88-
TableCell(
89-
child: Text(
90-
'Vitamin A:',
91-
style: Styles.detailsServingLabelText(themeData),
92-
),
93-
),
94-
TableCell(
95-
child: _buildVitaminText(
96-
veggie.vitaminAPercentage,
97-
prefs.desiredCalories,
98-
),
99-
),
100-
],
101-
),
102-
TableRow(
103-
children: [
104-
TableCell(
105-
child: Text(
106-
'Vitamin C:',
107-
style: Styles.detailsServingLabelText(themeData),
108-
),
109-
),
110-
TableCell(
111-
child: _buildVitaminText(
112-
veggie.vitaminCPercentage,
113-
prefs.desiredCalories,
114-
),
115-
),
116-
],
117-
),
118-
],
119-
),
120-
Padding(
121-
padding: const EdgeInsets.only(top: 16),
122-
child: FutureBuilder(
123-
future: prefs.desiredCalories,
124-
builder: (context, snapshot) {
125-
return Text(
126-
'Percent daily values based on a diet of '
127-
'${snapshot.data ?? '2,000'} calories.',
128-
style: Styles.detailsServingNoteText(themeData),
129-
);
130-
},
131-
),
132-
),
133-
],
45+
const SizedBox(height: 32),
46+
Row(
47+
mainAxisSize: MainAxisSize.max,
48+
children: [
49+
Text(
50+
'Serving size',
51+
style: Styles.detailsServingLabelText(themeData),
52+
),
53+
const Spacer(),
54+
Text(
55+
veggie.servingSize,
56+
textAlign: TextAlign.end,
57+
style: CupertinoTheme.of(context).textTheme.textStyle,
58+
),
59+
],
60+
),
61+
const SizedBox(height: 24),
62+
Row(
63+
mainAxisSize: MainAxisSize.max,
64+
children: [
65+
Text(
66+
'Calories',
67+
style: Styles.detailsServingLabelText(themeData),
68+
),
69+
const Spacer(),
70+
Text(
71+
'${veggie.caloriesPerServing} kCal',
72+
style: CupertinoTheme.of(context).textTheme.textStyle,
73+
textAlign: TextAlign.end,
74+
),
75+
],
76+
),
77+
const SizedBox(height: 24),
78+
Row(
79+
mainAxisSize: MainAxisSize.max,
80+
children: [
81+
Text(
82+
'Vitamin A',
83+
style: Styles.detailsServingLabelText(themeData),
84+
),
85+
const Spacer(),
86+
_buildVitaminText(
87+
veggie.vitaminAPercentage,
88+
prefs.desiredCalories,
89+
),
90+
],
91+
),
92+
const SizedBox(height: 24),
93+
Row(
94+
mainAxisSize: MainAxisSize.max,
95+
children: [
96+
Text(
97+
'Vitamin C',
98+
style: Styles.detailsServingLabelText(themeData),
99+
),
100+
const Spacer(),
101+
_buildVitaminText(
102+
veggie.vitaminCPercentage,
103+
prefs.desiredCalories,
104+
),
105+
],
106+
),
107+
Padding(
108+
padding: const EdgeInsets.only(top: 32),
109+
child: FutureBuilder(
110+
future: prefs.desiredCalories,
111+
builder: (context, snapshot) {
112+
return Text(
113+
'Percent daily values based on a diet of '
114+
'${snapshot.data ?? '2,000'} calories.',
115+
style: Styles.detailsServingNoteText(themeData),
116+
);
117+
},
134118
),
135-
)
119+
),
136120
],
137121
);
138122
}
@@ -155,36 +139,6 @@ class InfoView extends StatelessWidget {
155139
child: Column(
156140
crossAxisAlignment: CrossAxisAlignment.stretch,
157141
children: [
158-
Row(
159-
mainAxisSize: MainAxisSize.max,
160-
children: [
161-
FutureBuilder<Set<VeggieCategory>>(
162-
future: prefs.preferredCategories,
163-
builder: (context, snapshot) {
164-
return Text(
165-
veggie.categoryName!.toUpperCase(),
166-
style: (snapshot.hasData &&
167-
snapshot.data!.contains(veggie.category))
168-
? Styles.detailsPreferredCategoryText(themeData)
169-
: themeData.textTheme.textStyle,
170-
);
171-
},
172-
),
173-
const Spacer(),
174-
for (Season season in veggie.seasons) ...[
175-
const SizedBox(width: 12),
176-
Padding(
177-
padding: Styles.seasonIconPadding[season]!,
178-
child: Icon(
179-
Styles.seasonIconData[season],
180-
semanticLabel: seasonNames[season],
181-
color: Styles.seasonColors[season],
182-
),
183-
),
184-
],
185-
],
186-
),
187-
const SizedBox(height: 8),
188142
Text(
189143
veggie.name,
190144
style: Styles.detailsTitleText(themeData),
@@ -194,6 +148,40 @@ class InfoView extends StatelessWidget {
194148
veggie.shortDescription,
195149
style: CupertinoTheme.of(context).textTheme.textStyle,
196150
),
151+
const SizedBox(height: 16),
152+
Text(
153+
'Seasons',
154+
style: Styles.detailsServingLabelText(themeData),
155+
),
156+
const SizedBox(height: 12),
157+
Row(
158+
mainAxisSize: MainAxisSize.max,
159+
children: <Widget>[
160+
for (var season in Season.values) ...[
161+
const Spacer(),
162+
Column(
163+
mainAxisSize: MainAxisSize.min,
164+
children: [
165+
Icon(
166+
Styles.seasonIconData[season],
167+
color: veggie.seasons.contains(season)
168+
? Styles.seasonColors[season]
169+
: const Color.fromRGBO(128, 128, 128, 1),
170+
size: 24,
171+
),
172+
const SizedBox(height: 4),
173+
Text(
174+
season.name.characters.first.toUpperCase() +
175+
season.name.characters.skip(1).string,
176+
style: Styles.minorText(CupertinoTheme.of(context))
177+
.copyWith(fontSize: 11),
178+
),
179+
],
180+
),
181+
const Spacer(),
182+
],
183+
],
184+
),
197185
ServingInfoChart(veggie, prefs),
198186
],
199187
),

0 commit comments

Comments
 (0)