| OLD | NEW | 
|---|
|  | (Empty) | 
| 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 |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 import 'dart:sky'; |  | 
| 6 import 'package:sky/framework/app.dart'; |  | 
| 7 import 'package:sky/framework/layout2.dart'; |  | 
| 8 |  | 
| 9 class RenderSolidColor extends RenderDecoratedBox { |  | 
| 10   final Size desiredSize; |  | 
| 11   final int backgroundColor; |  | 
| 12 |  | 
| 13   RenderSolidColor(int backgroundColor, { this.desiredSize: const sky.Size.infin
    ite() }) |  | 
| 14       : backgroundColor = backgroundColor, |  | 
| 15         super(new BoxDecoration(backgroundColor: backgroundColor)) { |  | 
| 16   } |  | 
| 17 |  | 
| 18   BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { |  | 
| 19     return new BoxDimensions.withConstraints(constraints, |  | 
| 20                                              width: desiredSize.width, |  | 
| 21                                              height: desiredSize.height); |  | 
| 22   } |  | 
| 23 |  | 
| 24   void performLayout() { |  | 
| 25     size = constraints.constrain(desiredSize); |  | 
| 26   } |  | 
| 27 |  | 
| 28   void handlePointer(PointerEvent event) { |  | 
| 29     if (event.type == 'pointerdown') |  | 
| 30       decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); |  | 
| 31     else if (event.type == 'pointerup') |  | 
| 32       decoration = new BoxDecoration(backgroundColor: backgroundColor); |  | 
| 33   } |  | 
| 34 } |  | 
| 35 |  | 
| 36 AppView app; |  | 
| 37 |  | 
| 38 void main() { |  | 
| 39   var root = new RenderFlex( |  | 
| 40       direction: FlexDirection.Vertical, |  | 
| 41       decoration: new BoxDecoration(backgroundColor: 0xFF000000)); |  | 
| 42 |  | 
| 43   void addFlexChild(RenderFlex parent, int backgroundColor, { int flex: 0 }) { |  | 
| 44     RenderNode child = new RenderSolidColor(backgroundColor); |  | 
| 45     parent.add(child); |  | 
| 46     child.parentData.flex = flex; |  | 
| 47   } |  | 
| 48 |  | 
| 49   // Yellow bar at top |  | 
| 50   addFlexChild(root, 0xFFFFFF00, flex: 1); |  | 
| 51 |  | 
| 52   // Turquoise box |  | 
| 53   root.add(new RenderSolidColor(0x7700FFFF, desiredSize: new Size(100.0, 100.0))
    ); |  | 
| 54 |  | 
| 55   // Green and cyan render block with padding |  | 
| 56   var renderBlock = new RenderBlock(decoration: new BoxDecoration(backgroundColo
    r: 0xFFFFFFFF)); |  | 
| 57 |  | 
| 58   renderBlock.add(new RenderSolidColor(0xFF00FF00, desiredSize: new Size(100.0, 
    50.0))); |  | 
| 59   renderBlock.add(new RenderSolidColor(0x7700FFFF, desiredSize: new Size(50.0, 1
    00.0))); |  | 
| 60 |  | 
| 61   root.add(new RenderPadding(const EdgeDims(10.0, 10.0, 10.0, 10.0), renderBlock
    )); |  | 
| 62 |  | 
| 63   var row = new RenderFlex( |  | 
| 64     direction: FlexDirection.Horizontal, |  | 
| 65     decoration: new BoxDecoration(backgroundColor: 0xFF333333)); |  | 
| 66 |  | 
| 67   // Purple and blue cells |  | 
| 68   addFlexChild(row, 0x77FF00FF, flex: 1); |  | 
| 69   addFlexChild(row, 0xFF0000FF, flex: 2); |  | 
| 70 |  | 
| 71   root.add(row); |  | 
| 72   row.parentData.flex = 3; |  | 
| 73 |  | 
| 74   app = new AppView(root); |  | 
| 75 |  | 
| 76 } |  | 
| OLD | NEW | 
|---|