OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 } |
OLD | NEW |