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

Side by Side Diff: sky/sdk/example/rendering/interactive_flex.dart

Issue 1214073014: Back button should kill interactive flex app (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase and add missing file 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
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 'dart:sky'; 5 import 'dart:sky';
6 import 'dart:math' as math; 6 import 'dart:math' as math;
7 7
8 import 'package:sky/mojo/activity.dart' as activity;
8 import 'package:sky/mojo/net/image_cache.dart' as image_cache; 9 import 'package:sky/mojo/net/image_cache.dart' as image_cache;
9 import 'package:sky/painting/text_style.dart'; 10 import 'package:sky/painting/text_style.dart';
10 import 'package:sky/rendering/box.dart'; 11 import 'package:sky/rendering/box.dart';
11 import 'package:sky/rendering/flex.dart'; 12 import 'package:sky/rendering/flex.dart';
12 import 'package:sky/rendering/object.dart'; 13 import 'package:sky/rendering/object.dart';
13 import 'package:sky/rendering/paragraph.dart'; 14 import 'package:sky/rendering/paragraph.dart';
14 import 'package:sky/rendering/sky_binding.dart'; 15 import 'package:sky/rendering/sky_binding.dart';
15 16
16 import 'solid_color_box.dart'; 17 import 'solid_color_box.dart';
17 18
(...skipping 20 matching lines...) Expand all
38 39
39 RenderImageGrow image; 40 RenderImageGrow image;
40 41
41 Map<int, Touch> touches = new Map(); 42 Map<int, Touch> touches = new Map();
42 void handleEvent(event) { 43 void handleEvent(event) {
43 if (event is PointerEvent) { 44 if (event is PointerEvent) {
44 if (event.type == 'pointermove') 45 if (event.type == 'pointermove')
45 image.growth = math.max(0.0, image.growth + event.x - touches[event.pointe r].x); 46 image.growth = math.max(0.0, image.growth + event.x - touches[event.pointe r].x);
46 touches[event.pointer] = new Touch(event.x, event.y); 47 touches[event.pointer] = new Touch(event.x, event.y);
47 } 48 }
49 if (event.type == "back") {
50 activity.finishCurrentActivity();
51 }
48 } 52 }
49 53
50 void main() { 54 void main() {
51 void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int fl ex: 0 }) { 55 void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int fl ex: 0 }) {
52 RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor); 56 RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor);
53 parent.add(child); 57 parent.add(child);
54 child.parentData.flex = flex; 58 child.parentData.flex = flex;
55 } 59 }
56 60
57 var row = new RenderFlex(direction: FlexDirection.horizontal); 61 var row = new RenderFlex(direction: FlexDirection.horizontal);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 column.parentData.flex = 8; 98 column.parentData.flex = 8;
95 99
96 RenderDecoratedBox root = new RenderDecoratedBox( 100 RenderDecoratedBox root = new RenderDecoratedBox(
97 decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)), 101 decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)),
98 child: row 102 child: row
99 ); 103 );
100 104
101 new SkyBinding(root: root); 105 new SkyBinding(root: root);
102 view.setEventCallback(handleEvent); 106 view.setEventCallback(handleEvent);
103 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698