Skip to content

Commit a9e0bab

Browse files
committed
[104 Completed 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. Add the slanted_menu.png to assets for 101 branch so its ready when needed. (#44) [101] TODOs for starter code (#50) [101] Added future TODOs to 101 starter [101] Included lines to ignore .iml files and files in idea/ (#67) [101] Remove 104 comments [All] Icons for Android and iOS. (#69) [101] Add .vscode/ to gitignore, stop tracking ignored files (#71) Removes files that should not be tracked because they've been ignored by gitignore rules (but have yet to be removed from the repository itself). Also adds the .vscode folder to gitignore, for users who might use VSCode as their development environment. [101] Removed legacy 'new' and 'const' from 101 starter codelab (#72) [101] Restore legacy to data.dart and product.dart (#75) [101] Update import for app.dart to stop type errors in future codelabs (#83) Replace data.dart (#99) [All] Adding back in filter functionality. (#112) [106] Update TODO from "PrimaryColorOverride" to "AccentColorOverride" (#115) * [106] Update TODO from "PrimaryColorOverride" to "AccentColorOverride" * [106] Update TODO from "PrimaryColorOverride" to "AccentColorOverride" [101] Completed code. [102] Completed code. [103] Completed code. [104] Completed code. Bump shrine_images to 1.1.1 (#138) [103] Correcting cut corners border file. [103-4] Button theme.
1 parent c834bd6 commit a9e0bab

File tree

7 files changed

+463
-104
lines changed

7 files changed

+463
-104
lines changed

mdc_100_series/lib/app.dart

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,73 @@
1414

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

17+
import 'backdrop.dart';
1718
import 'colors.dart';
1819
import 'home.dart';
1920
import 'login.dart';
21+
import 'category_menu_page.dart';
22+
import 'model/product.dart';
2023
import 'supplemental/cut_corners_border.dart';
2124

22-
// TODO: Convert ShrineApp to stateful widget (104)
23-
class ShrineApp extends StatelessWidget {
25+
class ShrineApp extends StatefulWidget {
26+
@override
27+
_ShrineAppState createState() => _ShrineAppState();
28+
}
29+
30+
class _ShrineAppState extends State<ShrineApp> {
31+
Category _currentCategory = Category.all;
2432

2533
@override
2634
Widget build(BuildContext context) {
2735
return MaterialApp(
2836
title: 'Shrine',
29-
// TODO: Change home: to a Backdrop with a HomePage frontLayer (104)
30-
home: HomePage(),
31-
// TODO: Make currentCategory field take _currentCategory (104)
32-
// TODO: Pass _currentCategory for frontLayer (104)
33-
// TODO: Change backLayer field value to CategoryMenuPage (104)
37+
home: Backdrop(
38+
currentCategory: _currentCategory,
39+
frontLayer: HomePage(category: _currentCategory),
40+
backLayer: CategoryMenuPage(
41+
currentCategory: _currentCategory,
42+
onCategoryTap: _onCategoryTap,
43+
),
44+
frontTitle: Text('SHRINE'),
45+
backTitle: Text('MENU'),
46+
),
3447
initialRoute: '/login',
3548
onGenerateRoute: _getRoute,
3649
theme: _kShrineTheme,
3750
);
3851
}
3952

40-
Route<dynamic> _getRoute(RouteSettings settings) {
41-
if (settings.name != '/login') {
42-
return null;
43-
}
53+
/// Function to call when a [Category] is tapped.
54+
void _onCategoryTap(Category category) {
55+
setState(() {
56+
_currentCategory = category;
57+
});
58+
}
59+
}
4460

45-
return MaterialPageRoute<void>(
46-
settings: settings,
47-
builder: (BuildContext context) => LoginPage(),
48-
fullscreenDialog: true,
49-
);
61+
Route<dynamic> _getRoute(RouteSettings settings) {
62+
if (settings.name != '/login') {
63+
return null;
5064
}
65+
66+
return MaterialPageRoute<void>(
67+
settings: settings,
68+
builder: (BuildContext context) => LoginPage(),
69+
fullscreenDialog: true,
70+
);
5171
}
5272

5373
final ThemeData _kShrineTheme = _buildShrineTheme();
5474

75+
IconThemeData _customIconTheme(IconThemeData original) {
76+
return original.copyWith(color: kShrineBrown900);
77+
}
78+
5579
ThemeData _buildShrineTheme() {
5680
final ThemeData base = ThemeData.light();
5781
return base.copyWith(
5882
accentColor: kShrineBrown900,
5983
primaryColor: kShrinePink100,
60-
buttonColor: kShrinePink100,
6184
scaffoldBackgroundColor: kShrineBackgroundWhite,
6285
cardColor: kShrineBackgroundWhite,
6386
textSelectionColor: kShrinePink100,
@@ -66,15 +89,14 @@ ThemeData _buildShrineTheme() {
6689
buttonColor: kShrinePink100,
6790
textTheme: ButtonTextTheme.normal,
6891
),
69-
primaryIconTheme: base.iconTheme.copyWith(
70-
color: kShrineBrown900
71-
),
92+
primaryIconTheme: base.iconTheme.copyWith(color: kShrineBrown900),
7293
inputDecorationTheme: InputDecorationTheme(
7394
border: CutCornersBorder(),
7495
),
7596
textTheme: _buildShrineTextTheme(base.textTheme),
7697
primaryTextTheme: _buildShrineTextTheme(base.primaryTextTheme),
7798
accentTextTheme: _buildShrineTextTheme(base.accentTextTheme),
99+
iconTheme: _customIconTheme(base.iconTheme),
78100
);
79101
}
80102

0 commit comments

Comments
 (0)