| 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; | 5 import 'dart:sky' as sky; |
| 6 | 6 |
| 7 import 'package:sky/framework/rendering/box.dart'; | 7 import 'package:sky/framework/rendering/box.dart'; |
| 8 import 'package:sky/framework/rendering/flex.dart'; |
| 8 import 'package:sky/framework/widgets/ui_node.dart'; | 9 import 'package:sky/framework/widgets/ui_node.dart'; |
| 9 import 'package:sky/framework/widgets/wrappers.dart'; | 10 import 'package:sky/framework/widgets/wrappers.dart'; |
| 10 | 11 |
| 11 import '../lib/solid_color_box.dart'; | 12 class Rectangle extends Component { |
| 12 | |
| 13 class Rectangle extends RenderObjectWrapper { | |
| 14 RenderSolidColorBox root; | |
| 15 RenderSolidColorBox createNode() => | |
| 16 new RenderSolidColorBox(color, desiredSize: new sky.Size(40.0, 130.0)); | |
| 17 | |
| 18 final int color; | |
| 19 | 13 |
| 20 Rectangle(this.color, { Object key }) : super(key: key); | 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 |
| 21 } | 26 } |
| 22 | 27 |
| 23 class ContainerApp extends App { | 28 class ContainerApp extends App { |
| 24 UINode build() { | 29 UINode build() { |
| 25 return new EventListenerNode( | 30 return new Flex([ |
| 26 new Block([ | 31 new Rectangle(const Color(0xFF00FFFF), key: 'a'), |
| 27 new Container( | 32 new Container( |
| 28 padding: new EdgeDims.all(10.0), | 33 padding: new EdgeDims.all(10.0), |
| 29 margin: new EdgeDims.all(10.0), | 34 margin: new EdgeDims.all(10.0), |
| 30 height: 100.0, | 35 decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)
), |
| 31 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF00F
F00)), | 36 child: new Image(src: "https://www.dartlang.org/logos/dart-logo.png", |
| 32 child: new Block([ | 37 size: new Size(300.0, 300.0), |
| 33 new Container( | 38 key: 1 |
| 34 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xF
FFFFF00)), | 39 ) |
| 35 height: 20.0 | 40 ), |
| 36 ), | 41 new Rectangle(const Color(0xFFFFFF00), key: 'b'), |
| 37 new Image(src: "https://www.dartlang.org/logos/dart-logo.png", | 42 ], |
| 38 size: new sky.Size(300.0, 300.0), | 43 direction: FlexDirection.vertical, |
| 39 key: 1 | 44 justifyContent: FlexJustifyContent.spaceBetween |
| 40 ), | 45 ); |
| 41 ])), | |
| 42 ]), | |
| 43 onPointerDown: _handlePointerDown, | |
| 44 onGestureTap: _handleGestureTap); | |
| 45 } | |
| 46 | |
| 47 void _handlePointerDown(sky.PointerEvent event) { | |
| 48 print("_handlePointerDown"); | |
| 49 } | |
| 50 | |
| 51 void _handleGestureTap(sky.GestureEvent event) { | |
| 52 print("_handleGestureTap"); | |
| 53 } | 46 } |
| 54 } | 47 } |
| 55 | 48 |
| 56 void main() { | 49 void main() { |
| 57 new ContainerApp(); | 50 new ContainerApp(); |
| 58 } | 51 } |
| OLD | NEW |