mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
[VeggieSeasons] Fix dark mode problems (#395)
This commit is contained in:
committed by
GitHub
parent
28742ddeaf
commit
d9c9b3a519
@@ -8,7 +8,6 @@ import 'package:scoped_model/scoped_model.dart';
|
|||||||
import 'package:veggieseasons/data/app_state.dart';
|
import 'package:veggieseasons/data/app_state.dart';
|
||||||
import 'package:veggieseasons/data/preferences.dart';
|
import 'package:veggieseasons/data/preferences.dart';
|
||||||
import 'package:veggieseasons/screens/home.dart';
|
import 'package:veggieseasons/screens/home.dart';
|
||||||
import 'package:veggieseasons/styles.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
@@ -23,11 +22,7 @@ void main() {
|
|||||||
child: ScopedModel<Preferences>(
|
child: ScopedModel<Preferences>(
|
||||||
model: Preferences()..load(),
|
model: Preferences()..load(),
|
||||||
child: CupertinoApp(
|
child: CupertinoApp(
|
||||||
theme: CupertinoThemeData(
|
|
||||||
brightness: Brightness.light,
|
|
||||||
),
|
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
color: Styles.appBackground,
|
|
||||||
home: HomeScreen(),
|
home: HomeScreen(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ class ServingInfoChart extends StatelessWidget {
|
|||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final target = snapshot?.data ?? 2000;
|
final target = snapshot?.data ?? 2000;
|
||||||
final percent = standardPercentage * 2000 ~/ target;
|
final percent = standardPercentage * 2000 ~/ target;
|
||||||
|
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
|
|
||||||
return Text(
|
return Text(
|
||||||
'$percent% DV',
|
'$percent% DV',
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style: Styles.detailsServingValueText,
|
style: Styles.detailsServingValueText(themeData),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -40,6 +41,7 @@ class ServingInfoChart extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
@@ -70,14 +72,14 @@ class ServingInfoChart extends StatelessWidget {
|
|||||||
TableCell(
|
TableCell(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Serving size:',
|
'Serving size:',
|
||||||
style: Styles.detailsServingLabelText,
|
style: Styles.detailsServingLabelText(themeData),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TableCell(
|
TableCell(
|
||||||
child: Text(
|
child: Text(
|
||||||
veggie.servingSize,
|
veggie.servingSize,
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style: Styles.detailsServingValueText,
|
style: Styles.detailsServingValueText(themeData),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -87,14 +89,14 @@ class ServingInfoChart extends StatelessWidget {
|
|||||||
TableCell(
|
TableCell(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Calories:',
|
'Calories:',
|
||||||
style: Styles.detailsServingLabelText,
|
style: Styles.detailsServingLabelText(themeData),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TableCell(
|
TableCell(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${veggie.caloriesPerServing} kCal',
|
'${veggie.caloriesPerServing} kCal',
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style: Styles.detailsServingValueText,
|
style: Styles.detailsServingValueText(themeData),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -104,7 +106,7 @@ class ServingInfoChart extends StatelessWidget {
|
|||||||
TableCell(
|
TableCell(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Vitamin A:',
|
'Vitamin A:',
|
||||||
style: Styles.detailsServingLabelText,
|
style: Styles.detailsServingLabelText(themeData),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TableCell(
|
TableCell(
|
||||||
@@ -120,7 +122,7 @@ class ServingInfoChart extends StatelessWidget {
|
|||||||
TableCell(
|
TableCell(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Vitamin C:',
|
'Vitamin C:',
|
||||||
style: Styles.detailsServingLabelText,
|
style: Styles.detailsServingLabelText(themeData),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TableCell(
|
TableCell(
|
||||||
@@ -141,7 +143,7 @@ class ServingInfoChart extends StatelessWidget {
|
|||||||
return Text(
|
return Text(
|
||||||
'Percent daily values based on a diet of ' +
|
'Percent daily values based on a diet of ' +
|
||||||
'${snapshot?.data ?? '2,000'} calories.',
|
'${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 appState = ScopedModel.of<AppState>(context, rebuildOnChange: true);
|
||||||
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 CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(24),
|
padding: const EdgeInsets.all(24),
|
||||||
@@ -179,8 +182,8 @@ class InfoView extends StatelessWidget {
|
|||||||
veggie.categoryName.toUpperCase(),
|
veggie.categoryName.toUpperCase(),
|
||||||
style: (snapshot.hasData &&
|
style: (snapshot.hasData &&
|
||||||
snapshot.data.contains(veggie.category))
|
snapshot.data.contains(veggie.category))
|
||||||
? Styles.detailsPreferredCategoryText
|
? Styles.detailsPreferredCategoryText(themeData)
|
||||||
: Styles.detailsCategoryText,
|
: Styles.detailsCategoryText(themeData),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -201,12 +204,12 @@ class InfoView extends StatelessWidget {
|
|||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
veggie.name,
|
veggie.name,
|
||||||
style: Styles.detailsTitleText,
|
style: Styles.detailsTitleText(themeData),
|
||||||
),
|
),
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
veggie.shortDescription,
|
veggie.shortDescription,
|
||||||
style: Styles.detailsDescriptionText,
|
style: Styles.detailsDescriptionText(themeData),
|
||||||
),
|
),
|
||||||
ServingInfoChart(veggie, prefs),
|
ServingInfoChart(veggie, prefs),
|
||||||
SizedBox(height: 24),
|
SizedBox(height: 24),
|
||||||
@@ -220,7 +223,10 @@ class InfoView extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text('Save to Garden'),
|
Text(
|
||||||
|
'Save to Garden',
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ class FavoritesScreen extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
child: Text(
|
child: Text(
|
||||||
'You haven\'t added any favorite veggies to your garden yet.',
|
'You haven\'t added any favorite veggies to your garden yet.',
|
||||||
style: Styles.headlineDescription,
|
style: Styles.headlineDescription(
|
||||||
|
CupertinoTheme.of(context)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ListView(
|
: ListView(
|
||||||
|
|||||||
@@ -36,44 +36,43 @@ class ListScreen extends StatelessWidget {
|
|||||||
ScopedModel.of<AppState>(context, rebuildOnChange: true);
|
ScopedModel.of<AppState>(context, rebuildOnChange: true);
|
||||||
final prefs =
|
final prefs =
|
||||||
ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
||||||
|
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
return DecoratedBox(
|
return SafeArea(
|
||||||
decoration: BoxDecoration(color: Color(0xffffffff)),
|
bottom: false,
|
||||||
child: SafeArea(
|
child: ListView.builder(
|
||||||
bottom: false,
|
itemCount: appState.allVeggies.length + 2,
|
||||||
child: ListView.builder(
|
itemBuilder: (context, index) {
|
||||||
itemCount: appState.allVeggies.length + 2,
|
if (index == 0) {
|
||||||
itemBuilder: (context, index) {
|
return Padding(
|
||||||
if (index == 0) {
|
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
|
||||||
return Padding(
|
child: Column(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Text(dateString.toUpperCase(), style: Styles.minorText),
|
||||||
children: [
|
Text('In season today',
|
||||||
Text(dateString.toUpperCase(), style: Styles.minorText),
|
style: Styles.headlineText(themeData)),
|
||||||
Text('In season today', style: Styles.headlineText),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
} else if (index <= appState.availableVeggies.length) {
|
||||||
} else if (index <= appState.availableVeggies.length) {
|
return _generateVeggieRow(
|
||||||
return _generateVeggieRow(
|
appState.availableVeggies[index - 1],
|
||||||
appState.availableVeggies[index - 1],
|
prefs,
|
||||||
prefs,
|
);
|
||||||
);
|
} else if (index <= appState.availableVeggies.length + 1) {
|
||||||
} else if (index <= appState.availableVeggies.length + 1) {
|
return Padding(
|
||||||
return Padding(
|
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
|
||||||
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
|
child: Text('Not in season',
|
||||||
child: Text('Not in season', style: Styles.headlineText),
|
style: Styles.headlineText(themeData)),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
int relativeIndex =
|
int relativeIndex =
|
||||||
index - (appState.availableVeggies.length + 2);
|
index - (appState.availableVeggies.length + 2);
|
||||||
return _generateVeggieRow(
|
return _generateVeggieRow(
|
||||||
appState.unavailableVeggies[relativeIndex], prefs,
|
appState.unavailableVeggies[relativeIndex], prefs,
|
||||||
inSeason: false);
|
inSeason: false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
child: Text(
|
child: Text(
|
||||||
'No veggies matching your search terms were found.',
|
'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(
|
return CupertinoTabView(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return DecoratedBox(
|
return SafeArea(
|
||||||
decoration: BoxDecoration(
|
bottom: false,
|
||||||
color: Styles.scaffoldBackground,
|
child: Column(
|
||||||
),
|
children: [
|
||||||
child: SafeArea(
|
_createSearchBox(),
|
||||||
bottom: false,
|
Expanded(
|
||||||
child: Column(
|
child: _buildSearchResults(model.searchVeggies(terms)),
|
||||||
children: [
|
),
|
||||||
_createSearchBox(),
|
],
|
||||||
Expanded(
|
|
||||||
child: _buildSearchResults(model.searchVeggies(terms)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ class VeggieCategorySettingsScreen extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final model = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
final model = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
||||||
final currentPrefs = model.preferredCategories;
|
final currentPrefs = model.preferredCategories;
|
||||||
|
Brightness brightness = CupertinoTheme.brightnessOf(context);
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: CupertinoNavigationBar(
|
||||||
middle: Text('Preferred Categories'),
|
middle: Text('Preferred Categories'),
|
||||||
previousPageTitle: 'Settings',
|
previousPageTitle: 'Settings',
|
||||||
),
|
),
|
||||||
backgroundColor: Styles.scaffoldBackground,
|
backgroundColor: Styles.scaffoldBackground(brightness),
|
||||||
child: FutureBuilder<Set<VeggieCategory>>(
|
child: FutureBuilder<Set<VeggieCategory>>(
|
||||||
future: currentPrefs,
|
future: currentPrefs,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
@@ -80,12 +80,12 @@ class CalorieSettingsScreen extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final model = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
final model = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
||||||
|
Brightness brightness = CupertinoTheme.brightnessOf(context);
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: CupertinoNavigationBar(
|
||||||
previousPageTitle: 'Settings',
|
previousPageTitle: 'Settings',
|
||||||
),
|
),
|
||||||
backgroundColor: Styles.scaffoldBackground,
|
backgroundColor: Styles.scaffoldBackground(brightness),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
FutureBuilder<int>(
|
FutureBuilder<int>(
|
||||||
@@ -138,7 +138,10 @@ class SettingsScreen extends StatelessWidget {
|
|||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Text(snapshot.data?.toString() ?? ''),
|
Text(
|
||||||
|
snapshot.data?.toString() ?? '',
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||||
|
),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
SettingsNavigationIndicator(),
|
SettingsNavigationIndicator(),
|
||||||
],
|
],
|
||||||
@@ -182,7 +185,7 @@ class SettingsScreen extends StatelessWidget {
|
|||||||
|
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Styles.scaffoldBackground,
|
color: Styles.scaffoldBackground(CupertinoTheme.brightnessOf(context)),
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: <Widget>[
|
slivers: <Widget>[
|
||||||
CupertinoSliverNavigationBar(
|
CupertinoSliverNavigationBar(
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ 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 {
|
||||||
static const headlineText = TextStyle(
|
static TextStyle headlineText(CupertinoThemeData themeData) => TextStyle(
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.8),
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontFamily: 'NotoSans',
|
fontFamily: 'NotoSans',
|
||||||
fontSize: 32,
|
fontSize: 32,
|
||||||
fontStyle: FontStyle.normal,
|
fontStyle: FontStyle.normal,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
);
|
);
|
||||||
|
|
||||||
static const minorText = TextStyle(
|
static const minorText = TextStyle(
|
||||||
color: Color.fromRGBO(128, 128, 128, 1),
|
color: Color.fromRGBO(128, 128, 128, 1),
|
||||||
@@ -24,21 +24,22 @@ abstract class Styles {
|
|||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
);
|
);
|
||||||
|
|
||||||
static const headlineName = TextStyle(
|
static TextStyle headlineName(CupertinoThemeData themeData) => TextStyle(
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontFamily: 'NotoSans',
|
fontFamily: 'NotoSans',
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
fontStyle: FontStyle.normal,
|
fontStyle: FontStyle.normal,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
);
|
);
|
||||||
|
|
||||||
static const headlineDescription = TextStyle(
|
static TextStyle headlineDescription(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.8),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 16,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.normal,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.normal,
|
fontStyle: FontStyle.normal,
|
||||||
);
|
fontWeight: FontWeight.normal,
|
||||||
|
);
|
||||||
|
|
||||||
static const cardTitleText = TextStyle(
|
static const cardTitleText = TextStyle(
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
||||||
@@ -64,37 +65,40 @@ abstract class Styles {
|
|||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
);
|
);
|
||||||
|
|
||||||
static const detailsTitleText = TextStyle(
|
static TextStyle detailsTitleText(CupertinoThemeData themeData) => TextStyle(
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontFamily: 'NotoSans',
|
fontFamily: 'NotoSans',
|
||||||
fontSize: 30,
|
fontSize: 30,
|
||||||
fontStyle: FontStyle.normal,
|
fontStyle: FontStyle.normal,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
);
|
);
|
||||||
|
|
||||||
static const detailsPreferredCategoryText = TextStyle(
|
static TextStyle detailsPreferredCategoryText(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 80, 0, 0.7),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 16,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.normal,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold,
|
fontStyle: FontStyle.normal,
|
||||||
);
|
fontWeight: FontWeight.bold,
|
||||||
|
);
|
||||||
|
|
||||||
static const detailsCategoryText = TextStyle(
|
static TextStyle detailsCategoryText(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.7),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 16,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.normal,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.normal,
|
fontStyle: FontStyle.normal,
|
||||||
);
|
fontWeight: FontWeight.normal,
|
||||||
|
);
|
||||||
|
|
||||||
static const detailsDescriptionText = TextStyle(
|
static TextStyle detailsDescriptionText(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 16,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.normal,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.normal,
|
fontStyle: FontStyle.normal,
|
||||||
);
|
fontWeight: FontWeight.normal,
|
||||||
|
);
|
||||||
|
|
||||||
static const detailsBoldDescriptionText = TextStyle(
|
static const detailsBoldDescriptionText = TextStyle(
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
||||||
@@ -112,59 +116,69 @@ abstract class Styles {
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
);
|
);
|
||||||
|
|
||||||
static const detailsServingLabelText = TextStyle(
|
static TextStyle detailsServingLabelText(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 16,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.normal,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold,
|
fontStyle: FontStyle.normal,
|
||||||
);
|
fontWeight: FontWeight.bold,
|
||||||
|
);
|
||||||
|
|
||||||
static const detailsServingValueText = TextStyle(
|
static TextStyle detailsServingValueText(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 16,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.normal,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.normal,
|
fontStyle: FontStyle.normal,
|
||||||
);
|
fontWeight: FontWeight.normal,
|
||||||
|
);
|
||||||
|
|
||||||
static const detailsServingNoteText = TextStyle(
|
static TextStyle detailsServingNoteText(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 16,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.italic,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.normal,
|
fontStyle: FontStyle.italic,
|
||||||
);
|
fontWeight: FontWeight.normal,
|
||||||
|
);
|
||||||
|
|
||||||
static const triviaFinishedTitleText = TextStyle(
|
static TextStyle triviaFinishedTitleText(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 32,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.normal,
|
fontSize: 32,
|
||||||
fontWeight: FontWeight.normal,
|
fontStyle: FontStyle.normal,
|
||||||
);
|
fontWeight: FontWeight.normal,
|
||||||
|
);
|
||||||
|
|
||||||
static const triviaFinishedText = TextStyle(
|
static TextStyle triviaFinishedText(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 16,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.normal,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.normal,
|
fontStyle: FontStyle.normal,
|
||||||
);
|
fontWeight: FontWeight.normal,
|
||||||
|
);
|
||||||
|
|
||||||
static const triviaFinishedBigText = TextStyle(
|
static TextStyle triviaFinishedBigText(CupertinoThemeData themeData) =>
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.9),
|
TextStyle(
|
||||||
fontFamily: 'NotoSans',
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontSize: 48,
|
fontFamily: 'NotoSans',
|
||||||
fontStyle: FontStyle.normal,
|
fontSize: 48,
|
||||||
fontWeight: FontWeight.normal,
|
fontStyle: FontStyle.normal,
|
||||||
);
|
fontWeight: FontWeight.normal,
|
||||||
|
);
|
||||||
|
|
||||||
static const appBackground = Color(0xffd0d0d0);
|
static const appBackground = Color(0xffd0d0d0);
|
||||||
|
|
||||||
static const scaffoldBackground = Color(0xfff0f0f0);
|
static Color scaffoldBackground(Brightness brightness) =>
|
||||||
|
brightness == Brightness.light
|
||||||
|
? CupertinoColors.lightBackgroundGray
|
||||||
|
: null;
|
||||||
|
|
||||||
static const searchBackground = Color(0xffe0e0e0);
|
static Color searchBackground(CupertinoThemeData themeData) =>
|
||||||
|
themeData.barBackgroundColor;
|
||||||
|
|
||||||
static const frostedBackground = Color(0xccf8f8f8);
|
static const frostedBackground = Color(0xccf8f8f8);
|
||||||
|
|
||||||
@@ -172,13 +186,23 @@ abstract class Styles {
|
|||||||
|
|
||||||
static const closeButtonPressed = Color(0xff808080);
|
static const closeButtonPressed = Color(0xff808080);
|
||||||
|
|
||||||
static const TextStyle searchText = TextStyle(
|
static TextStyle searchText(CupertinoThemeData themeData) => TextStyle(
|
||||||
color: Color.fromRGBO(0, 0, 0, 1),
|
color: themeData.textTheme.textStyle.color,
|
||||||
fontFamily: 'NotoSans',
|
fontFamily: 'NotoSans',
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontStyle: FontStyle.normal,
|
fontStyle: FontStyle.normal,
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
static TextStyle settingsItemText(CupertinoThemeData themeData) =>
|
||||||
|
themeData.textTheme.textStyle;
|
||||||
|
|
||||||
|
static TextStyle settingsItemSubtitleText(CupertinoThemeData themeData) =>
|
||||||
|
TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
letterSpacing: -0.2,
|
||||||
|
color: themeData.textTheme.textStyle.color,
|
||||||
|
);
|
||||||
|
|
||||||
static const Color searchCursorColor = Color.fromRGBO(0, 122, 255, 1);
|
static const Color searchCursorColor = Color.fromRGBO(0, 122, 255, 1);
|
||||||
|
|
||||||
@@ -240,7 +264,13 @@ abstract class Styles {
|
|||||||
|
|
||||||
static const Color settingsItemPressed = Color(0xffd9d9d9);
|
static const Color settingsItemPressed = Color(0xffd9d9d9);
|
||||||
|
|
||||||
static const Color settingsLineation = Color(0xffbcbbc1);
|
static Color settingsItemColor(Brightness brightness) =>
|
||||||
|
brightness == Brightness.light
|
||||||
|
? CupertinoColors.tertiarySystemBackground
|
||||||
|
: CupertinoColors.darkBackgroundGray;
|
||||||
|
|
||||||
|
static Color settingsLineation(Brightness brightness) =>
|
||||||
|
brightness == Brightness.light ? Color(0xffbcbbc1) : Color(0xFF4C4B4B);
|
||||||
|
|
||||||
static const Color settingsBackground = Color(0xffefeff4);
|
static const Color settingsBackground = Color(0xffefeff4);
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ class SearchBar extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
|
|
||||||
return DecoratedBox(
|
return DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Styles.searchBackground,
|
color: Styles.searchBackground(themeData),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -40,7 +42,7 @@ class SearchBar extends StatelessWidget {
|
|||||||
controller: controller,
|
controller: controller,
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
decoration: null,
|
decoration: null,
|
||||||
style: Styles.searchText,
|
style: Styles.searchText(themeData),
|
||||||
cursorColor: Styles.searchCursorColor,
|
cursorColor: Styles.searchCursorColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -74,14 +74,13 @@ class SettingsGroup extends StatelessWidget {
|
|||||||
final List<SettingsItem> items;
|
final List<SettingsItem> items;
|
||||||
final Widget header;
|
final Widget header;
|
||||||
final Widget footer;
|
final Widget footer;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Brightness brightness = CupertinoTheme.brightnessOf(context);
|
||||||
final dividedItems = <Widget>[items[0]];
|
final dividedItems = <Widget>[items[0]];
|
||||||
|
|
||||||
for (int i = 1; i < items.length; i++) {
|
for (int i = 1; i < items.length; i++) {
|
||||||
dividedItems.add(Container(
|
dividedItems.add(Container(
|
||||||
color: Styles.settingsLineation,
|
color: Styles.settingsLineation(brightness),
|
||||||
height: 0.3,
|
height: 0.3,
|
||||||
));
|
));
|
||||||
dividedItems.add(items[i]);
|
dividedItems.add(items[i]);
|
||||||
@@ -99,12 +98,12 @@ class SettingsGroup extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: CupertinoColors.white,
|
color: CupertinoColors.white,
|
||||||
border: Border(
|
border: Border(
|
||||||
top: const BorderSide(
|
top: BorderSide(
|
||||||
color: Styles.settingsLineation,
|
color: Styles.settingsLineation(brightness),
|
||||||
width: 0,
|
width: 0,
|
||||||
),
|
),
|
||||||
bottom: const BorderSide(
|
bottom: BorderSide(
|
||||||
color: Styles.settingsLineation,
|
color: Styles.settingsLineation(brightness),
|
||||||
width: 0,
|
width: 0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -85,9 +85,11 @@ class SettingsItemState extends State<SettingsItem> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
|
Brightness brightness = CupertinoTheme.brightnessOf(context);
|
||||||
return AnimatedContainer(
|
return AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
color: pressed ? Styles.settingsItemPressed : Styles.transparentColor,
|
color: Styles.settingsItemColor(brightness),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
@@ -132,20 +134,23 @@ class SettingsItemState extends State<SettingsItem> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(height: 8.5),
|
SizedBox(height: 8.5),
|
||||||
Text(widget.label),
|
Text(
|
||||||
|
widget.label,
|
||||||
|
style: Styles.settingsItemText(themeData),
|
||||||
|
),
|
||||||
SizedBox(height: 4),
|
SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
widget.subtitle,
|
widget.subtitle,
|
||||||
style: TextStyle(
|
style: Styles.settingsItemSubtitleText(themeData),
|
||||||
fontSize: 12,
|
|
||||||
letterSpacing: -0.2,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Padding(
|
: Padding(
|
||||||
padding: EdgeInsets.only(top: 1.5),
|
padding: EdgeInsets.only(top: 1.5),
|
||||||
child: Text(widget.label),
|
child: Text(
|
||||||
|
widget.label,
|
||||||
|
style: Styles.settingsItemText(themeData),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -106,18 +106,20 @@ class _TriviaViewState extends State<TriviaView> {
|
|||||||
// Widget shown when the game is over. It includes the score and a button to
|
// Widget shown when the game is over. It includes the score and a button to
|
||||||
// restart everything.
|
// restart everything.
|
||||||
Widget _buildFinishedView() {
|
Widget _buildFinishedView() {
|
||||||
|
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(32),
|
padding: const EdgeInsets.all(32),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'All done!',
|
'All done!',
|
||||||
style: Styles.triviaFinishedTitleText,
|
style: Styles.triviaFinishedTitleText(themeData),
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'You answered',
|
'You answered',
|
||||||
style: Styles.triviaFinishedText,
|
style: Styles.triviaFinishedText(themeData),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -126,24 +128,24 @@ class _TriviaViewState extends State<TriviaView> {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'$score',
|
'$score',
|
||||||
style: Styles.triviaFinishedBigText,
|
style: Styles.triviaFinishedBigText(themeData),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Text(
|
child: Text(
|
||||||
' of ',
|
' of ',
|
||||||
style: Styles.triviaFinishedText,
|
style: Styles.triviaFinishedText(themeData),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${veggie.trivia.length}',
|
'${veggie.trivia.length}',
|
||||||
style: Styles.triviaFinishedBigText,
|
style: Styles.triviaFinishedBigText(themeData),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'questions correctly!',
|
'questions correctly!',
|
||||||
style: Styles.triviaFinishedText,
|
style: Styles.triviaFinishedText(themeData),
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
CupertinoButton(
|
CupertinoButton(
|
||||||
@@ -162,7 +164,10 @@ class _TriviaViewState extends State<TriviaView> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
Text(currentTrivia.question),
|
Text(
|
||||||
|
currentTrivia.question,
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||||
|
),
|
||||||
SizedBox(height: 32),
|
SizedBox(height: 32),
|
||||||
for (int i = 0; i < currentTrivia.answers.length; i++)
|
for (int i = 0; i < currentTrivia.answers.length; i++)
|
||||||
Padding(
|
Padding(
|
||||||
@@ -188,9 +193,12 @@ class _TriviaViewState extends State<TriviaView> {
|
|||||||
padding: const EdgeInsets.all(32),
|
padding: const EdgeInsets.all(32),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(status == PlayerStatus.wasCorrect
|
Text(
|
||||||
? 'That\'s right!'
|
status == PlayerStatus.wasCorrect
|
||||||
: 'Sorry, that wasn\'t the right answer.'),
|
? 'That\'s right!'
|
||||||
|
: 'Sorry, that wasn\'t the right answer.',
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||||
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
CupertinoButton(
|
CupertinoButton(
|
||||||
child: Text('Next Question'),
|
child: Text('Next Question'),
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ class VeggieHeadline extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
onTap: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
||||||
builder: (context) => DetailsScreen(veggie.id),
|
builder: (context) => DetailsScreen(veggie.id),
|
||||||
@@ -89,13 +91,16 @@ class VeggieHeadline extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(veggie.name, style: Styles.headlineName),
|
Text(
|
||||||
|
veggie.name,
|
||||||
|
style: Styles.headlineName(themeData),
|
||||||
|
),
|
||||||
..._buildSeasonDots(veggie.seasons),
|
..._buildSeasonDots(veggie.seasons),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
veggie.shortDescription,
|
veggie.shortDescription,
|
||||||
style: Styles.headlineDescription,
|
style: Styles.headlineDescription(themeData),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user