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

Side by Side Diff: sky/sdk/lib/widgets/drawer_item.dart

Issue 1236043004: Improve drawer performance (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: cache paint 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 | « sky/sdk/lib/widgets/basic.dart ('k') | sky/sdk/lib/widgets/icon.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' as sky; 5 import 'dart:sky' as sky;
6 6
7 import 'package:sky/painting/text_style.dart'; 7 import 'package:sky/painting/text_style.dart';
8 import 'package:sky/theme/colors.dart' as colors; 8 import 'package:sky/theme/colors.dart' as colors;
9 import 'package:sky/widgets/basic.dart'; 9 import 'package:sky/widgets/basic.dart';
10 import 'package:sky/widgets/button_base.dart'; 10 import 'package:sky/widgets/button_base.dart';
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 Color _getBackgroundColor(ThemeData themeData) { 41 Color _getBackgroundColor(ThemeData themeData) {
42 if (highlight) 42 if (highlight)
43 return themeData.highlightColor; 43 return themeData.highlightColor;
44 if (selected) 44 if (selected)
45 return themeData.selectedColor; 45 return themeData.selectedColor;
46 return colors.transparent; 46 return colors.transparent;
47 } 47 }
48 48
49 sky.ColorFilter _getColorFilter(ThemeData themeData) {
50 if (selected)
51 return new sky.ColorFilter.mode(themeData.primaryColor, sky.TransferMode.s rcATop);
52 return new sky.ColorFilter.mode(const Color(0x73000000), sky.TransferMode.ds tIn);
53 }
54
49 Widget buildContent() { 55 Widget buildContent() {
50 ThemeData themeData = Theme.of(this); 56 ThemeData themeData = Theme.of(this);
51 57
52 List<Widget> flexChildren = new List<Widget>(); 58 List<Widget> flexChildren = new List<Widget>();
53 if (icon != null) { 59 if (icon != null) {
54 Widget child = new Icon(type: icon, size: 24);
55 if (selected) {
56 child = new ColorFilter(
57 color: themeData.primaryColor,
58 transferMode: sky.TransferMode.srcATop,
59 child: child
60 );
61 }
62 flexChildren.add( 60 flexChildren.add(
63 new Opacity( 61 new Padding(
64 opacity: selected ? 1.0 : 0.45, 62 padding: const EdgeDims.symmetric(horizontal: 16.0),
65 child: new Padding( 63 child: new Icon(
66 padding: const EdgeDims.symmetric(horizontal: 16.0), 64 type: icon,
67 child: child 65 size: 24,
68 ) 66 colorFilter: _getColorFilter(themeData))
69 ) 67 )
70 ); 68 );
71 } 69 }
72 flexChildren.add( 70 flexChildren.add(
73 new Flexible( 71 new Flexible(
74 child: new Padding( 72 child: new Padding(
75 padding: const EdgeDims.symmetric(horizontal: 16.0), 73 padding: const EdgeDims.symmetric(horizontal: 16.0),
76 child: new DefaultTextStyle( 74 child: new DefaultTextStyle(
77 style: _getTextStyle(themeData), 75 style: _getTextStyle(themeData),
78 child: new Flex(children, direction: FlexDirection.horizontal) 76 child: new Flex(children, direction: FlexDirection.horizontal)
(...skipping 10 matching lines...) Expand all
89 child: new Container( 87 child: new Container(
90 height: 48.0, 88 height: 48.0,
91 decoration: new BoxDecoration(backgroundColor: _getBackgroundColor(theme Data)), 89 decoration: new BoxDecoration(backgroundColor: _getBackgroundColor(theme Data)),
92 child: new InkWell( 90 child: new InkWell(
93 child: new Flex(flexChildren) 91 child: new Flex(flexChildren)
94 ) 92 )
95 ) 93 )
96 ); 94 );
97 } 95 }
98 } 96 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/basic.dart ('k') | sky/sdk/lib/widgets/icon.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698