| 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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |