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

Side by Side Diff: sky/sdk/lib/widgets/widget.dart

Issue 1182463007: Re-wire up the back button (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 | « sky/sdk/lib/widgets/navigator.dart ('k') | 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:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 import 'dart:sky' as sky; 8 import 'dart:sky' as sky;
9 9
10 import '../app/view.dart'; 10 import '../app/view.dart';
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 if (target is Listener) 764 if (target is Listener)
765 target._handleEvent(event); 765 target._handleEvent(event);
766 target = target._parent; 766 target = target._parent;
767 } 767 }
768 } 768 }
769 } 769 }
770 770
771 } 771 }
772 772
773 abstract class App extends Component { 773 abstract class App extends Component {
774 void _handleEvent(sky.Event event) {
775 if (event.type == 'back')
776 onBack();
777 }
778
779 void didMount() {
780 super.didMount();
781 WidgetAppView.appView.addEventListener(_handleEvent);
782 }
783
784 void didUnmount() {
785 super.didUnmount();
786 WidgetAppView.appView.removeEventListener(_handleEvent);
787 }
788
774 // Override this to handle back button behavior in your app 789 // Override this to handle back button behavior in your app
775 void onBack() { } 790 void onBack() { }
776 } 791 }
777 792
778 abstract class AbstractWidgetRoot extends Component { 793 abstract class AbstractWidgetRoot extends Component {
779 794
780 AbstractWidgetRoot() : super(stateful: true) { 795 AbstractWidgetRoot() : super(stateful: true) {
781 _mounted = true; 796 _mounted = true;
782 _scheduleComponentForRender(this); 797 _scheduleComponentForRender(this);
783 } 798 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 if (root.parent == null) { 866 if (root.parent == null) {
852 // we haven't attached it yet 867 // we haven't attached it yet
853 assert(_container.child == null); 868 assert(_container.child == null);
854 _container.child = root; 869 _container.child = root;
855 } 870 }
856 assert(root.parent == _container); 871 assert(root.parent == _container);
857 } 872 }
858 873
859 Widget build() => builder(); 874 Widget build() => builder();
860 } 875 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/navigator.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698