Merge pull request #1368 from abarth/fn3_address_book

Fn3 address book
This commit is contained in:
Adam Barth 2015-09-26 14:24:31 -07:00
commit 5773cf49cf
2 changed files with 30 additions and 53 deletions

View File

@ -3,9 +3,9 @@
// found in the LICENSE file.
import 'package:sky/material.dart';
import 'package:sky/widgets.dart';
import 'package:sky/src/fn3.dart';
class Field extends Component {
class Field extends StatelessComponent {
Field({
Key key,
this.inputKey,
@ -17,7 +17,7 @@ class Field extends Component {
final String icon;
final String placeholder;
Widget build() {
Widget build(BuildContext context) {
return new Row([
new Padding(
padding: const EdgeDims.symmetric(horizontal: 16.0),
@ -34,19 +34,22 @@ class Field extends Component {
}
}
class AddressBookApp extends App {
class AddressBookHome extends StatelessComponent {
AddressBookHome({ this.navigator });
Widget buildToolBar(Navigator navigator) {
final NavigatorState navigator;
Widget buildToolBar(BuildContext context) {
return new ToolBar(
left: new IconButton(icon: "navigation/arrow_back"),
right: [new IconButton(icon: "navigation/check")]
);
}
Widget buildFloatingActionButton(Navigator navigator) {
Widget buildFloatingActionButton(BuildContext context) {
return new FloatingActionButton(
child: new Icon(type: 'image/photo_camera', size: 24),
backgroundColor: Theme.of(this).accentColor
backgroundColor: Theme.of(context).accentColor
);
}
@ -59,7 +62,7 @@ class AddressBookApp extends App {
static final GlobalKey fillKey = new GlobalKey();
static final GlobalKey emoticonKey = new GlobalKey();
Widget buildBody(Navigator navigator) {
Widget buildBody(BuildContext context) {
return new Material(
child: new Block([
new AspectRatio(
@ -78,45 +81,27 @@ class AddressBookApp extends App {
);
}
Widget buildMain(Navigator navigator) {
Widget build(BuildContext context) {
return new Scaffold(
toolbar: buildToolBar(navigator),
body: buildBody(navigator),
floatingActionButton: buildFloatingActionButton(navigator)
);
}
NavigationState _navigationState;
void initState() {
_navigationState = new NavigationState([
new Route(
name: '/',
builder: (navigator, route) => buildMain(navigator)
),
]);
super.initState();
}
Widget build() {
ThemeData theme = new ThemeData(
brightness: ThemeBrightness.light,
primarySwatch: Colors.teal,
accentColor: Colors.pinkAccent[100]
);
return new Theme(
data: theme,
child: new DefaultTextStyle(
style: Typography.error, // if you see this, you've forgotten to correctly configure the text style!
child: new Title(
title: 'Address Book',
child: new Navigator(_navigationState)
)
)
toolbar: buildToolBar(context),
body: buildBody(context),
floatingActionButton: buildFloatingActionButton(context)
);
}
}
final ThemeData theme = new ThemeData(
brightness: ThemeBrightness.light,
primarySwatch: Colors.teal,
accentColor: Colors.pinkAccent[100]
);
void main() {
runApp(new AddressBookApp());
runApp(new App(
title: 'Address Book',
theme: theme,
routes: <String, RouteBuilder>{
'/': (NavigatorState navigator, Route route) => new AddressBookHome(navigator: navigator)
}
));
}

View File

@ -2,14 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:sky/widgets.dart';
import 'package:sky/src/fn3.dart';
class HelloWorldApp extends App {
Widget build() {
return new Center(child: new Text('Hello, world!'));
}
}
void main() {
runApp(new HelloWorldApp());
}
void main() => runApp(new Center(child: new Text('Hello, world!')));