Skip to content

Commit 7c5fecb

Browse files
authored
Styling revamp using CupertinoThemeData and CupertinoTextThemeData (#593)
1 parent 1d33b3d commit 7c5fecb

File tree

11 files changed

+160
-231
lines changed

11 files changed

+160
-231
lines changed

experimental/veggieseasons/lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:provider/provider.dart';
88
import 'package:veggieseasons/data/app_state.dart';
99
import 'package:veggieseasons/data/preferences.dart';
1010
import 'package:veggieseasons/screens/home.dart';
11+
import 'package:veggieseasons/styles.dart';
1112

1213
void main() {
1314
WidgetsFlutterBinding.ensureInitialized();
@@ -58,6 +59,7 @@ class _VeggieAppState extends State<VeggieApp> with RestorationMixin {
5859
),
5960
],
6061
child: CupertinoApp(
62+
theme: Styles.veggieThemeData,
6163
debugShowCheckedModeBanner: false,
6264
home: HomeScreen(restorationId: 'home'),
6365
restorationScopeId: 'app',

experimental/veggieseasons/lib/screens/details.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ class ServingInfoChart extends StatelessWidget {
2828
builder: (context, snapshot) {
2929
final target = snapshot?.data ?? 2000;
3030
final percent = standardPercentage * 2000 ~/ target;
31-
final themeData = CupertinoTheme.of(context);
3231

3332
return Text(
3433
'$percent% DV',
34+
style: CupertinoTheme.of(context).textTheme.textStyle,
3535
textAlign: TextAlign.end,
36-
style: Styles.detailsServingValueText(themeData),
3736
);
3837
},
3938
);
@@ -54,7 +53,7 @@ class ServingInfoChart extends StatelessWidget {
5453
),
5554
child: Text(
5655
'Serving info',
57-
style: Styles.detailsServingHeaderText,
56+
style: CupertinoTheme.of(context).textTheme.textStyle,
5857
),
5958
),
6059
),
@@ -79,7 +78,7 @@ class ServingInfoChart extends StatelessWidget {
7978
child: Text(
8079
veggie.servingSize,
8180
textAlign: TextAlign.end,
82-
style: Styles.detailsServingValueText(themeData),
81+
style: CupertinoTheme.of(context).textTheme.textStyle,
8382
),
8483
),
8584
],
@@ -95,8 +94,8 @@ class ServingInfoChart extends StatelessWidget {
9594
TableCell(
9695
child: Text(
9796
'${veggie.caloriesPerServing} kCal',
97+
style: CupertinoTheme.of(context).textTheme.textStyle,
9898
textAlign: TextAlign.end,
99-
style: Styles.detailsServingValueText(themeData),
10099
),
101100
),
102101
],
@@ -184,7 +183,7 @@ class InfoView extends StatelessWidget {
184183
style: (snapshot.hasData &&
185184
snapshot.data.contains(veggie.category))
186185
? Styles.detailsPreferredCategoryText(themeData)
187-
: Styles.detailsCategoryText(themeData),
186+
: themeData.textTheme.textStyle,
188187
);
189188
},
190189
),
@@ -210,7 +209,7 @@ class InfoView extends StatelessWidget {
210209
SizedBox(height: 8),
211210
Text(
212211
veggie.shortDescription,
213-
style: Styles.detailsDescriptionText(themeData),
212+
style: CupertinoTheme.of(context).textTheme.textStyle,
214213
),
215214
ServingInfoChart(veggie, prefs),
216215
SizedBox(height: 24),
@@ -249,7 +248,8 @@ class DetailsScreen extends StatefulWidget {
249248
static Route<void> _routeBuilder(BuildContext context, Object arguments) {
250249
final veggieId = arguments as int;
251250
return CupertinoPageRoute(
252-
builder: (context) => DetailsScreen(id: veggieId, restorationId: 'details'),
251+
builder: (context) =>
252+
DetailsScreen(id: veggieId, restorationId: 'details'),
253253
fullscreenDialog: true,
254254
);
255255
}
@@ -324,8 +324,12 @@ class _DetailsScreenState extends State<DetailsScreen> with RestorationMixin {
324324
SizedBox(height: 20),
325325
CupertinoSegmentedControl<int>(
326326
children: {
327-
0: Text('Facts & Info'),
328-
1: Text('Trivia'),
327+
0: Text(
328+
'Facts & Info',
329+
),
330+
1: Text(
331+
'Trivia',
332+
)
329333
},
330334
groupValue: _selectedViewIndex.value,
331335
onValueChanged: (value) {

experimental/veggieseasons/lib/screens/favorites.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:flutter/widgets.dart';
77
import 'package:provider/provider.dart';
88
import 'package:veggieseasons/data/app_state.dart';
99
import 'package:veggieseasons/data/veggie.dart';
10-
import 'package:veggieseasons/styles.dart';
1110
import 'package:veggieseasons/widgets/veggie_headline.dart';
1211

1312
class FavoritesScreen extends StatelessWidget {
@@ -32,8 +31,7 @@ class FavoritesScreen extends StatelessWidget {
3231
padding: const EdgeInsets.symmetric(horizontal: 24),
3332
child: Text(
3433
'You haven\'t added any favorite veggies to your garden yet.',
35-
style: Styles.headlineDescription(
36-
CupertinoTheme.of(context)),
34+
style: CupertinoTheme.of(context).textTheme.textStyle,
3735
),
3836
)
3937
: ListView(

experimental/veggieseasons/lib/screens/list.dart

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import 'package:flutter/cupertino.dart';
6+
import 'package:flutter/services.dart';
67
import 'package:flutter/widgets.dart';
78
import 'package:intl/intl.dart';
89
import 'package:provider/provider.dart';
@@ -40,43 +41,48 @@ class ListScreen extends StatelessWidget {
4041
final appState = Provider.of<AppState>(context);
4142
final prefs = Provider.of<Preferences>(context);
4243
final themeData = CupertinoTheme.of(context);
43-
return SafeArea(
44-
bottom: false,
45-
child: ListView.builder(
46-
restorationId: 'list',
47-
itemCount: appState.allVeggies.length + 2,
48-
itemBuilder: (context, index) {
49-
if (index == 0) {
50-
return Padding(
51-
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
52-
child: Column(
53-
crossAxisAlignment: CrossAxisAlignment.start,
54-
children: [
55-
Text(dateString.toUpperCase(), style: Styles.minorText),
56-
Text('In season today',
57-
style: Styles.headlineText(themeData)),
58-
],
59-
),
60-
);
61-
} else if (index <= appState.availableVeggies.length) {
62-
return _generateVeggieRow(
63-
appState.availableVeggies[index - 1],
64-
prefs,
65-
);
66-
} else if (index <= appState.availableVeggies.length + 1) {
67-
return Padding(
68-
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
69-
child: Text('Not in season',
70-
style: Styles.headlineText(themeData)),
71-
);
72-
} else {
73-
var relativeIndex =
74-
index - (appState.availableVeggies.length + 2);
75-
return _generateVeggieRow(
76-
appState.unavailableVeggies[relativeIndex], prefs,
77-
inSeason: false);
78-
}
79-
},
44+
return AnnotatedRegion<SystemUiOverlayStyle>(
45+
value: SystemUiOverlayStyle(
46+
statusBarBrightness: MediaQuery.platformBrightnessOf(context)),
47+
child: SafeArea(
48+
bottom: false,
49+
child: ListView.builder(
50+
restorationId: 'list',
51+
itemCount: appState.allVeggies.length + 2,
52+
itemBuilder: (context, index) {
53+
if (index == 0) {
54+
return Padding(
55+
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
56+
child: Column(
57+
crossAxisAlignment: CrossAxisAlignment.start,
58+
children: [
59+
Text(dateString.toUpperCase(),
60+
style: Styles.minorText(themeData)),
61+
Text('In season today',
62+
style: Styles.headlineText(themeData)),
63+
],
64+
),
65+
);
66+
} else if (index <= appState.availableVeggies.length) {
67+
return _generateVeggieRow(
68+
appState.availableVeggies[index - 1],
69+
prefs,
70+
);
71+
} else if (index <= appState.availableVeggies.length + 1) {
72+
return Padding(
73+
padding: const EdgeInsets.fromLTRB(16, 24, 16, 16),
74+
child: Text('Not in season',
75+
style: Styles.headlineText(themeData)),
76+
);
77+
} else {
78+
var relativeIndex =
79+
index - (appState.availableVeggies.length + 2);
80+
return _generateVeggieRow(
81+
appState.unavailableVeggies[relativeIndex], prefs,
82+
inSeason: false);
83+
}
84+
},
85+
),
8086
),
8187
);
8288
},

experimental/veggieseasons/lib/screens/search.dart

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// found in the LICENSE file.
44

55
import 'package:flutter/cupertino.dart';
6+
import 'package:flutter/services.dart';
67
import 'package:flutter/widgets.dart';
78
import 'package:provider/provider.dart';
89
import 'package:veggieseasons/data/app_state.dart';
910
import 'package:veggieseasons/data/veggie.dart';
10-
import 'package:veggieseasons/styles.dart';
1111
import 'package:veggieseasons/widgets/search_bar.dart';
1212
import 'package:veggieseasons/widgets/veggie_headline.dart';
1313

@@ -63,7 +63,7 @@ class _SearchScreenState extends State<SearchScreen> with RestorationMixin {
6363
padding: const EdgeInsets.symmetric(horizontal: 24),
6464
child: Text(
6565
'No veggies matching your search terms were found.',
66-
style: Styles.headlineDescription(CupertinoTheme.of(context)),
66+
style: CupertinoTheme.of(context).textTheme.textStyle,
6767
),
6868
),
6969
);
@@ -101,15 +101,19 @@ class _SearchScreenState extends State<SearchScreen> with RestorationMixin {
101101
return UnmanagedRestorationScope(
102102
child: CupertinoTabView(
103103
builder: (context) {
104-
return SafeArea(
105-
bottom: false,
106-
child: Stack(
107-
children: [
108-
_buildSearchResults(model.searchVeggies(terms)),
109-
_createSearchBox(),
110-
],
111-
),
112-
);
104+
return AnnotatedRegion<SystemUiOverlayStyle>(
105+
value: SystemUiOverlayStyle(
106+
statusBarBrightness:
107+
MediaQuery.platformBrightnessOf(context)),
108+
child: SafeArea(
109+
bottom: false,
110+
child: Stack(
111+
children: [
112+
_buildSearchResults(model.searchVeggies(terms)),
113+
_createSearchBox(),
114+
],
115+
),
116+
));
113117
},
114118
),
115119
);

0 commit comments

Comments
 (0)