Skip to content

[101] Complete #2

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 17 commits into from
Apr 6, 2018
Merged
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
11 changes: 11 additions & 0 deletions MDC-101/complete/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.DS_Store
.atom/
.dart_tool/
.idea
.vscode/
.packages
.pub/
build/
ios/.generated/
packages
.flutter-plugins
8 changes: 8 additions & 0 deletions MDC-101/complete/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 5a58b36e36b8d7aace89d3950e6deb307956a6a0
channel: beta
Binary file added MDC-101/complete/assets/2.0x/diamond.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MDC-101/complete/assets/3.0x/diamond.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MDC-101/complete/assets/diamond.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions MDC-101/complete/lib/app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'home.dart';
import 'login.dart';

import 'package:flutter/material.dart';

class ShrineApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Shrine',
home: HomePage(),
initialRoute: '/login',
onGenerateRoute: _getRoute,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another comment that's more a question:

Is there a definite benefit to using onGenerateRoute here rather than supplying a map via the routes property? It may just be the examples I happen to be looking at right now, but that seems like a popular option:

https://github.com/brianegan/flutter_architecture_samples/blob/master/example/scoped_model/lib/app.dart

I don't know that you can set the fullScreenDialog option that way, though, which may be a dealbreaker.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1, I was not even aware of onGenerateRoute until now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's all new to me! Need me to change it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, actually, I used to have the routes map. But I couldn't get the pop to be a modal-style dismiss.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed offline, and this is definitely the better way to go. I'm now curious what other functionality you lose (if any) by using a straight up route table.

);
}

Route<dynamic> _getRoute(RouteSettings settings) {
if (settings.name != '/login') {
return null;
}

return MaterialPageRoute<void>(
settings: settings,
builder: (BuildContext context) => LoginPage(),
fullscreenDialog: true,
);
}
}
15 changes: 15 additions & 0 deletions MDC-101/complete/lib/home.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SHRINE'),
),
body: Center(
child: Text('You did it!'),
),
);
}
}
53 changes: 53 additions & 0 deletions MDC-101/complete/lib/login.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';

class LoginPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 24.0),
children: <Widget>[
SizedBox(height: 80.0),
Column(
children: <Widget>[
Image.asset('assets/diamond.png'),
SizedBox(height: 16.0),
Text('SHRINE'),
],
),
SizedBox(height: 120.0),
TextField(
decoration: InputDecoration(
filled: true,
labelText: 'Username',
),
),
SizedBox(height: 12.0),
TextField(
decoration: InputDecoration(
filled: true,
labelText: 'Password',
),
obscureText: true,
),
ButtonBar(
children: <Widget>[
FlatButton(
child: Text('CANCEL'),
onPressed: null,
),
RaisedButton(
child: Text('NEXT'),
onPressed: () {
Navigator.pop(context);
},
)
],
)
],
),
)
);
}
}
5 changes: 5 additions & 0 deletions MDC-101/complete/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:flutter/material.dart';

import 'app.dart';

void main() => runApp(ShrineApp());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just FYI: optional new/const might not make it for I/O. That's a worst case scenario, but after the recent snafu, it's a lot more probable than before.

19 changes: 19 additions & 0 deletions MDC-101/complete/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: mdc_101_complete
description: >
Learn the basics of using Material Components by building a simple app with core components.

dependencies:
flutter:
sdk: flutter

cupertino_icons: ^0.1.0

dev_dependencies:
flutter_test:
sdk: flutter


flutter:
uses-material-design: true
assets:
- assets/diamond.png