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:async'; |
| 6 |
| 7 import 'package:sky/widgets/basic.dart'; |
| 8 import 'package:sky/widgets/raised_button.dart'; |
| 9 |
| 10 import '../resources/display_list.dart'; |
| 11 |
| 12 class FiddleApp extends App { |
| 13 |
| 14 bool arbitrarySetting = true; |
| 15 |
| 16 void toggle() { |
| 17 setState(() { |
| 18 arbitrarySetting = !arbitrarySetting; |
| 19 }); |
| 20 } |
| 21 |
| 22 Widget buildFlex1() { |
| 23 return new Flex([ |
| 24 new Flexible(child: new Container( |
| 25 decoration: new BoxDecoration( |
| 26 backgroundColor: const Color(0xFF00FFFF) |
| 27 ) |
| 28 )), |
| 29 new RaisedButton(child: new Text('TAP ME TO CHANGE THE BACKGROUND COLOUR')
, onPressed: toggle) |
| 30 ]); |
| 31 } |
| 32 |
| 33 Widget buildFlex2() { |
| 34 return new Flex([ |
| 35 new Flexible(child: new Container( |
| 36 key: 'something-else', |
| 37 decoration: new BoxDecoration( |
| 38 backgroundColor: const Color(0xEFFF9F00) |
| 39 ) |
| 40 )), |
| 41 new RaisedButton(child: new Text('PRESS ME TO CHANGE IT BACK'), onPressed:
toggle) |
| 42 ]); |
| 43 } |
| 44 |
| 45 Widget buildStack1() { |
| 46 return new Stack([ |
| 47 new Positioned(child: new Container( |
| 48 decoration: new BoxDecoration( |
| 49 backgroundColor: const Color(0xFF00FFFF) |
| 50 ) |
| 51 )), |
| 52 new RaisedButton(child: new Text('TAP ME TO CHANGE THE BACKGROUND COLOUR')
, onPressed: toggle) |
| 53 ]); |
| 54 } |
| 55 |
| 56 Widget buildStack2() { |
| 57 return new Stack([ |
| 58 new Positioned(child: new Container( |
| 59 key: 'something-else', |
| 60 decoration: new BoxDecoration( |
| 61 backgroundColor: const Color(0xEFFF9F00) |
| 62 ) |
| 63 )), |
| 64 new RaisedButton(child: new Text('PRESS ME TO CHANGE IT BACK'), onPressed:
toggle) |
| 65 ]); |
| 66 } |
| 67 |
| 68 Widget build() { |
| 69 return new Block([ |
| 70 new SizedBox( |
| 71 key: 'flex-example', |
| 72 height: 250.0, |
| 73 child: arbitrarySetting ? buildFlex1() : buildFlex2() |
| 74 ), |
| 75 new SizedBox( |
| 76 key: 'stack-example', |
| 77 height: 250.0, |
| 78 child: arbitrarySetting ? buildStack1() : buildStack2() |
| 79 ) |
| 80 ]); |
| 81 } |
| 82 } |
| 83 |
| 84 main() { |
| 85 TestRenderView renderViewOverride = new TestRenderView(); |
| 86 FiddleApp app = new FiddleApp(); |
| 87 runApp(app, renderViewOverride: renderViewOverride); |
| 88 new Future.microtask(() { |
| 89 renderViewOverride.checkFrame(); |
| 90 app.toggle(); |
| 91 new Future.microtask(() { |
| 92 renderViewOverride.checkFrame(); |
| 93 app.toggle(); |
| 94 new Future.microtask(() { |
| 95 renderViewOverride.checkFrame(); |
| 96 renderViewOverride.endTest(); |
| 97 }); |
| 98 }); |
| 99 }); |
| 100 } |
OLD | NEW |