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

Side by Side Diff: sky/sdk/example/demo_launcher/lib/main.dart

Issue 1223083002: Make RenderBlock painting match its hittesting (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 | « no previous file | sky/sdk/lib/rendering/block.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 'dart:sky'; 5 import 'dart:sky';
6 6
7 import 'package:sky/mojo/activity.dart' as activity; 7 import 'package:sky/mojo/activity.dart' as activity;
8 import 'package:sky/mojo/asset_bundle.dart'; 8 import 'package:sky/mojo/asset_bundle.dart';
9 import 'package:sky/mojo/shell.dart' as shell; 9 import 'package:sky/mojo/shell.dart' as shell;
10 import 'package:sky/painting/box_painter.dart'; 10 import 'package:sky/painting/box_painter.dart';
11 import 'package:sky/theme/colors.dart' as colors; 11 import 'package:sky/theme/colors.dart' as colors;
12 import 'package:sky/theme/typography.dart' as typography; 12 import 'package:sky/theme/typography.dart' as typography;
13 import 'package:sky/widgets/basic.dart'; 13 import 'package:sky/widgets/basic.dart';
14 import 'package:sky/widgets/card.dart'; 14 import 'package:sky/widgets/card.dart';
15 import 'package:sky/widgets/fixed_height_scrollable.dart'; 15 import 'package:sky/widgets/fixed_height_scrollable.dart';
16 import 'package:sky/widgets/flat_button.dart'; 16 import 'package:sky/widgets/flat_button.dart';
17 import 'package:sky/widgets/material.dart'; 17 import 'package:sky/widgets/material.dart';
18 import 'package:sky/widgets/scaffold.dart'; 18 import 'package:sky/widgets/scaffold.dart';
19 import 'package:sky/widgets/task_description.dart'; 19 import 'package:sky/widgets/task_description.dart';
20 import 'package:sky/widgets/theme.dart'; 20 import 'package:sky/widgets/theme.dart';
21 import 'package:sky/widgets/tool_bar.dart'; 21 import 'package:sky/widgets/tool_bar.dart';
22 import 'package:sky/widgets/scrollable_list.dart';
22 23
23 AssetBundle _initBundle() { 24 AssetBundle _initBundle() {
24 if (rootBundle != null) 25 if (rootBundle != null)
25 return rootBundle; 26 return rootBundle;
26 const String _kAssetBase = '..'; 27 const String _kAssetBase = '..';
27 return new NetworkAssetBundle(Uri.base.resolve(_kAssetBase)); 28 return new NetworkAssetBundle(Uri.base.resolve(_kAssetBase));
28 } 29 }
29 30
30 final AssetBundle _bundle = _initBundle(); 31 final AssetBundle _bundle = _initBundle();
31 32
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 textTheme: typography.white 126 textTheme: typography.white
126 ), 127 ),
127 128
128 // TODO(jackson): This doesn't seem to be working 129 // TODO(jackson): This doesn't seem to be working
129 // new SkyDemo('Licenses', 'LICENSES.sky'), 130 // new SkyDemo('Licenses', 'LICENSES.sky'),
130 ]; 131 ];
131 132
132 const double kCardHeight = 120.0; 133 const double kCardHeight = 120.0;
133 const EdgeDims kListPadding = const EdgeDims.all(4.0); 134 const EdgeDims kListPadding = const EdgeDims.all(4.0);
134 135
135 class DemoList extends FixedHeightScrollable { 136 class DemoList extends Component {
136 DemoList({ String key }) : super(key: key, itemHeight: kCardHeight, padding: k ListPadding);
137
138 int get itemCount => demos.length;
139
140 Widget buildDemo(SkyDemo demo) { 137 Widget buildDemo(SkyDemo demo) {
141 return new Listener( 138 return new Listener(
142 key: demo.name, 139 key: demo.name,
143 onGestureTap: (_) => launch(demo.href, demo.bundle), 140 onGestureTap: (_) => launch(demo.href, demo.bundle),
144 child: new Container( 141 child: new Container(
145 height: kCardHeight, 142 height: kCardHeight,
146 child: new Card( 143 child: new Card(
147 child: new Flex([ 144 child: new Flex([
148 new Flexible( 145 new Flexible(
149 child: new Stack([ 146 child: new Stack([
150 new Container( 147 new Container(
151 decoration: demo.decoration, 148 decoration: demo.decoration,
152 child: new Container() 149 child: new Container()
153 ), 150 ),
154 new Container( 151 new Container(
155 margin: const EdgeDims.all(24.0), 152 margin: const EdgeDims.all(24.0),
156 child: new Block([ 153 child: new Block([
157 new Text(demo.name, style: demo.textTheme.title), 154 new Text(demo.name, style: demo.textTheme.title),
158 new Text(demo.description, style: demo.textTheme.subhead) 155 new Text(demo.description, style: demo.textTheme.subhead)
159 ]) 156 ])
160 ) 157 )
161 ]) 158 ])
162 ), 159 ),
163 ], direction: FlexDirection.vertical) 160 ], direction: FlexDirection.vertical)
164 ) 161 )
165 ) 162 )
166 ); 163 );
167 } 164 }
168 165
169 List<Widget> buildItems(int start, int count) { 166 Widget build() {
170 return demos 167 return new ScrollableList<SkyDemo>(
171 .skip(start) 168 items: demos,
172 .take(count) 169 itemHeight: kCardHeight,
173 .map(buildDemo) 170 itemBuilder: buildDemo,
174 .toList(growable: false); 171 padding: kListPadding
172 );
175 } 173 }
176 } 174 }
177 175
178 class SkyHome extends App { 176 class SkyHome extends App {
179 Widget build() { 177 Widget build() {
180 return new Theme( 178 return new Theme(
181 data: new ThemeData( 179 data: new ThemeData(
182 brightness: ThemeBrightness.dark, 180 brightness: ThemeBrightness.dark,
183 primarySwatch: colors.Teal 181 primarySwatch: colors.Teal
184 ), 182 ),
185 child: new TaskDescription( 183 child: new TaskDescription(
186 label: 'Sky Demos', 184 label: 'Sky Demos',
187 child: new Scaffold( 185 child: new Scaffold(
188 toolbar: new ToolBar(center: new Text('Sky Demos')), 186 toolbar: new ToolBar(center: new Text('Sky Demos')),
189 body: new Material( 187 body: new Material(
190 type: MaterialType.canvas, 188 type: MaterialType.canvas,
191 child: new DemoList() 189 child: new DemoList()
192 ) 190 )
193 ) 191 )
194 ) 192 )
195 ); 193 );
196 } 194 }
197 } 195 }
198 196
199 void main() { 197 void main() {
200 runApp(new SkyHome()); 198 runApp(new SkyHome());
201 } 199 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/rendering/block.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698