mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Adds veggieseasons preferences, tweaks styles + list page (#37)
This commit is contained in:
@@ -9,13 +9,19 @@ import 'package:veggieseasons/data/model.dart';
|
||||
import 'package:veggieseasons/data/veggie.dart';
|
||||
import 'package:veggieseasons/styles.dart';
|
||||
|
||||
/// A circular widget that indicates in which seasons a particular veggie can be
|
||||
/// harvested. It displays the first two letters of the season and uses a
|
||||
/// different background color to represent each of the seasons as well.
|
||||
/// A circular widget that represents a season of the year.
|
||||
///
|
||||
/// The season can be displayed as a valid harvest season or one during which a
|
||||
/// particular veggie cannot be harvested. Bright colors are used in the first
|
||||
/// case, and grays in the latter.
|
||||
class SeasonCircle extends StatelessWidget {
|
||||
SeasonCircle(this.season, this.isHarvestTime);
|
||||
|
||||
/// Season to be displayed by this widget.
|
||||
final Season season;
|
||||
|
||||
SeasonCircle(this.season);
|
||||
/// Whether or not [season] should be presented as a valid harvest season.
|
||||
final bool isHarvestTime;
|
||||
|
||||
String get _firstChars {
|
||||
return '${season.toString().substring(7, 8).toUpperCase()}'
|
||||
@@ -28,7 +34,9 @@ class SeasonCircle extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.seasonColors[season],
|
||||
color: isHarvestTime
|
||||
? Styles.seasonColors[season]
|
||||
: Styles.transparentColor,
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Styles.seasonBorder,
|
||||
),
|
||||
@@ -36,7 +44,12 @@ class SeasonCircle extends StatelessWidget {
|
||||
height: 50.0,
|
||||
width: 50.0,
|
||||
child: Center(
|
||||
child: Text(_firstChars, style: Styles.seasonText),
|
||||
child: Text(
|
||||
_firstChars,
|
||||
style: isHarvestTime
|
||||
? Styles.activeSeasonText
|
||||
: Styles.inactiveSeasonText,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -116,8 +129,9 @@ class DetailsScreen extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Wrap(
|
||||
children:
|
||||
veggie.seasons.map<Widget>((s) => SeasonCircle(s)).toList(),
|
||||
children: Season.values.map((s) {
|
||||
return SeasonCircle(s, veggie.seasons.contains(s));
|
||||
}).toList(),
|
||||
),
|
||||
SizedBox(width: 8.0),
|
||||
Expanded(
|
||||
|
||||
Reference in New Issue
Block a user