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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 static const kButtonX = -16.0; // from right edge of body | 83 static const kButtonX = -16.0; // from right edge of body |
84 static const kButtonY = -16.0; // from bottom edge of body | 84 static const kButtonY = -16.0; // from bottom edge of body |
85 | 85 |
86 void performLayout() { | 86 void performLayout() { |
87 double bodyHeight = size.height; | 87 double bodyHeight = size.height; |
88 double bodyPosition = 0.0; | 88 double bodyPosition = 0.0; |
89 if (_slots[ScaffoldSlots.toolbar] != null) { | 89 if (_slots[ScaffoldSlots.toolbar] != null) { |
90 RenderBox toolbar = _slots[ScaffoldSlots.toolbar]; | 90 RenderBox toolbar = _slots[ScaffoldSlots.toolbar]; |
91 toolbar.layout(new BoxConstraints.tight(new Size(size.width, kToolbarHeigh
t))); | 91 toolbar.layout(new BoxConstraints.tight(new Size(size.width, kToolbarHeigh
t))); |
92 assert(toolbar.parentData is BoxParentData); | 92 assert(toolbar.parentData is BoxParentData); |
93 toolbar.parentData.position = new Point(0.0, 0.0); | 93 toolbar.parentData.position = Point.origin; |
94 bodyPosition = kToolbarHeight; | 94 bodyPosition = kToolbarHeight; |
95 bodyHeight -= kToolbarHeight; | 95 bodyHeight -= kToolbarHeight; |
96 } | 96 } |
97 if (_slots[ScaffoldSlots.statusBar] != null) { | 97 if (_slots[ScaffoldSlots.statusBar] != null) { |
98 RenderBox statusbar = _slots[ScaffoldSlots.statusBar]; | 98 RenderBox statusbar = _slots[ScaffoldSlots.statusBar]; |
99 statusbar.layout(new BoxConstraints.tight(new Size(size.width, kStatusbarH
eight))); | 99 statusbar.layout(new BoxConstraints.tight(new Size(size.width, kStatusbarH
eight))); |
100 assert(statusbar.parentData is BoxParentData); | 100 assert(statusbar.parentData is BoxParentData); |
101 statusbar.parentData.position = new Point(0.0, size.height - kStatusbarHei
ght); | 101 statusbar.parentData.position = new Point(0.0, size.height - kStatusbarHei
ght); |
102 bodyHeight -= kStatusbarHeight; | 102 bodyHeight -= kStatusbarHeight; |
103 } | 103 } |
104 if (_slots[ScaffoldSlots.body] != null) { | 104 if (_slots[ScaffoldSlots.body] != null) { |
105 RenderBox body = _slots[ScaffoldSlots.body]; | 105 RenderBox body = _slots[ScaffoldSlots.body]; |
106 body.layout(new BoxConstraints.tight(new Size(size.width, bodyHeight))); | 106 body.layout(new BoxConstraints.tight(new Size(size.width, bodyHeight))); |
107 assert(body.parentData is BoxParentData); | 107 assert(body.parentData is BoxParentData); |
108 body.parentData.position = new Point(0.0, bodyPosition); | 108 body.parentData.position = new Point(0.0, bodyPosition); |
109 } | 109 } |
110 if (_slots[ScaffoldSlots.drawer] != null) { | 110 if (_slots[ScaffoldSlots.drawer] != null) { |
111 RenderBox drawer = _slots[ScaffoldSlots.drawer]; | 111 RenderBox drawer = _slots[ScaffoldSlots.drawer]; |
112 drawer.layout(new BoxConstraints(minWidth: 0.0, maxWidth: size.width, minH
eight: size.height, maxHeight: size.height)); | 112 drawer.layout(new BoxConstraints(minWidth: 0.0, maxWidth: size.width, minH
eight: size.height, maxHeight: size.height)); |
113 assert(drawer.parentData is BoxParentData); | 113 assert(drawer.parentData is BoxParentData); |
114 drawer.parentData.position = new Point(0.0, 0.0); | 114 drawer.parentData.position = Point.origin; |
115 } | 115 } |
116 if (_slots[ScaffoldSlots.floatingActionButton] != null) { | 116 if (_slots[ScaffoldSlots.floatingActionButton] != null) { |
117 RenderBox floatingActionButton = _slots[ScaffoldSlots.floatingActionButton
]; | 117 RenderBox floatingActionButton = _slots[ScaffoldSlots.floatingActionButton
]; |
118 Size area = new Size(size.width + kButtonX, size.height + kButtonY); | 118 Size area = new Size(size.width + kButtonX, size.height + kButtonY); |
119 floatingActionButton.layout(new BoxConstraints.loose(area)); | 119 floatingActionButton.layout(new BoxConstraints.loose(area)); |
120 assert(floatingActionButton.parentData is BoxParentData); | 120 assert(floatingActionButton.parentData is BoxParentData); |
121 floatingActionButton.parentData.position = (area - floatingActionButton.si
ze).toPoint(); | 121 floatingActionButton.parentData.position = (area - floatingActionButton.si
ze).toPoint(); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 void syncRenderObject(UINode old) { | 203 void syncRenderObject(UINode old) { |
204 super.syncRenderObject(old); | 204 super.syncRenderObject(old); |
205 syncChild(toolbar, old is Scaffold ? old.toolbar : null, ScaffoldSlots.toolb
ar); | 205 syncChild(toolbar, old is Scaffold ? old.toolbar : null, ScaffoldSlots.toolb
ar); |
206 syncChild(body, old is Scaffold ? old.body : null, ScaffoldSlots.body); | 206 syncChild(body, old is Scaffold ? old.body : null, ScaffoldSlots.body); |
207 syncChild(statusbar, old is Scaffold ? old.statusbar : null, ScaffoldSlots.s
tatusBar); | 207 syncChild(statusbar, old is Scaffold ? old.statusbar : null, ScaffoldSlots.s
tatusBar); |
208 syncChild(drawer, old is Scaffold ? old.drawer : null, ScaffoldSlots.drawer)
; | 208 syncChild(drawer, old is Scaffold ? old.drawer : null, ScaffoldSlots.drawer)
; |
209 syncChild(floatingActionButton, old is Scaffold ? old.floatingActionButton :
null, ScaffoldSlots.floatingActionButton); | 209 syncChild(floatingActionButton, old is Scaffold ? old.floatingActionButton :
null, ScaffoldSlots.floatingActionButton); |
210 } | 210 } |
211 | 211 |
212 } | 212 } |
OLD | NEW |