|
|
|
@ -4,18 +4,55 @@
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.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/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 _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
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return CupertinoPageScaffold(
|
|
|
|
|
navigationBar: CupertinoNavigationBar(
|
|
|
|
|
middle: Text('My Garden'),
|
|
|
|
|
middle: Text('Your Garden'),
|
|
|
|
|
),
|
|
|
|
|
backgroundColor: Styles.scaffoldBackground,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Text('Not yet implemented.'),
|
|
|
|
|
child: _buildScaffoldBody(context),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|