Adding favorites screen to veggieseasons. (#16)

pull/17/head
Andrew Brogdon 6 years ago committed by GitHub
parent 1ed6c91700
commit 5f040e6545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,18 +4,55 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:veggieseasons/data/model.dart';
import 'package:veggieseasons/data/veggie.dart';
import 'package:veggieseasons/styles.dart'; import 'package:veggieseasons/styles.dart';
import 'package:veggieseasons/widgets/veggie_headline.dart';
class FavoritesScreen extends StatelessWidget { 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 _buildScaffoldBody(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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CupertinoPageScaffold( return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar( navigationBar: CupertinoNavigationBar(
middle: Text('My Garden'), middle: Text('Your Garden'),
), ),
backgroundColor: Styles.scaffoldBackground, backgroundColor: Styles.scaffoldBackground,
child: Center( child: Center(
child: Text('Not yet implemented.'), child: _buildScaffoldBody(context),
), ),
); );
} }

Loading…
Cancel
Save