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

Side by Side Diff: sky/sdk/example/widgets/card_collection.dart

Issue 1241483002: Improve drawer menu items (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
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 'package:sky/base/lerp.dart'; 5 import 'package:sky/base/lerp.dart';
6 import 'package:sky/painting/text_style.dart'; 6 import 'package:sky/painting/text_style.dart';
7 import 'package:sky/theme/colors.dart'; 7 import 'package:sky/theme/colors.dart';
8 import 'package:sky/widgets/basic.dart'; 8 import 'package:sky/widgets/basic.dart';
9 import 'package:sky/widgets/card.dart'; 9 import 'package:sky/widgets/card.dart';
10 import 'package:sky/widgets/dismissable.dart'; 10 import 'package:sky/widgets/dismissable.dart';
11 import 'package:sky/widgets/scaffold.dart'; 11 import 'package:sky/widgets/scaffold.dart';
12 import 'package:sky/widgets/variable_height_scrollable.dart'; 12 import 'package:sky/widgets/variable_height_scrollable.dart';
13 import 'package:sky/widgets/theme.dart'; 13 import 'package:sky/widgets/theme.dart';
14 import 'package:sky/widgets/tool_bar.dart'; 14 import 'package:sky/widgets/tool_bar.dart';
15 import 'package:sky/widgets/widget.dart'; 15 import 'package:sky/widgets/widget.dart';
16 16
17 17
18 class CardCollectionApp extends App { 18 class CardCollectionApp extends App {
19 19
20 final TextStyle cardLabelStyle = 20 final TextStyle cardLabelStyle =
21 new TextStyle(color: White, fontSize: 18.0, fontWeight: bold); 21 new TextStyle(color: white, fontSize: 18.0, fontWeight: bold);
22 22
23 final List<double> cardHeights = [ 23 final List<double> cardHeights = [
24 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0, 24 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0,
25 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0, 25 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0,
26 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0, 26 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0,
27 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0 27 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0
28 ]; 28 ];
29 29
30 List<int> visibleCardIndices; 30 List<int> visibleCardIndices;
31 31
32 void initState() { 32 void initState() {
33 visibleCardIndices = new List.generate(cardHeights.length, (i) => i); 33 visibleCardIndices = new List.generate(cardHeights.length, (i) => i);
34 super.initState(); 34 super.initState();
35 } 35 }
36 36
37 void dismissCard(int cardIndex) { 37 void dismissCard(int cardIndex) {
38 setState(() { 38 setState(() {
39 visibleCardIndices.remove(cardIndex); 39 visibleCardIndices.remove(cardIndex);
40 }); 40 });
41 } 41 }
42 42
43 Widget _builder(int index) { 43 Widget _builder(int index) {
44 if (index >= visibleCardIndices.length) 44 if (index >= visibleCardIndices.length)
45 return null; 45 return null;
46 46
47 int cardIndex = visibleCardIndices[index]; 47 int cardIndex = visibleCardIndices[index];
48 Color color = lerpColor(Red[500], Blue[500], cardIndex / cardHeights.length) ; 48 Color color = lerpColor(Red[500], Blue[500], cardIndex / cardHeights.length) ;
49 Widget label = new Text("Item ${cardIndex}", style: cardLabelStyle); 49 Widget label = new Text("Item ${cardIndex}", style: cardLabelStyle);
50 return new Dismissable( 50 return new Dismissable(
51 key: cardIndex.toString(), 51 key: cardIndex.toString(),
52 onDismissed: () { dismissCard(cardIndex); }, 52 onDismissed: () { dismissCard(cardIndex); },
53 child: new Card( 53 child: new Card(
54 color: color, 54 color: color,
55 child: new Container( 55 child: new Container(
56 height: cardHeights[cardIndex], 56 height: cardHeights[cardIndex],
(...skipping 17 matching lines...) Expand all
74 return new Scaffold( 74 return new Scaffold(
75 toolbar: new ToolBar(center: new Text('Swipe Away')), 75 toolbar: new ToolBar(center: new Text('Swipe Away')),
76 body: cardCollection 76 body: cardCollection
77 ); 77 );
78 } 78 }
79 } 79 }
80 80
81 void main() { 81 void main() {
82 runApp(new CardCollectionApp()); 82 runApp(new CardCollectionApp());
83 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698