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

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

Issue 1217093005: Refactor stateful parts of Component into StatefulComponent (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase Created 5 years, 5 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/button_base.dart ('k') | sky/sdk/lib/widgets/scrollable.dart » ('j') | 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 'basic.dart'; 5 import 'basic.dart';
6 6
7 typedef Widget Builder(Navigator navigator, RouteBase route); 7 typedef Widget Builder(Navigator navigator, RouteBase route);
8 8
9 abstract class RouteBase { 9 abstract class RouteBase {
10 RouteBase({ this.name }); 10 RouteBase({ this.name });
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 void pop() { 68 void pop() {
69 if (historyIndex > 0) { 69 if (historyIndex > 0) {
70 history[historyIndex].popState(); 70 history[historyIndex].popState();
71 history.removeLast(); 71 history.removeLast();
72 historyIndex--; 72 historyIndex--;
73 } 73 }
74 } 74 }
75 } 75 }
76 76
77 class Navigator extends Component { 77 class Navigator extends StatefulComponent {
78 78
79 Navigator(this.state, { String key }) : super(key: key, stateful: true); 79 Navigator(this.state, { String key }) : super(key: key);
80 80
81 NavigationState state; 81 NavigationState state;
82 82
83 void syncFields(Navigator source) { 83 void syncFields(Navigator source) {
84 state = source.state; 84 state = source.state;
85 } 85 }
86 86
87 RouteBase get currentRoute => state.currentRoute; 87 RouteBase get currentRoute => state.currentRoute;
88 88
89 void pushState(String name, Function callback) { 89 void pushState(String name, Function callback) {
(...skipping 20 matching lines...) Expand all
110 void pop() { 110 void pop() {
111 setState(() { 111 setState(() {
112 state.pop(); 112 state.pop();
113 }); 113 });
114 } 114 }
115 115
116 Widget build() { 116 Widget build() {
117 return state.currentRoute.build(this, state.currentRoute); 117 return state.currentRoute.build(this, state.currentRoute);
118 } 118 }
119 } 119 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/button_base.dart ('k') | sky/sdk/lib/widgets/scrollable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698