1
0
mirror of https://github.com/flutter/samples.git synced 2026-06-08 15:28:30 +00:00

[VeggieSeasons] Fix dark mode problems (#395)

This commit is contained in:
Abdullah Deshmukh
2020-03-31 10:25:00 +05:30
committed by GitHub
parent 28742ddeaf
commit d9c9b3a519
12 changed files with 255 additions and 207 deletions

View File

@@ -28,11 +28,12 @@ class ServingInfoChart extends StatelessWidget {
builder: (context, snapshot) {
final target = snapshot?.data ?? 2000;
final percent = standardPercentage * 2000 ~/ target;
final CupertinoThemeData themeData = CupertinoTheme.of(context);
return Text(
'$percent% DV',
textAlign: TextAlign.end,
style: Styles.detailsServingValueText,
style: Styles.detailsServingValueText(themeData),
);
},
);
@@ -40,6 +41,7 @@ class ServingInfoChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
final CupertinoThemeData themeData = CupertinoTheme.of(context);
return Column(
children: [
SizedBox(height: 16),
@@ -70,14 +72,14 @@ class ServingInfoChart extends StatelessWidget {
TableCell(
child: Text(
'Serving size:',
style: Styles.detailsServingLabelText,
style: Styles.detailsServingLabelText(themeData),
),
),
TableCell(
child: Text(
veggie.servingSize,
textAlign: TextAlign.end,
style: Styles.detailsServingValueText,
style: Styles.detailsServingValueText(themeData),
),
),
],
@@ -87,14 +89,14 @@ class ServingInfoChart extends StatelessWidget {
TableCell(
child: Text(
'Calories:',
style: Styles.detailsServingLabelText,
style: Styles.detailsServingLabelText(themeData),
),
),
TableCell(
child: Text(
'${veggie.caloriesPerServing} kCal',
textAlign: TextAlign.end,
style: Styles.detailsServingValueText,
style: Styles.detailsServingValueText(themeData),
),
),
],
@@ -104,7 +106,7 @@ class ServingInfoChart extends StatelessWidget {
TableCell(
child: Text(
'Vitamin A:',
style: Styles.detailsServingLabelText,
style: Styles.detailsServingLabelText(themeData),
),
),
TableCell(
@@ -120,7 +122,7 @@ class ServingInfoChart extends StatelessWidget {
TableCell(
child: Text(
'Vitamin C:',
style: Styles.detailsServingLabelText,
style: Styles.detailsServingLabelText(themeData),
),
),
TableCell(
@@ -141,7 +143,7 @@ class ServingInfoChart extends StatelessWidget {
return Text(
'Percent daily values based on a diet of ' +
'${snapshot?.data ?? '2,000'} calories.',
style: Styles.detailsServingNoteText,
style: Styles.detailsServingNoteText(themeData),
);
},
),
@@ -163,6 +165,7 @@ class InfoView extends StatelessWidget {
final appState = ScopedModel.of<AppState>(context, rebuildOnChange: true);
final prefs = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
final veggie = appState.getVeggie(id);
final CupertinoThemeData themeData = CupertinoTheme.of(context);
return Padding(
padding: const EdgeInsets.all(24),
@@ -179,8 +182,8 @@ class InfoView extends StatelessWidget {
veggie.categoryName.toUpperCase(),
style: (snapshot.hasData &&
snapshot.data.contains(veggie.category))
? Styles.detailsPreferredCategoryText
: Styles.detailsCategoryText,
? Styles.detailsPreferredCategoryText(themeData)
: Styles.detailsCategoryText(themeData),
);
},
),
@@ -201,12 +204,12 @@ class InfoView extends StatelessWidget {
SizedBox(height: 8),
Text(
veggie.name,
style: Styles.detailsTitleText,
style: Styles.detailsTitleText(themeData),
),
SizedBox(height: 8),
Text(
veggie.shortDescription,
style: Styles.detailsDescriptionText,
style: Styles.detailsDescriptionText(themeData),
),
ServingInfoChart(veggie, prefs),
SizedBox(height: 24),
@@ -220,7 +223,10 @@ class InfoView extends StatelessWidget {
},
),
SizedBox(width: 8),
Text('Save to Garden'),
Text(
'Save to Garden',
style: CupertinoTheme.of(context).textTheme.textStyle,
),
],
),
],

View File

@@ -27,7 +27,8 @@ class FavoritesScreen extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Text(
'You haven\'t added any favorite veggies to your garden yet.',
style: Styles.headlineDescription,
style: Styles.headlineDescription(
CupertinoTheme.of(context)),
),
)
: ListView(

View File

@@ -36,44 +36,43 @@ class ListScreen extends StatelessWidget {
ScopedModel.of<AppState>(context, rebuildOnChange: true);
final prefs =
ScopedModel.of<Preferences>(context, rebuildOnChange: true);
return DecoratedBox(
decoration: BoxDecoration(color: Color(0xffffffff)),
child: SafeArea(
bottom: false,
child: ListView.builder(
itemCount: appState.allVeggies.length + 2,
itemBuilder: (context, index) {
if (index == 0) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(dateString.toUpperCase(), style: Styles.minorText),
Text('In season today', style: Styles.headlineText),
],
),
);
} else if (index <= appState.availableVeggies.length) {
return _generateVeggieRow(
appState.availableVeggies[index - 1],
prefs,
);
} else if (index <= appState.availableVeggies.length + 1) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
child: Text('Not in season', style: Styles.headlineText),
);
} else {
int relativeIndex =
index - (appState.availableVeggies.length + 2);
return _generateVeggieRow(
appState.unavailableVeggies[relativeIndex], prefs,
inSeason: false);
}
},
),
final CupertinoThemeData themeData = CupertinoTheme.of(context);
return SafeArea(
bottom: false,
child: ListView.builder(
itemCount: appState.allVeggies.length + 2,
itemBuilder: (context, index) {
if (index == 0) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(dateString.toUpperCase(), style: Styles.minorText),
Text('In season today',
style: Styles.headlineText(themeData)),
],
),
);
} else if (index <= appState.availableVeggies.length) {
return _generateVeggieRow(
appState.availableVeggies[index - 1],
prefs,
);
} else if (index <= appState.availableVeggies.length + 1) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
child: Text('Not in season',
style: Styles.headlineText(themeData)),
);
} else {
int relativeIndex =
index - (appState.availableVeggies.length + 2);
return _generateVeggieRow(
appState.unavailableVeggies[relativeIndex], prefs,
inSeason: false);
}
},
),
);
},

View File

@@ -54,7 +54,7 @@ class _SearchScreenState extends State<SearchScreen> {
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Text(
'No veggies matching your search terms were found.',
style: Styles.headlineDescription,
style: Styles.headlineDescription(CupertinoTheme.of(context)),
),
),
);
@@ -77,20 +77,15 @@ class _SearchScreenState extends State<SearchScreen> {
return CupertinoTabView(
builder: (context) {
return DecoratedBox(
decoration: BoxDecoration(
color: Styles.scaffoldBackground,
),
child: SafeArea(
bottom: false,
child: Column(
children: [
_createSearchBox(),
Expanded(
child: _buildSearchResults(model.searchVeggies(terms)),
),
],
),
return SafeArea(
bottom: false,
child: Column(
children: [
_createSearchBox(),
Expanded(
child: _buildSearchResults(model.searchVeggies(terms)),
),
],
),
);
},

View File

@@ -17,13 +17,13 @@ class VeggieCategorySettingsScreen extends StatelessWidget {
Widget build(BuildContext context) {
final model = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
final currentPrefs = model.preferredCategories;
Brightness brightness = CupertinoTheme.brightnessOf(context);
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('Preferred Categories'),
previousPageTitle: 'Settings',
),
backgroundColor: Styles.scaffoldBackground,
backgroundColor: Styles.scaffoldBackground(brightness),
child: FutureBuilder<Set<VeggieCategory>>(
future: currentPrefs,
builder: (context, snapshot) {
@@ -80,12 +80,12 @@ class CalorieSettingsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final model = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
Brightness brightness = CupertinoTheme.brightnessOf(context);
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
previousPageTitle: 'Settings',
),
backgroundColor: Styles.scaffoldBackground,
backgroundColor: Styles.scaffoldBackground(brightness),
child: ListView(
children: [
FutureBuilder<int>(
@@ -138,7 +138,10 @@ class SettingsScreen extends StatelessWidget {
builder: (context, snapshot) {
return Row(
children: [
Text(snapshot.data?.toString() ?? ''),
Text(
snapshot.data?.toString() ?? '',
style: CupertinoTheme.of(context).textTheme.textStyle,
),
SizedBox(width: 8),
SettingsNavigationIndicator(),
],
@@ -182,7 +185,7 @@ class SettingsScreen extends StatelessWidget {
return CupertinoPageScaffold(
child: Container(
color: Styles.scaffoldBackground,
color: Styles.scaffoldBackground(CupertinoTheme.brightnessOf(context)),
child: CustomScrollView(
slivers: <Widget>[
CupertinoSliverNavigationBar(