Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7982a3a2
Unverified
Commit
7982a3a2
authored
May 02, 2018
by
xster
Committed by
GitHub
May 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New gallery performance improvements (#17167)
parent
e77cfcf2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
55 deletions
+64
-55
home.dart
examples/flutter_gallery/lib/gallery/home.dart
+64
-55
No files found.
examples/flutter_gallery/lib/gallery/home.dart
View file @
7982a3a2
...
...
@@ -52,37 +52,41 @@ class _CategoryItem extends StatelessWidget {
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
bool
isDark
=
theme
.
brightness
==
Brightness
.
dark
;
return
new
RawMaterialButton
(
padding:
EdgeInsets
.
zero
,
splashColor:
theme
.
primaryColor
.
withOpacity
(
0.12
),
highlightColor:
Colors
.
transparent
,
onPressed:
onTap
,
child:
new
Column
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
new
Padding
(
padding:
const
EdgeInsets
.
all
(
6.0
),
child:
new
Icon
(
category
.
icon
,
size:
60.0
,
color:
isDark
?
Colors
.
white
:
_kFlutterBlue
,
),
),
const
SizedBox
(
height:
10.0
),
new
Container
(
height:
48.0
,
alignment:
Alignment
.
center
,
child:
new
Text
(
category
.
name
,
textAlign:
TextAlign
.
center
,
style:
theme
.
textTheme
.
subhead
.
copyWith
(
fontFamily:
'GoogleSans'
,
// This repaint boundary prevents the entire _CategoriesPage from being
// repainted when the button's ink splash animates.
return
new
RepaintBoundary
(
child:
new
RawMaterialButton
(
padding:
EdgeInsets
.
zero
,
splashColor:
theme
.
primaryColor
.
withOpacity
(
0.12
),
highlightColor:
Colors
.
transparent
,
onPressed:
onTap
,
child:
new
Column
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
new
Padding
(
padding:
const
EdgeInsets
.
all
(
6.0
),
child:
new
Icon
(
category
.
icon
,
size:
60.0
,
color:
isDark
?
Colors
.
white
:
_kFlutterBlue
,
),
),
),
],
const
SizedBox
(
height:
10.0
),
new
Container
(
height:
48.0
,
alignment:
Alignment
.
center
,
child:
new
Text
(
category
.
name
,
textAlign:
TextAlign
.
center
,
style:
theme
.
textTheme
.
subhead
.
copyWith
(
fontFamily:
'GoogleSans'
,
color:
isDark
?
Colors
.
white
:
_kFlutterBlue
,
),
),
),
],
),
),
);
}
...
...
@@ -112,33 +116,38 @@ class _CategoriesPage extends StatelessWidget {
final
double
rowHeight
=
columnWidth
*
aspectRatio
;
final
int
rowCount
=
(
categories
.
length
+
columnCount
-
1
)
~/
columnCount
;
return
new
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
new
List
<
Widget
>.
generate
(
rowCount
,
(
int
rowIndex
)
{
final
int
columnCountForRow
=
rowIndex
==
rowCount
-
1
?
categories
.
length
-
columnCount
*
math
.
max
(
0
,
rowCount
-
1
)
:
columnCount
;
return
new
Row
(
children:
new
List
<
Widget
>.
generate
(
columnCountForRow
,
(
int
columnIndex
)
{
final
int
index
=
rowIndex
*
columnCount
+
columnIndex
;
final
GalleryDemoCategory
category
=
categoriesList
[
index
];
return
new
SizedBox
(
width:
columnWidth
,
height:
rowHeight
,
child:
new
_CategoryItem
(
category:
category
,
onTap:
()
{
onCategoryTap
(
category
);
},
),
);
}),
);
}),
// This repaint boundary prevents the inner contents of the front layer
// from repainting when the backdrop toggle triggers a repaint on the
// LayoutBuilder.
return
new
RepaintBoundary
(
child:
new
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
new
List
<
Widget
>.
generate
(
rowCount
,
(
int
rowIndex
)
{
final
int
columnCountForRow
=
rowIndex
==
rowCount
-
1
?
categories
.
length
-
columnCount
*
math
.
max
(
0
,
rowCount
-
1
)
:
columnCount
;
return
new
Row
(
children:
new
List
<
Widget
>.
generate
(
columnCountForRow
,
(
int
columnIndex
)
{
final
int
index
=
rowIndex
*
columnCount
+
columnIndex
;
final
GalleryDemoCategory
category
=
categoriesList
[
index
];
return
new
SizedBox
(
width:
columnWidth
,
height:
rowHeight
,
child:
new
_CategoryItem
(
category:
category
,
onTap:
()
{
onCategoryTap
(
category
);
},
),
);
}),
);
}),
),
);
},
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment