Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: sky/sdk/example/address_book/lib/main.dart

Issue 1227093010: Add an AspectRatio widget for doing proportional height sizing (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sky/sdk/lib/rendering/box.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'package:sky/theme/colors.dart' as colors; 5 import 'package:sky/theme/colors.dart' as colors;
6 import 'package:sky/theme/typography.dart' as typography; 6 import 'package:sky/theme/typography.dart' as typography;
7 import 'package:sky/widgets/basic.dart'; 7 import 'package:sky/widgets/basic.dart';
8 import 'package:sky/widgets/default_text_style.dart'; 8 import 'package:sky/widgets/default_text_style.dart';
9 import 'package:sky/widgets/theme.dart'; 9 import 'package:sky/widgets/theme.dart';
10 import 'package:sky/widgets/widget.dart'; 10 import 'package:sky/widgets/widget.dart';
11 import 'package:sky/widgets/task_description.dart'; 11 import 'package:sky/widgets/task_description.dart';
12 import 'package:sky/widgets/scaffold.dart'; 12 import 'package:sky/widgets/scaffold.dart';
13 import 'package:sky/widgets/tool_bar.dart'; 13 import 'package:sky/widgets/tool_bar.dart';
14 import 'package:sky/widgets/icon_button.dart'; 14 import 'package:sky/widgets/icon_button.dart';
15 import 'package:sky/widgets/floating_action_button.dart'; 15 import 'package:sky/widgets/floating_action_button.dart';
16 import 'package:sky/widgets/icon.dart'; 16 import 'package:sky/widgets/icon.dart';
17 import 'package:sky/widgets/material.dart'; 17 import 'package:sky/widgets/material.dart';
18 import 'package:sky/editing/input.dart'; 18 import 'package:sky/editing/input.dart';
19 import 'package:sky/widgets/scrollable_viewport.dart';
19 20
20 class Field extends Container { 21 class Field extends Component {
21 Field({this.icon: null, this.placeholder: null}); 22 Field({this.icon: null, this.placeholder: null});
22 23
23 String icon; 24 String icon;
24 String placeholder; 25 String placeholder;
25 26
26 Widget build() { 27 Widget build() {
27 return new Flex([ 28 return new Flex([
28 new Padding( 29 new Padding(
29 padding: const EdgeDims.symmetric(horizontal: 16.0), 30 padding: const EdgeDims.symmetric(horizontal: 16.0),
30 child: new Icon(type:icon, size:24) 31 child: new Icon(type:icon, size:24)
31 ), 32 ),
32 new Flexible(child:new Input(placeholder:placeholder)) 33 new Flexible(child:new Input(placeholder:placeholder, focused:false))
33 ], 34 ],
34 direction: FlexDirection.horizontal 35 direction: FlexDirection.horizontal
35 ); 36 );
36 } 37 }
37 } 38 }
38 39
39
40 class AddressBookApp extends App { 40 class AddressBookApp extends App {
41 41
42 Widget buildToolBar() { 42 Widget buildToolBar() {
43 return new ToolBar( 43 return new ToolBar(
44 left: new IconButton(icon: "navigation/arrow_back"), 44 left: new IconButton(icon: "navigation/arrow_back"),
45 right: [new IconButton(icon: "navigation/check")] 45 right: [new IconButton(icon: "navigation/check")]
46 ); 46 );
47 } 47 }
48 48
49 Widget buildFloatingActionButton() { 49 Widget buildFloatingActionButton() {
50 return new FloatingActionButton( 50 return new FloatingActionButton(
51 child: new Icon(type: 'image/photo_camera', size: 24), 51 child: new Icon(type: 'image/photo_camera', size: 24),
52 backgroundColor: Theme.of(this).accentColor 52 backgroundColor: Theme.of(this).accentColor
53 ); 53 );
54 } 54 }
55 55
56 Widget buildBody() { 56 Widget buildBody() {
57 return new Material( 57 return new Material(
58 child:new Block([ 58 child: new ScrollableBlock([
59 new AspectRatio(
60 aspectRatio: 16 / 9,
abarth-chromium 2015/07/14 20:17:02 Does this need to be 16.0 / 9.0 to get floating po
Cutch 2015/07/14 20:33:44 16 / 9 will be a floating point division on two in
61 child: new Container(
62 decoration: new BoxDecoration(backgroundColor: colors.Purple[300])
63 )
64 ),
59 new Field(icon:"social/person", placeholder:"Name"), 65 new Field(icon:"social/person", placeholder:"Name"),
60 new Field(icon: "communication/phone", placeholder:"Phone"), 66 new Field(icon: "communication/phone", placeholder:"Phone"),
61 new Field(icon: "communication/email", placeholder:"Email"), 67 new Field(icon: "communication/email", placeholder:"Email"),
62 new Field(icon: "maps/place", placeholder:"Address"), 68 new Field(icon: "maps/place", placeholder:"Address"),
63 new Field(icon: "av/volume_up", placeholder:"Ringtone"), 69 new Field(icon: "av/volume_up", placeholder:"Ringtone"),
64 new Field(icon: "content/add", placeholder:"Add note"), 70 new Field(icon: "content/add", placeholder:"Add note"),
65 ]) 71 ])
66 ); 72 );
67 } 73 }
68 74
(...skipping 22 matching lines...) Expand all
91 child: buildMain() 97 child: buildMain()
92 ) 98 )
93 ) 99 )
94 ); 100 );
95 } 101 }
96 } 102 }
97 103
98 void main() { 104 void main() {
99 runApp(new AddressBookApp()); 105 runApp(new AddressBookApp());
100 } 106 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/rendering/box.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698