| OLD | NEW |
| 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 'dart:sky' as sky; | |
| 6 | |
| 7 import 'package:sky/framework/rendering/box.dart'; | 5 import 'package:sky/framework/rendering/box.dart'; |
| 8 import 'package:sky/framework/rendering/flex.dart'; | 6 import 'package:sky/framework/rendering/flex.dart'; |
| 9 import 'package:sky/framework/widgets/ui_node.dart'; | 7 import 'package:sky/framework/widgets/raised_button.dart'; |
| 10 import 'package:sky/framework/widgets/wrappers.dart'; | 8 import 'package:sky/framework/widgets/wrappers.dart'; |
| 11 | 9 |
| 12 class Rectangle extends Component { | |
| 13 | |
| 14 Rectangle(this.color, { Object key }) : super(key: key); | |
| 15 | |
| 16 final Color color; | |
| 17 | |
| 18 UINode build() { | |
| 19 return new FlexExpandingChild( | |
| 20 new Container( | |
| 21 decoration: new BoxDecoration(backgroundColor: color) | |
| 22 ) | |
| 23 ); | |
| 24 } | |
| 25 | |
| 26 } | |
| 27 | |
| 28 class ContainerApp extends App { | 10 class ContainerApp extends App { |
| 29 UINode build() { | 11 UINode build() { |
| 30 return new Flex([ | 12 return new Flex([ |
| 31 new Rectangle(const Color(0xFF00FFFF), key: 'a'), | |
| 32 new Container( | 13 new Container( |
| 14 key: 'a', |
| 33 padding: new EdgeDims.all(10.0), | 15 padding: new EdgeDims.all(10.0), |
| 34 margin: new EdgeDims.all(10.0), | 16 margin: new EdgeDims.all(10.0), |
| 35 decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)
), | 17 decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)
), |
| 36 child: new Image(src: "https://www.dartlang.org/logos/dart-logo.png", | 18 child: new Image( |
| 37 size: new Size(300.0, 300.0), | 19 src: "https://www.dartlang.org/logos/dart-logo.png", |
| 38 key: 1 | 20 size: new Size(300.0, 300.0) |
| 39 ) | 21 ) |
| 40 ), | 22 ), |
| 41 new Rectangle(const Color(0xFFFFFF00), key: 'b'), | 23 new Container( |
| 24 key: 'b', |
| 25 decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFF00)
), |
| 26 padding: new EdgeDims.symmetric(horizontal: 50.0, vertical: 75.0), |
| 27 child: new RaisedButton( |
| 28 child: new Text('PRESS ME'), |
| 29 onPressed: () => print("Hello World") |
| 30 ) |
| 31 ), |
| 32 new FlexExpandingChild( |
| 33 new Container( |
| 34 decoration: new BoxDecoration(backgroundColor: const Color(0xFF00FFF
F)) |
| 35 ) |
| 36 ), |
| 42 ], | 37 ], |
| 43 direction: FlexDirection.vertical, | 38 direction: FlexDirection.vertical, |
| 44 justifyContent: FlexJustifyContent.spaceBetween | 39 justifyContent: FlexJustifyContent.spaceBetween |
| 45 ); | 40 ); |
| 46 } | 41 } |
| 47 } | 42 } |
| 48 | 43 |
| 49 void main() { | 44 void main() { |
| 50 new ContainerApp(); | 45 new ContainerApp(); |
| 51 } | 46 } |
| OLD | NEW |