Skip to content

[104] PrimaryColorOverride -> AccentColorOverride #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
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-101-flutter](https://codelabs.developers.google.com/codelabs/mdc-101-flutter), to follow along the guided steps.
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.

## Support

Expand Down
112 changes: 92 additions & 20 deletions mdc_100_series/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,111 @@

import 'package:flutter/material.dart';

import 'backdrop.dart';
import 'colors.dart';
import 'home.dart';
import 'login.dart';
import 'category_menu_page.dart';
import 'model/product.dart';
import 'supplemental/cut_corners_border.dart';

class ShrineApp extends StatefulWidget {
@override
_ShrineAppState createState() => _ShrineAppState();
}

class _ShrineAppState extends State<ShrineApp> {
Category _currentCategory = Category.all;

// TODO: Convert ShrineApp to stateful widget (104)
class ShrineApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Shrine',
// TODO: Change home: to a Backdrop with a HomePage frontLayer (104)
home: HomePage(),
// TODO: Make currentCategory field take _currentCategory (104)
// TODO: Pass _currentCategory for frontLayer (104)
// TODO: Change backLayer field value to CategoryMenuPage (104)
home: Backdrop(
currentCategory: _currentCategory,
frontLayer: HomePage(category: _currentCategory),
backLayer: CategoryMenuPage(
currentCategory: _currentCategory,
onCategoryTap: _onCategoryTap,
),
frontTitle: Text('SHRINE'),
backTitle: Text('MENU'),
),
initialRoute: '/login',
onGenerateRoute: _getRoute,
// TODO: Add a theme (103)
theme: _kShrineTheme,
);
}

Route<dynamic> _getRoute(RouteSettings settings) {
if (settings.name != '/login') {
return null;
}
/// Function to call when a [Category] is tapped.
void _onCategoryTap(Category category) {
setState(() {
_currentCategory = category;
});
}
}

return MaterialPageRoute<void>(
settings: settings,
builder: (BuildContext context) => LoginPage(),
fullscreenDialog: true,
);
Route<dynamic> _getRoute(RouteSettings settings) {
if (settings.name != '/login') {
return null;
}

return MaterialPageRoute<void>(
settings: settings,
builder: (BuildContext context) => LoginPage(),
fullscreenDialog: true,
);
}

final ThemeData _kShrineTheme = _buildShrineTheme();

IconThemeData _customIconTheme(IconThemeData original) {
return original.copyWith(color: kShrineBrown900);
}

// TODO: Build a Shrine Theme (103)
// TODO: Build a Shrine Text Theme (103)
ThemeData _buildShrineTheme() {
final ThemeData base = ThemeData.light();
return base.copyWith(
accentColor: kShrineBrown900,
primaryColor: kShrinePink100,
buttonColor: kShrinePink100,
scaffoldBackgroundColor: kShrineBackgroundWhite,
cardColor: kShrineBackgroundWhite,
textSelectionColor: kShrinePink100,
errorColor: kShrineErrorRed,
buttonTheme: ButtonThemeData(
textTheme: ButtonTextTheme.accent,
),
primaryIconTheme: base.iconTheme.copyWith(color: kShrineBrown900),
inputDecorationTheme: InputDecorationTheme(
border: CutCornersBorder(),
),
textTheme: _buildShrineTextTheme(base.textTheme),
primaryTextTheme: _buildShrineTextTheme(base.primaryTextTheme),
accentTextTheme: _buildShrineTextTheme(base.accentTextTheme),
iconTheme: _customIconTheme(base.iconTheme),
);
}

TextTheme _buildShrineTextTheme(TextTheme base) {
return base.copyWith(
headline: base.headline.copyWith(
fontWeight: FontWeight.w500,
),
title: base.title.copyWith(
fontSize: 18.0
),
caption: base.caption.copyWith(
fontWeight: FontWeight.w400,
fontSize: 14.0,
),
body2: base.body2.copyWith(
fontWeight: FontWeight.w500,
fontSize: 16.0,
),
).apply(
fontFamily: 'Rubik',
displayColor: kShrineBrown900,
bodyColor: kShrineBrown900,
);
}
Loading