mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Updates veggieseasons to Dart 2.3, adds some minor UI updates (#88)
This commit is contained in:
@@ -11,49 +11,35 @@ import 'package:veggieseasons/styles.dart';
|
||||
import 'package:veggieseasons/widgets/veggie_headline.dart';
|
||||
|
||||
class FavoritesScreen extends StatelessWidget {
|
||||
/// Builds the "content" of the favorites screen: either a list of favorite
|
||||
/// veggies or a note that says the user hasn't favorited any yet.
|
||||
Widget _buildTabViewBody(BuildContext context) {
|
||||
final model = ScopedModel.of<AppState>(context, rebuildOnChange: true);
|
||||
|
||||
if (model.favoriteVeggies.length == 0) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
child: Text(
|
||||
'You haven\'t added any favorite veggies to your garden yet.',
|
||||
style: Styles.headlineDescription,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final rows = <Widget>[
|
||||
SizedBox(height: 24.0),
|
||||
];
|
||||
|
||||
for (Veggie veggie in model.favoriteVeggies) {
|
||||
rows.add(
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 16.0, right: 16.0, bottom: 24.0),
|
||||
child: VeggieHeadline(veggie),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView(
|
||||
children: rows,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoTabView(
|
||||
builder: (context) {
|
||||
final model = ScopedModel.of<AppState>(context, rebuildOnChange: true);
|
||||
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('My Garden'),
|
||||
),
|
||||
child: Center(
|
||||
child: _buildTabViewBody(context),
|
||||
child: model.favoriteVeggies.isEmpty
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Text(
|
||||
'You haven\'t added any favorite veggies to your garden yet.',
|
||||
style: Styles.headlineDescription,
|
||||
),
|
||||
)
|
||||
: ListView(
|
||||
children: [
|
||||
SizedBox(height: 24),
|
||||
for (Veggie veggie in model.favoriteVeggies)
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 0, 16, 24),
|
||||
child: VeggieHeadline(veggie),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user