| 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 '../fn2.dart'; | 5 import '../fn2.dart'; |
| 6 import '../rendering/box.dart'; | 6 import '../rendering/box.dart'; |
| 7 import '../rendering/object.dart'; | 7 import '../rendering/object.dart'; |
| 8 | 8 |
| 9 enum ScaffoldSlots { | 9 enum ScaffoldSlots { |
| 10 toolbar, | 10 toolbar, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 | 152 |
| 153 class Scaffold extends RenderObjectWrapper { | 153 class Scaffold extends RenderObjectWrapper { |
| 154 | 154 |
| 155 // static final Style _style = new Style(''' | 155 // static final Style _style = new Style(''' |
| 156 // ${typography.typeface}; | 156 // ${typography.typeface}; |
| 157 // ${typography.black.body1};'''); | 157 // ${typography.black.body1};'''); |
| 158 | 158 |
| 159 Scaffold({ | 159 Scaffold({ |
| 160 Object key, | 160 Object key, |
| 161 this.toolbar, | 161 UINode toolbar, |
| 162 this.body, | 162 UINode body, |
| 163 this.statusbar, | 163 UINode statusbar, |
| 164 this.drawer, | 164 UINode drawer, |
| 165 this.floatingActionButton | 165 UINode floatingActionButton |
| 166 }) : super( | 166 }) : _toolbar = toolbar, |
| 167 key: key | 167 _body = body, |
| 168 ); | 168 _statusbar = statusbar, |
| 169 _drawer = drawer, |
| 170 _floatingActionButton = floatingActionButton, |
| 171 super(key: key); |
| 169 | 172 |
| 170 final UINode toolbar; | 173 UINode _toolbar; |
| 171 final UINode body; | 174 UINode _body; |
| 172 final UINode statusbar; | 175 UINode _statusbar; |
| 173 final UINode drawer; | 176 UINode _drawer; |
| 174 final UINode floatingActionButton; | 177 UINode _floatingActionButton; |
| 175 | 178 |
| 176 RenderScaffold root; | 179 RenderScaffold root; |
| 177 RenderScaffold createNode() => new RenderScaffold(); | 180 RenderScaffold createNode() => new RenderScaffold(); |
| 178 | 181 |
| 179 void insert(RenderObjectWrapper child, ScaffoldSlots slot) { | 182 void insert(RenderObjectWrapper child, ScaffoldSlots slot) { |
| 180 root[slot] = child != null ? child.root : null; | 183 root[slot] = child != null ? child.root : null; |
| 181 } | 184 } |
| 182 | 185 |
| 183 void removeChild(UINode node) { | 186 void removeChild(UINode node) { |
| 184 assert(node != null); | 187 assert(node != null); |
| 185 root.remove(node.root); | 188 root.remove(node.root); |
| 186 super.removeChild(node); | 189 super.removeChild(node); |
| 187 } | 190 } |
| 188 | 191 |
| 189 void remove() { | 192 void remove() { |
| 190 if (toolbar != null) | 193 if (_toolbar != null) |
| 191 removeChild(toolbar); | 194 removeChild(_toolbar); |
| 192 if (body != null) | 195 if (_body != null) |
| 193 removeChild(body); | 196 removeChild(_body); |
| 194 if (statusbar != null) | 197 if (_statusbar != null) |
| 195 removeChild(statusbar); | 198 removeChild(_statusbar); |
| 196 if (drawer != null) | 199 if (_drawer != null) |
| 197 removeChild(drawer); | 200 removeChild(_drawer); |
| 198 if (floatingActionButton != null) | 201 if (_floatingActionButton != null) |
| 199 removeChild(floatingActionButton); | 202 removeChild(_floatingActionButton); |
| 200 super.remove(); | 203 super.remove(); |
| 201 } | 204 } |
| 202 | 205 |
| 203 void syncRenderObject(UINode old) { | 206 void syncRenderObject(UINode old) { |
| 204 super.syncRenderObject(old); | 207 super.syncRenderObject(old); |
| 205 syncChild(toolbar, old is Scaffold ? old.toolbar : null, ScaffoldSlots.toolb
ar); | 208 _toolbar = syncChild(_toolbar, old is Scaffold ? old._toolbar : null, Scaffo
ldSlots.toolbar); |
| 206 syncChild(body, old is Scaffold ? old.body : null, ScaffoldSlots.body); | 209 _body = syncChild(_body, old is Scaffold ? old._body : null, ScaffoldSlots.b
ody); |
| 207 syncChild(statusbar, old is Scaffold ? old.statusbar : null, ScaffoldSlots.s
tatusBar); | 210 _statusbar = syncChild(_statusbar, old is Scaffold ? old._statusbar : null,
ScaffoldSlots.statusBar); |
| 208 syncChild(drawer, old is Scaffold ? old.drawer : null, ScaffoldSlots.drawer)
; | 211 _drawer = syncChild(_drawer, old is Scaffold ? old._drawer : null, ScaffoldS
lots.drawer); |
| 209 syncChild(floatingActionButton, old is Scaffold ? old.floatingActionButton :
null, ScaffoldSlots.floatingActionButton); | 212 _floatingActionButton = syncChild(_floatingActionButton, old is Scaffold ? o
ld._floatingActionButton : null, ScaffoldSlots.floatingActionButton); |
| 210 } | 213 } |
| 211 | 214 |
| 212 } | 215 } |
| OLD | NEW |