Skip to content

Commit

Permalink
[102] Completed code.
Browse files Browse the repository at this point in the history
[101] Starter code.

[101] Making AppBar something you add in 102.

[Model] Adding model from the start.

[103] Adding fonts.

[103] Supplemental files.

[101] Correcting supplemental files.

[101] Copy correction.

[101] Minor renaming.

[101] Update for Dart 2.

[101] Missing dependency.

[101] Dart 2.

[101] Dart 2.

[101] Dart 2.

[101] Dart 2.

[101] Correcting model.

[Meta] README file.

[Meta] Clarification.

[101] Copy correction.

[104] Updating data.

[101] Correcting widget class. (material-components#23)

Add link to actual codelab in the README

[Meta] README correction.

[101] README specificity.

[101] Complete code.
[102] Starter code.

[102] Minor copy correction.

[101] Update for Dart 2

[102] Rebase.

Add the slanted_menu.png to assets for 101 branch so its ready when needed. (material-components#44) (material-components#45)

[102] Complete code.
[103] Starter code.

[102] Correcting home being stateful.

[103] Correcting order of fields. (material-components#10)

[102] Removing unneeded value.

[102] Dart 2.

[102] Data correction.

[103] README specificity.

[META] Readme correction.
  • Loading branch information
willlarche authored and tianlunlee committed Jun 27, 2018
1 parent 56dc63a commit aaf2a2f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -11,7 +11,7 @@ Codelabs MDC-101 through MDC-104 will guide you through building and integrating
The starter and completed code is in the various branches of this repo.

## Getting Started
Visit the [Google codelabs site](https://codelabs.developers.google.com/), or [codelabs.developers.google.com/codelabs/mdc-102-flutter](https://codelabs.developers.google.com/codelabs/mdc-102-flutter), to follow along the guided steps.
Visit the [Google codelabs site](https://codelabs.developers.google.com/), or [codelabs.developers.google.com/codelabs/mdc-103-flutter](https://codelabs.developers.google.com/codelabs/mdc-103-flutter), to follow along the guided steps.

## Support

Expand Down
86 changes: 82 additions & 4 deletions mdc_100_series/lib/home.dart
Expand Up @@ -15,14 +15,92 @@
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
// TODO: Make a collection of cards (102)

List<Card> _buildGridCards(BuildContext context) {
List<Product> products = getProducts(Category.all);

if (products == null || products.isEmpty) {
return const <Card>[];
}

final ThemeData theme = Theme.of(context);
final NumberFormat formatter = NumberFormat.simpleCurrency(
locale: Localizations.localeOf(context).toString());

return products.map((product) {
return Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AspectRatio(
aspectRatio: 18 / 11,
child: Image.asset(
product.assetName,
package: product.assetPackage,
fit: BoxFit.fitWidth,
),
),
Expanded(
child: Padding(
padding: EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// TODO(larche): Make headline6 when available
Text(
product.name,
style: theme.textTheme.title,
maxLines: 1,
),
SizedBox(height: 8.0),
// TODO(larche): Make subtitle2 when available
Text(
formatter.format(product.price),
style: theme.textTheme.body2,
),
],
),
),
),
],
),
);
}).toList();
}

@override
Widget build(BuildContext context) {
return Scaffold(
// TODO: Add app bar (102)
// TODO: Add a grid view (102)
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.menu),
onPressed: () {
print('Menu button');
},
),
title: Text('SHRINE'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {
print('Search button');
},
),
IconButton(
icon: Icon(Icons.tune),
onPressed: () {
print('Filter button');
},
),
],
),
body: Center(
child: Text('You did it!'),
child: GridView.count(
crossAxisCount: 2,
padding: EdgeInsets.all(16.0),
childAspectRatio: 8.0 / 9.0,
children: _buildGridCards(context),
),
),
);
}
Expand Down

0 comments on commit aaf2a2f

Please sign in to comment.