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

Side by Side Diff: sky/sdk/lib/framework/components2/scaffold.dart

Issue 1171173003: Right-size the toolbar (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Updated per review feedback Created 5 years, 6 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 | « no previous file | sky/sdk/lib/framework/components2/tool_bar.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 '../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 import '../theme2/view_configuration.dart';
8 9
9 enum ScaffoldSlots { 10 enum ScaffoldSlots {
10 toolbar, 11 toolbar,
11 body, 12 body,
12 statusBar, 13 statusBar,
13 drawer, 14 drawer,
14 floatingActionButton 15 floatingActionButton
15 } 16 }
16 17
17 class RenderScaffold extends RenderBox { 18 class RenderScaffold extends RenderBox {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return null; 72 return null;
72 } 73 }
73 74
74 bool get sizedByParent => true; 75 bool get sizedByParent => true;
75 void performResize() { 76 void performResize() {
76 size = constraints.constrain(Size.infinite); 77 size = constraints.constrain(Size.infinite);
77 assert(size.width < double.INFINITY); 78 assert(size.width < double.INFINITY);
78 assert(size.height < double.INFINITY); 79 assert(size.height < double.INFINITY);
79 } 80 }
80 81
81 static const kToolbarHeight = 100.0;
82 static const kStatusbarHeight = 50.0;
83 static const kButtonX = 16.0; // left from right edge of body 82 static const kButtonX = 16.0; // left from right edge of body
84 static const kButtonY = 16.0; // up from bottom edge of body 83 static const kButtonY = 16.0; // up from bottom edge of body
85 84
86 void performLayout() { 85 void performLayout() {
87 double bodyHeight = size.height; 86 double bodyHeight = size.height;
88 double bodyPosition = 0.0; 87 double bodyPosition = 0.0;
89 if (_slots[ScaffoldSlots.toolbar] != null) { 88 if (_slots[ScaffoldSlots.toolbar] != null) {
90 RenderBox toolbar = _slots[ScaffoldSlots.toolbar]; 89 RenderBox toolbar = _slots[ScaffoldSlots.toolbar];
91 toolbar.layout(new BoxConstraints.tight(new Size(size.width, kToolbarHeigh t))); 90 double toolbarHeight = kToolBarHeight + kNotificationAreaHeight;
91 toolbar.layout(new BoxConstraints.tight(new Size(size.width, toolbarHeight )));
92 assert(toolbar.parentData is BoxParentData); 92 assert(toolbar.parentData is BoxParentData);
93 toolbar.parentData.position = Point.origin; 93 toolbar.parentData.position = Point.origin;
94 bodyPosition = kToolbarHeight; 94 bodyPosition += toolbarHeight;
95 bodyHeight -= kToolbarHeight; 95 bodyHeight -= toolbarHeight;
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];
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void syncRenderObject(UINode old) { 206 void syncRenderObject(UINode old) {
207 super.syncRenderObject(old); 207 super.syncRenderObject(old);
208 _toolbar = syncChild(_toolbar, old is Scaffold ? old._toolbar : null, Scaffo ldSlots.toolbar); 208 _toolbar = syncChild(_toolbar, old is Scaffold ? old._toolbar : null, Scaffo ldSlots.toolbar);
209 _body = syncChild(_body, old is Scaffold ? old._body : null, ScaffoldSlots.b ody); 209 _body = syncChild(_body, old is Scaffold ? old._body : null, ScaffoldSlots.b ody);
210 _statusbar = syncChild(_statusbar, old is Scaffold ? old._statusbar : null, ScaffoldSlots.statusBar); 210 _statusbar = syncChild(_statusbar, old is Scaffold ? old._statusbar : null, ScaffoldSlots.statusBar);
211 _drawer = syncChild(_drawer, old is Scaffold ? old._drawer : null, ScaffoldS lots.drawer); 211 _drawer = syncChild(_drawer, old is Scaffold ? old._drawer : null, ScaffoldS lots.drawer);
212 _floatingActionButton = syncChild(_floatingActionButton, old is Scaffold ? o ld._floatingActionButton : null, ScaffoldSlots.floatingActionButton); 212 _floatingActionButton = syncChild(_floatingActionButton, old is Scaffold ? o ld._floatingActionButton : null, ScaffoldSlots.floatingActionButton);
213 } 213 }
214 214
215 } 215 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/framework/components2/tool_bar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698