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

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

Issue 1195493002: Refactor Navigator to put state in separate class, initial back button plumbing (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: abarth CR feedback 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
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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 abstract class App extends AbstractWidgetRoot { 792 abstract class App extends AbstractWidgetRoot {
793 793
794 App({ RenderView renderViewOverride }) : super(renderViewOverride: renderViewO verride); 794 App({ RenderView renderViewOverride }) : super(renderViewOverride: renderViewO verride);
795 795
796 void _buildIfDirty() { 796 void _buildIfDirty() {
797 super._buildIfDirty(); 797 super._buildIfDirty();
798 798
799 if (root.parent == null) { 799 if (root.parent == null) {
800 // we haven't attached it yet 800 // we haven't attached it yet
801 WidgetAppView._appView.root = root; 801 WidgetAppView._appView.root = root;
802 WidgetAppView._appView.eventListeners.add((event) {
Hixie 2015/06/17 19:29:43 This shouldn't use the underbar version. If there'
803 if (event.type == "back")
804 onBack();
805 });
802 } 806 }
803 assert(root.parent is RenderView); 807 assert(root.parent is RenderView);
804 } 808 }
805 809
810 // Override this to handle back button behavior in your app
811 void onBack() { }
812
806 } 813 }
807 814
808 typedef Widget Builder(); 815 typedef Widget Builder();
809 816
810 class RenderBoxToWidgetAdapter extends AbstractWidgetRoot { 817 class RenderBoxToWidgetAdapter extends AbstractWidgetRoot {
811 818
812 RenderBoxToWidgetAdapter( 819 RenderBoxToWidgetAdapter(
813 RenderObjectWithChildMixin<RenderBox> container, 820 RenderObjectWithChildMixin<RenderBox> container,
814 this.builder 821 this.builder
815 ) : _container = container, super() { 822 ) : _container = container, super() {
(...skipping 24 matching lines...) Expand all
840 if (root.parent == null) { 847 if (root.parent == null) {
841 // we haven't attached it yet 848 // we haven't attached it yet
842 assert(_container.child == null); 849 assert(_container.child == null);
843 _container.child = root; 850 _container.child = root;
844 } 851 }
845 assert(root.parent == _container); 852 assert(root.parent == _container);
846 } 853 }
847 854
848 Widget build() => builder(); 855 Widget build() => builder();
849 } 856 }
OLDNEW
« sky/sdk/lib/app/view.dart ('K') | « sky/sdk/lib/widgets/navigator.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698