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

Side by Side Diff: samples/third_party/pop-pop-win/lib/platform_target.dart

Issue 200723008: samples/poppopwin: upgrade to first-class sample (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixed pkgbuild.status for rename Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 library ppw_platform;
2
3 import 'dart:async';
4
5 abstract class PlatformTarget {
6 bool _initialized = false;
7
8 factory PlatformTarget() => new _DefaultPlatform();
9
10 PlatformTarget.base();
11
12 bool get initialized => _initialized;
13
14 void initialize() {
15 assert(!_initialized);
16 _initialized = true;
17 }
18
19 Future clearValues();
20
21 Future setValue(String key, String value);
22
23 Future<String> getValue(String key);
24
25 void trackAnalyticsEvent(String category, String action, [String label,
26 int value]) {
27 print('Analytics:: '
28 'category: $category; action: $action; label: $label; value: $value');
29 }
30
31 bool get renderBig;
32
33 bool get showAbout;
34
35 void toggleAbout([bool value]);
36
37 Stream get aboutChanged;
38 }
39
40 class _DefaultPlatform extends PlatformTarget {
41 final Map<String, String> _values = new Map<String, String>();
42 final StreamController _aboutController = new StreamController(sync: true);
43 bool _about = false;
44
45 _DefaultPlatform() : super.base();
46
47 @override
48 Future clearValues() => new Future(_values.clear);
49
50 @override
51 Future setValue(String key, String value) =>
52 new Future(() { _values[key] = value; });
53
54 @override
55 Future<String> getValue(String key) => new Future(() => _values[key]);
56
57 bool get renderBig => false;
58
59 void toggleAbout([bool value]) {
60 assert(_about != null);
61 if(value == null) {
62 value = !_about;
63 }
64 _about = value;
65 _aboutController.add(null);
66 }
67
68 bool get showAbout => _about;
69
70 Stream get aboutChanged => _aboutController.stream;
71 }
OLDNEW
« no previous file with comments | « samples/third_party/pop-pop-win/lib/html.dart ('k') | samples/third_party/pop-pop-win/lib/poppopwin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698