Skip to content

[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

Merged
merged 70 commits into from
Apr 23, 2018
Merged

[103] First attempt at notched corner text fields and all other 103 features #8

merged 70 commits into from
Apr 23, 2018

Conversation

willlarche
Copy link
Collaborator

@willlarche willlarche commented Apr 18, 2018

Ready for final review.

@@ -6,7 +6,7 @@ import 'login.dart';
class ShrineApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
Copy link
Collaborator

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 ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

class LoginPage extends StatelessWidget {
class LoginPage extends StatefulWidget {
@override
LoginPageState createState() {
Copy link
Collaborator

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();

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
}

class LoginPageState extends State<LoginPage> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_LoginPageState

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -1,6 +1,16 @@
import 'package:flutter/material.dart';

class LoginPage extends StatelessWidget {
class LoginPage extends StatefulWidget {
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected.

class ShrineApp extends StatelessWidget {
ThemeData _customTheme(BuildContext context) {
return Theme.of(context).copyWith(
accentColor: kShrineBrown,
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

primaryIconTheme:
_customIconTheme(Theme.of(context).primaryIconTheme),
inputDecorationTheme:
InputDecorationTheme(border: NotchedCornerBorder()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new

Copy link
Collaborator Author

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.

buttonTheme: const ButtonThemeData(
textTheme: ButtonTextTheme.accent,
),
textTheme: _customTextTheme(Theme.of(context).textTheme),
Copy link
Collaborator

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);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return original.copyWith(color: kShrineBrown);
}

TextTheme _customTextTheme(TextTheme original) {
Copy link
Collaborator

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.

return original.copyWith(color: kShrineBrown900);
}

TextTheme _customTextTheme(TextTheme original) {
Copy link
Collaborator

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

),
],
),
body: new Center(
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! Removed.

import 'supplemental/theming.dart';

class ShrineApp extends StatelessWidget {
ThemeData _customTheme(BuildContext context) {
Copy link
Collaborator

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,
  ...
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

@HansMuller HansMuller left a 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

home: new HomePage(),
initialRoute: '/login',
onGenerateRoute: _getRoute,
theme: _buildShrineTheme(),
Copy link
Collaborator

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();

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.


import 'supplemental/asymmetric_grid.dart';

class HomePage extends StatefulWidget {
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@override
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: kShrineSurfaceWhite,
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return new Theme(
child: child,
data: Theme.of(context).copyWith(
primaryColor: color,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the indent

Copy link
Collaborator Author

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) {
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

),
],
),
body: new ListView(
Copy link
Collaborator

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())

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,29 @@
name: mdc_101_complete
description: >
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the > belong here?

Copy link
Collaborator Author

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;
Copy link
Collaborator

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?

Copy link
Collaborator Author

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) {
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants