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:math' as math; | 5 import 'dart:math' as math; |
6 | 6 |
7 import 'package:sky/rendering/box.dart'; | 7 import 'package:sky/rendering/box.dart'; |
8 import 'package:sky/rendering/flex.dart'; | 8 import 'package:sky/rendering/flex.dart'; |
9 import 'package:sky/theme2/colors.dart'; | 9 import 'package:sky/theme2/colors.dart'; |
10 import 'package:sky/theme2/edges.dart'; | 10 import 'package:sky/theme2/edges.dart'; |
11 import 'package:sky/theme2/typography.dart'; | 11 import 'package:sky/theme2/typography.dart'; |
12 import 'package:sky/widgets/basic.dart'; | 12 import 'package:sky/widgets/basic.dart'; |
13 import 'package:sky/widgets/material.dart'; | 13 import 'package:sky/widgets/material.dart'; |
14 import 'package:sky/widgets/raised_button.dart'; | 14 import 'package:sky/widgets/raised_button.dart'; |
15 import 'package:sky/widgets/scaffold.dart'; | 15 import 'package:sky/widgets/scaffold.dart'; |
16 import 'package:sky/widgets/tool_bar.dart'; | 16 import 'package:sky/widgets/tool_bar.dart'; |
17 import 'package:sky/widgets/ui_node.dart'; | 17 import 'package:sky/widgets/widget.dart'; |
18 | 18 |
19 import '../rendering/sector_layout.dart'; | 19 import '../rendering/sector_layout.dart'; |
20 | 20 |
21 RenderBox initCircle() { | 21 RenderBox initCircle() { |
22 return new RenderBoxToRenderSectorAdapter( | 22 return new RenderBoxToRenderSectorAdapter( |
23 innerRadius: 25.0, | 23 innerRadius: 25.0, |
24 child: new RenderSectorRing(padding: 0.0) | 24 child: new RenderSectorRing(padding: 0.0) |
25 ); | 25 ); |
26 } | 26 } |
27 | 27 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 bool enabledRemove = false; | 65 bool enabledRemove = false; |
66 void updateEnabledState() { | 66 void updateEnabledState() { |
67 setState(() { | 67 setState(() { |
68 var ring = (sectors.child as RenderSectorRing); | 68 var ring = (sectors.child as RenderSectorRing); |
69 SectorDimensions currentSize = ring.getIntrinsicDimensions(const SectorCon
straints(), ring.deltaRadius); | 69 SectorDimensions currentSize = ring.getIntrinsicDimensions(const SectorCon
straints(), ring.deltaRadius); |
70 enabledAdd = currentSize.deltaTheta < kTwoPi; | 70 enabledAdd = currentSize.deltaTheta < kTwoPi; |
71 enabledRemove = ring.firstChild != null; | 71 enabledRemove = ring.firstChild != null; |
72 }); | 72 }); |
73 } | 73 } |
74 | 74 |
75 UINode build() { | 75 Widget build() { |
76 return new Scaffold( | 76 return new Scaffold( |
77 toolbar: new ToolBar( | 77 toolbar: new ToolBar( |
78 center: new Text('Sector Layout in a Widget Tree', style: white.title)
, | 78 center: new Text('Sector Layout in a Widget Tree', style: white.title)
, |
79 backgroundColor: Blue[500]), | 79 backgroundColor: Blue[500]), |
80 body: new Material( | 80 body: new Material( |
81 edge: MaterialEdge.canvas, | 81 edge: MaterialEdge.canvas, |
82 child: new Flex([ | 82 child: new Flex([ |
83 new Container( | 83 new Container( |
84 padding: new EdgeDims.symmetric(horizontal: 8.0, vertical: 25.0), | 84 padding: new EdgeDims.symmetric(horizontal: 8.0, vertical: 25.0), |
85 child: new Flex([ | 85 child: new Flex([ |
86 new RaisedButton( | 86 new RaisedButton( |
87 key: 'add-button', | 87 key: 'add-button', |
88 enabled: enabledAdd, | 88 enabled: enabledAdd, |
89 child: new ShrinkWrapWidth( | 89 child: new ShrinkWrapWidth( |
90 child: new Flex([ | 90 child: new Flex([ |
91 new Container( | 91 new Container( |
92 padding: new EdgeDims.all(4.0), | 92 padding: new EdgeDims.all(4.0), |
93 margin: new EdgeDims.only(right: 10.0), | 93 margin: new EdgeDims.only(right: 10.0), |
94 child: new UINodeToRenderBoxAdapter(sectorAddIcon) | 94 child: new WidgetToRenderBoxAdapter(sectorAddIcon) |
95 ), | 95 ), |
96 new Text('ADD SECTOR'), | 96 new Text('ADD SECTOR'), |
97 ]) | 97 ]) |
98 ), | 98 ), |
99 onPressed: addSector | 99 onPressed: addSector |
100 ), | 100 ), |
101 new RaisedButton( | 101 new RaisedButton( |
102 key: 'remove-button', | 102 key: 'remove-button', |
103 enabled: enabledRemove, | 103 enabled: enabledRemove, |
104 child: new ShrinkWrapWidth( | 104 child: new ShrinkWrapWidth( |
105 child: new Flex([ | 105 child: new Flex([ |
106 new Container( | 106 new Container( |
107 padding: new EdgeDims.all(4.0), | 107 padding: new EdgeDims.all(4.0), |
108 margin: new EdgeDims.only(right: 10.0), | 108 margin: new EdgeDims.only(right: 10.0), |
109 child: new UINodeToRenderBoxAdapter(sectorRemoveIcon) | 109 child: new WidgetToRenderBoxAdapter(sectorRemoveIcon) |
110 ), | 110 ), |
111 new Text('REMOVE SECTOR'), | 111 new Text('REMOVE SECTOR'), |
112 ]) | 112 ]) |
113 ), | 113 ), |
114 onPressed: removeSector | 114 onPressed: removeSector |
115 ) | 115 ) |
116 ], | 116 ], |
117 justifyContent: FlexJustifyContent.spaceAround | 117 justifyContent: FlexJustifyContent.spaceAround |
118 ) | 118 ) |
119 ), | 119 ), |
120 new Flexible( | 120 new Flexible( |
121 child: new Container( | 121 child: new Container( |
122 margin: new EdgeDims.all(8.0), | 122 margin: new EdgeDims.all(8.0), |
123 decoration: new BoxDecoration( | 123 decoration: new BoxDecoration( |
124 border: new Border.all(new BorderSide(color: new Color(0xFF000
000))) | 124 border: new Border.all(new BorderSide(color: new Color(0xFF000
000))) |
125 ), | 125 ), |
126 padding: new EdgeDims.all(8.0), | 126 padding: new EdgeDims.all(8.0), |
127 child: new UINodeToRenderBoxAdapter(sectors) | 127 child: new WidgetToRenderBoxAdapter(sectors) |
128 ) | 128 ) |
129 ), | 129 ), |
130 ], | 130 ], |
131 direction: FlexDirection.vertical, | 131 direction: FlexDirection.vertical, |
132 justifyContent: FlexJustifyContent.spaceBetween | 132 justifyContent: FlexJustifyContent.spaceBetween |
133 ) | 133 ) |
134 ) | 134 ) |
135 ); | 135 ); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 void main() { | 139 void main() { |
140 App app = new SectorApp(); | 140 App app = new SectorApp(); |
141 UINodeAppView.appView.onFrame = () { | 141 WidgetAppView.appView.onFrame = () { |
142 // uncomment this for debugging: | 142 // uncomment this for debugging: |
143 // UINodeAppView.appView.debugDumpRenderTree(); | 143 // WidgetAppView.appView.debugDumpRenderTree(); |
144 }; | 144 }; |
145 } | 145 } |
OLD | NEW |