-
Notifications
You must be signed in to change notification settings - Fork 247
[103] First attempt at notched corner text fields and all other 103 features #8
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
[103] First attempt at notched corner text fields and all other 103 features #8
Conversation
MDC-101/complete/lib/app.dart
Outdated
@@ -6,7 +6,7 @@ import 'login.dart'; | |||
class ShrineApp extends StatelessWidget { | |||
@override | |||
Widget build(BuildContext context) { | |||
return new MaterialApp( | |||
return MaterialApp( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're using explicit new/const then ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
MDC-101/complete/lib/login.dart
Outdated
class LoginPage extends StatelessWidget { | ||
class LoginPage extends StatefulWidget { | ||
@override | ||
LoginPageState createState() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is boilerplate and the conventional boilerplate is:
_LoginPageState createState => new _LoginPageState();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
MDC-101/complete/lib/login.dart
Outdated
} | ||
} | ||
|
||
class LoginPageState extends State<LoginPage> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_LoginPageState
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
MDC-102/complete/lib/login.dart
Outdated
@@ -1,6 +1,16 @@ | |||
import 'package:flutter/material.dart'; | |||
|
|||
class LoginPage extends StatelessWidget { | |||
class LoginPage extends StatefulWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See earlier comments about this same class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
MDC-103/complete/lib/app.dart
Outdated
class ShrineApp extends StatelessWidget { | ||
ThemeData _customTheme(BuildContext context) { | ||
return Theme.of(context).copyWith( | ||
accentColor: kShrineBrown, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 space indent throughout this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatter misbehaving. Using local variable for theme made it happy. Done.
MDC-103/complete/lib/app.dart
Outdated
primaryIconTheme: | ||
_customIconTheme(Theme.of(context).primaryIconTheme), | ||
inputDecorationTheme: | ||
InputDecorationTheme(border: NotchedCornerBorder()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to be const
. I'm guessing because it's a const
constructor.
MDC-103/complete/lib/app.dart
Outdated
buttonTheme: const ButtonThemeData( | ||
textTheme: ButtonTextTheme.accent, | ||
), | ||
textTheme: _customTextTheme(Theme.of(context).textTheme), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just do this at the outset:
final ThemeData theme = Theme.of(context);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
MDC-103/complete/lib/app.dart
Outdated
return original.copyWith(color: kShrineBrown); | ||
} | ||
|
||
TextTheme _customTextTheme(TextTheme original) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a reasonable approach to take however I think we'd prefer to start with a const ThemeData value. Will follow up with proposal for how to do that.
MDC-103/complete/lib/app.dart
Outdated
return original.copyWith(color: kShrineBrown900); | ||
} | ||
|
||
TextTheme _customTextTheme(TextTheme original) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a reasonable way to handle creating such a TextTheme but I think we'd prefer to define the entire Theme with a ThemeData value. Will follow up about how to do that
MDC-103/complete/lib/home.dart
Outdated
), | ||
], | ||
), | ||
body: new Center( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this Center widget really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope! Removed.
MDC-103/complete/lib/app.dart
Outdated
import 'supplemental/theming.dart'; | ||
|
||
class ShrineApp extends StatelessWidget { | ||
ThemeData _customTheme(BuildContext context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shrine's custom theme can be defined in terms of a ThemeData value; it shouldn't be necessary to compute anything vis Theme.of()
. Here's how I'd suggest coding it.
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,
),
).apply(
fontFamily: 'Rubik',
displayColor: kShrineBrown900,
bodyColor: kShrineBrown900,
);
}
ThemeData _buildShrineTheme() {
final ThemeData base = new ThemeData.light();
return base.copyWith(
accentColor: kShrineBrown900,
primaryColor: kShrinePink100,
buttonColor: kShrinePink100,
scaffoldBackgroundColor: kShrineBackgroundWhite,
cardColor: kShrineBackgroundWhite,
textSelectionColor: kShrinePink100,
errorColor: kShrineErrorRed,
buttonTheme: const ButtonThemeData(
textTheme: ButtonTextTheme.accent,
),
primaryIconTheme: base.iconTheme.copyWith(
color: kShrineBrown900
),
inputDecorationTheme: new InputDecorationTheme(
border: new NotchedCornerBorder()
),
textTheme: _buildShrineTextTheme(base.textTheme),
primaryTextTheme: _buildShrineTextTheme(base.primaryTextTheme),
accentTextTheme: _buildShrineTextTheme(base.accentTextTheme),
);
}
final ThemeData _shrineTheme = _buildShrineTheme();
...
new MaterialApp(
theme: _shrineTheme,
...
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some minor suggestions
MDC-103/complete/lib/app.dart
Outdated
home: new HomePage(), | ||
initialRoute: '/login', | ||
onGenerateRoute: _getRoute, | ||
theme: _buildShrineTheme(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to build the Shrine theme each time and doing so clouds the fact that its a constant value. Create a final global and use that instead:
final ThemeData _kShrineTheme = _buildShrineTheme();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do this, I have to move the variable and all the functions involved to be outside the class. That's ok, right? Global for all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Global and file private.
MDC-103/complete/lib/home.dart
Outdated
|
||
import 'supplemental/asymmetric_grid.dart'; | ||
|
||
class HomePage extends StatefulWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There doesn't appear to be any reason to make this widget stateful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
MDC-103/complete/lib/login.dart
Outdated
@override | ||
Widget build(BuildContext context) { | ||
return new Scaffold( | ||
backgroundColor: kShrineSurfaceWhite, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already defined by the Shrine theme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
MDC-103/complete/lib/login.dart
Outdated
return new Theme( | ||
child: child, | ||
data: Theme.of(context).copyWith( | ||
primaryColor: color, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Removed the trailing comma and it kept it all on one line.
import '../model/product.dart'; | ||
import '../product_columns.dart'; | ||
|
||
List<Container> buildGridCardsAsymmetric(BuildContext context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a widget that returns a ListView and has a List<Product>
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
MDC-103/complete/lib/home.dart
Outdated
), | ||
], | ||
), | ||
body: new ListView( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be:
new ProductsView(products: getAllProducts())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
MDC-103/complete/pubspec.yaml
Outdated
@@ -0,0 +1,29 @@ | |||
name: mdc_101_complete | |||
description: > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the >
belong here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I assumed the character limit applied to the yaml as well. Done.
} | ||
|
||
int oddCasesIndex(int input) { | ||
return (input / 2).ceil() * 3 - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you want to assert(input > 0)
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! Done.
return const <Container>[]; | ||
} | ||
|
||
return List.generate(listItemCount(products.length), (int index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good place to include a comment that explains what you're up to here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Ready for final review.