Skip to content

Commit 574253b

Browse files
willlarchetianlunlee
authored andcommitted
[103] Completed code.
[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. (#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. (#44) (#45) [102] Complete code. [103] Starter code. [102] Correcting home being stateful. [103] Correcting order of fields. (#10) [102] Removing unneeded value. [102] Dart 2. [102] Data correction. [103] README specificity. [103] Completed code. [104] Starter code. [103] Removing unneeded directory. [103] Unused icons code. [103] Moving supplemental files. [103] Using recent changes. [103] Removing unused import. [103] Data correction. [103] Adding body2 styling. [103] Dart 2 [103] Color const correction. [104] README specificity.
1 parent c7c1324 commit 574253b

File tree

6 files changed

+142
-84
lines changed

6 files changed

+142
-84
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Codelabs MDC-101 through MDC-104 will guide you through building and integrating
1111
The starter and completed code is in the various branches of this repo.
1212

1313
## Getting Started
14-
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.
14+
Visit the [Google codelabs site](https://codelabs.developers.google.com/), or [codelabs.developers.google.com/codelabs/mdc-104-flutter](https://codelabs.developers.google.com/codelabs/mdc-104-flutter), to follow along the guided steps.
1515

1616
## Support
1717

mdc_100_series/lib/app.dart

+60-7
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414

1515
import 'package:flutter/material.dart';
1616

17+
import 'colors.dart';
1718
import 'home.dart';
1819
import 'login.dart';
20+
import 'supplemental/cut_corners_border.dart';
1921

2022
class ShrineApp extends StatelessWidget {
2123
@override
@@ -25,18 +27,69 @@ class ShrineApp extends StatelessWidget {
2527
home: HomePage(),
2628
initialRoute: '/login',
2729
onGenerateRoute: _getRoute,
30+
theme: _kShrineTheme,
2831
);
2932
}
3033

3134
Route<dynamic> _getRoute(RouteSettings settings) {
32-
if (settings.name != '/login') {
33-
return null;
35+
if (settings.name == '/login') {
36+
return MaterialPageRoute<void>(
37+
settings: settings,
38+
builder: (BuildContext context) => LoginPage(),
39+
fullscreenDialog: true,
40+
);
3441
}
3542

36-
return MaterialPageRoute<void>(
37-
settings: settings,
38-
builder: (BuildContext context) => LoginPage(),
39-
fullscreenDialog: true,
40-
);
43+
return null;
4144
}
4245
}
46+
47+
final ThemeData _kShrineTheme = _buildShrineTheme();
48+
49+
ThemeData _buildShrineTheme() {
50+
final ThemeData base = ThemeData.light();
51+
return base.copyWith(
52+
accentColor: kShrineBrown900,
53+
primaryColor: kShrinePink100,
54+
buttonColor: kShrinePink100,
55+
scaffoldBackgroundColor: kShrineBackgroundWhite,
56+
cardColor: kShrineBackgroundWhite,
57+
textSelectionColor: kShrinePink100,
58+
errorColor: kShrineErrorRed,
59+
buttonTheme: ButtonThemeData(
60+
textTheme: ButtonTextTheme.accent,
61+
),
62+
primaryIconTheme: base.iconTheme.copyWith(
63+
color: kShrineBrown900
64+
),
65+
inputDecorationTheme: InputDecorationTheme(
66+
border: CutCornersBorder(),
67+
),
68+
textTheme: _buildShrineTextTheme(base.textTheme),
69+
primaryTextTheme: _buildShrineTextTheme(base.primaryTextTheme),
70+
accentTextTheme: _buildShrineTextTheme(base.accentTextTheme),
71+
);
72+
}
73+
74+
TextTheme _buildShrineTextTheme(TextTheme base) {
75+
return base.copyWith(
76+
headline: base.headline.copyWith(
77+
fontWeight: FontWeight.w500,
78+
),
79+
title: base.title.copyWith(
80+
fontSize: 18.0
81+
),
82+
caption: base.caption.copyWith(
83+
fontWeight: FontWeight.w400,
84+
fontSize: 14.0,
85+
),
86+
body2: base.body2.copyWith(
87+
fontWeight: FontWeight.w500,
88+
fontSize: 16.0,
89+
),
90+
).apply(
91+
fontFamily: 'Rubik',
92+
displayColor: kShrineBrown900,
93+
bodyColor: kShrineBrown900,
94+
);
95+
}

mdc_100_series/lib/colors.dart

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2018-present the Flutter authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import 'package:flutter/material.dart';
16+
17+
const kShrinePink50 = const Color(0xFFFEEAE6);
18+
const kShrinePink100 = const Color(0xFFFEDBD0);
19+
const kShrinePink300 = const Color(0xFFFBB8AC);
20+
21+
const kShrineBrown900 = const Color(0xFF442B2D);
22+
23+
const kShrineErrorRed = const Color(0xFFC5032B);
24+
25+
const kShrineSurfaceWhite = const Color(0xFFFFFBFA);
26+
const kShrineBackgroundWhite = Colors.white;

mdc_100_series/lib/home.dart

+3-62
Original file line numberDiff line numberDiff line change
@@ -13,69 +13,17 @@
1313
// limitations under the License.
1414

1515
import 'package:flutter/material.dart';
16-
import 'package:intl/intl.dart';
1716

1817
import 'model/data.dart';
1918
import 'model/product.dart';
19+
import 'supplemental/asymmetric_view.dart';
2020

2121
class HomePage extends StatelessWidget {
22-
23-
List<Card> _buildGridCards(BuildContext context) {
24-
List<Product> products = getProducts(Category.all);
25-
26-
if (products == null || products.isEmpty) {
27-
return const <Card>[];
28-
}
29-
30-
final ThemeData theme = Theme.of(context);
31-
final NumberFormat formatter = NumberFormat.simpleCurrency(
32-
locale: Localizations.localeOf(context).toString());
33-
34-
return products.map((product) {
35-
return Card(
36-
child: Column(
37-
crossAxisAlignment: CrossAxisAlignment.start,
38-
children: <Widget>[
39-
AspectRatio(
40-
aspectRatio: 18 / 11,
41-
child: Image.asset(
42-
product.assetName,
43-
package: product.assetPackage,
44-
fit: BoxFit.fitWidth,
45-
),
46-
),
47-
Expanded(
48-
child: Padding(
49-
padding: EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 8.0),
50-
child: Column(
51-
crossAxisAlignment: CrossAxisAlignment.start,
52-
children: <Widget>[
53-
// TODO(larche): Make headline6 when available
54-
Text(
55-
product.name,
56-
style: theme.textTheme.title,
57-
maxLines: 1,
58-
),
59-
SizedBox(height: 8.0),
60-
// TODO(larche): Make subtitle2 when available
61-
Text(
62-
formatter.format(product.price),
63-
style: theme.textTheme.body2,
64-
),
65-
],
66-
),
67-
),
68-
),
69-
],
70-
),
71-
);
72-
}).toList();
73-
}
74-
7522
@override
7623
Widget build(BuildContext context) {
7724
return Scaffold(
7825
appBar: AppBar(
26+
brightness: Brightness.light,
7927
leading: IconButton(
8028
icon: Icon(Icons.menu),
8129
onPressed: () {
@@ -98,14 +46,7 @@ class HomePage extends StatelessWidget {
9846
),
9947
],
10048
),
101-
body: Center(
102-
child: GridView.count(
103-
crossAxisCount: 2,
104-
padding: EdgeInsets.all(16.0),
105-
childAspectRatio: 8.0 / 9.0,
106-
children: _buildGridCards(context),
107-
),
108-
),
49+
body: AsymmetricView(products: getProducts(Category.all)),
10950
);
11051
}
11152
}

mdc_100_series/lib/login.dart

+44-13
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import 'package:flutter/material.dart';
1616

17+
import 'colors.dart';
18+
1719
class LoginPage extends StatefulWidget {
1820
@override
1921
_LoginPageState createState() => _LoginPageState();
@@ -35,37 +37,50 @@ class _LoginPageState extends State<LoginPage> {
3537
children: <Widget>[
3638
Image.asset('assets/diamond.png'),
3739
SizedBox(height: 16.0),
38-
Text('SHRINE'),
40+
Text(
41+
'SHRINE',
42+
style: Theme.of(context).textTheme.headline,
43+
),
3944
],
4045
),
4146
SizedBox(height: 120.0),
42-
TextField(
43-
controller: _usernameController,
44-
decoration: InputDecoration(
45-
filled: true,
46-
labelText: 'Username',
47+
PrimaryColorOverride(
48+
color: kShrineBrown900,
49+
child: TextField(
50+
controller: _usernameController,
51+
decoration: InputDecoration(
52+
labelText: 'Username',
53+
),
4754
),
4855
),
49-
SizedBox(height: 12.0),
50-
TextField(
51-
controller: _passwordController,
52-
decoration: InputDecoration(
53-
filled: true,
54-
labelText: 'Password',
56+
const SizedBox(height: 12.0),
57+
new PrimaryColorOverride(
58+
color: kShrineBrown900,
59+
child: TextField(
60+
controller: _passwordController,
61+
decoration: InputDecoration(
62+
labelText: 'Password',
63+
),
5564
),
56-
obscureText: true,
5765
),
5866
ButtonBar(
5967
children: <Widget>[
6068
FlatButton(
6169
child: Text('CANCEL'),
70+
shape: BeveledRectangleBorder(
71+
borderRadius: BorderRadius.all(Radius.circular(7.0)),
72+
),
6273
onPressed: () {
6374
_usernameController.clear();
6475
_passwordController.clear();
6576
},
6677
),
6778
RaisedButton(
6879
child: Text('NEXT'),
80+
elevation: 8.0,
81+
shape: BeveledRectangleBorder(
82+
borderRadius: BorderRadius.all(Radius.circular(7.0)),
83+
),
6984
onPressed: () {
7085
Navigator.pop(context);
7186
},
@@ -78,3 +93,19 @@ class _LoginPageState extends State<LoginPage> {
7893
);
7994
}
8095
}
96+
97+
class PrimaryColorOverride extends StatelessWidget {
98+
const PrimaryColorOverride({Key key, this.color, this.child})
99+
: super(key: key);
100+
101+
final Color color;
102+
final Widget child;
103+
104+
@override
105+
Widget build(BuildContext context) {
106+
return Theme(
107+
child: child,
108+
data: Theme.of(context).copyWith(primaryColor: color),
109+
);
110+
}
111+
}

mdc_100_series/pubspec.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Shrine
2-
description: Learn how to use Material for structure and layout.
2+
description: Take your design up a notch and learn to use our advanced component backdrop menu.
33

44
dependencies:
55
flutter:
@@ -55,3 +55,10 @@ flutter:
5555
- packages/shrine_images/35-0.jpg
5656
- packages/shrine_images/36-0.jpg
5757
- packages/shrine_images/37-0.jpg
58+
59+
fonts:
60+
- family: Rubik
61+
fonts:
62+
- asset: fonts/Rubik-Regular.ttf
63+
- asset: fonts/Rubik-Medium.ttf
64+
weight: 500

0 commit comments

Comments
 (0)