mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Adds model layer and list view to veggieseasons. (#13)
This commit is contained in:
74
veggieseasons/lib/widgets/veggie_headline.dart
Normal file
74
veggieseasons/lib/widgets/veggie_headline.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright 2018 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:veggieseasons/data/veggie.dart';
|
||||
import 'package:veggieseasons/styles.dart';
|
||||
|
||||
class VeggieHeadline extends StatelessWidget {
|
||||
final Veggie veggie;
|
||||
|
||||
const VeggieHeadline(this.veggie);
|
||||
|
||||
List<Widget> _buildSeasonDots(List<Season> seasons) {
|
||||
List<Widget> widgets = <Widget>[];
|
||||
|
||||
for (Season season in seasons) {
|
||||
widgets.add(SizedBox(width: 4.0));
|
||||
widgets.add(
|
||||
Container(
|
||||
height: 10.0,
|
||||
width: 10.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.seasonColors[season],
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
/* TODO(redbrogdon): navigation forthcoming */
|
||||
},
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 80.0,
|
||||
height: 80.0,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
child: Image.asset(
|
||||
veggie.imageAssetPath,
|
||||
fit: BoxFit.fitWidth,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8.0),
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Text(veggie.name, style: Styles.headlineName),
|
||||
]..addAll(_buildSeasonDots(veggie.seasons)),
|
||||
),
|
||||
Text(veggie.shortDescription,
|
||||
style: Styles.headlineDescription),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user