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

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: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:mojom/intents/intents.mojom.dart';
8 import 'package:sky/mojo/net/image_cache.dart' as image_cache; 9 import 'package:sky/mojo/net/image_cache.dart' as image_cache;
10 import 'package:sky/mojo/shell.dart' as shell;
9 import 'package:sky/painting/text_style.dart'; 11 import 'package:sky/painting/text_style.dart';
10 import 'package:sky/rendering/box.dart'; 12 import 'package:sky/rendering/box.dart';
11 import 'package:sky/rendering/flex.dart'; 13 import 'package:sky/rendering/flex.dart';
12 import 'package:sky/rendering/object.dart'; 14 import 'package:sky/rendering/object.dart';
13 import 'package:sky/rendering/paragraph.dart'; 15 import 'package:sky/rendering/paragraph.dart';
14 import 'package:sky/rendering/sky_binding.dart'; 16 import 'package:sky/rendering/sky_binding.dart';
15 17
16 import 'solid_color_box.dart'; 18 import 'solid_color_box.dart';
17 19
18 class Touch { 20 class Touch {
(...skipping 19 matching lines...) Expand all
38 40
39 RenderImageGrow image; 41 RenderImageGrow image;
40 42
41 Map<int, Touch> touches = new Map(); 43 Map<int, Touch> touches = new Map();
42 void handleEvent(event) { 44 void handleEvent(event) {
43 if (event is PointerEvent) { 45 if (event is PointerEvent) {
44 if (event.type == 'pointermove') 46 if (event.type == 'pointermove')
45 image.growth = math.max(0.0, image.growth + event.x - touches[event.pointe r].x); 47 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); 48 touches[event.pointer] = new Touch(event.x, event.y);
47 } 49 }
50 if (event.type == "back") {
51 ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound();
52 shell.requestService('mojo:sky_viewer', activityManager);
53 activityManager.ptr.finishCurrentActivity();
54 }
abarth-chromium 2015/07/07 18:10:26 Should we factor this into a library since we have
jackson 2015/07/07 19:17:30 Done.
48 } 55 }
49 56
50 void main() { 57 void main() {
51 void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int fl ex: 0 }) { 58 void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int fl ex: 0 }) {
52 RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor); 59 RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor);
53 parent.add(child); 60 parent.add(child);
54 child.parentData.flex = flex; 61 child.parentData.flex = flex;
55 } 62 }
56 63
57 var row = new RenderFlex(direction: FlexDirection.horizontal); 64 var row = new RenderFlex(direction: FlexDirection.horizontal);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 column.parentData.flex = 8; 101 column.parentData.flex = 8;
95 102
96 RenderDecoratedBox root = new RenderDecoratedBox( 103 RenderDecoratedBox root = new RenderDecoratedBox(
97 decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)), 104 decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)),
98 child: row 105 child: row
99 ); 106 );
100 107
101 new SkyBinding(root: root); 108 new SkyBinding(root: root);
102 view.setEventCallback(handleEvent); 109 view.setEventCallback(handleEvent);
103 } 110 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698