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
6d587704
Commit
6d587704
authored
Apr 01, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the fixed height card demo
Turns out card_collection had all kinds of bugs.
parent
794b7051
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
card_collection.dart
dev/manual_tests/card_collection.dart
+15
-10
No files found.
dev/manual_tests/card_collection.dart
View file @
6d587704
...
...
@@ -30,6 +30,7 @@ class CardCollectionState extends State<CardCollection> {
static
const
String
_sunshineURL
=
"http://www.walltor.com/images/wallpaper/good-morning-sunshine-58540.jpg"
;
static
const
double
kCardMargins
=
8.0
;
static
const
double
kFixedCardHeight
=
100.0
;
final
TextStyle
backgroundTextStyle
=
Typography
.
white
.
title
.
copyWith
(
textAlign:
TextAlign
.
center
);
...
...
@@ -59,10 +60,9 @@ class CardCollectionState extends State<CardCollection> {
void
_initFixedSizedCardModels
()
{
const
int
cardCount
=
27
;
const
double
cardHeight
=
100.0
;
_cardModels
=
new
List
<
CardModel
>.
generate
(
cardCount
,
(
int
i
)
=>
new
CardModel
(
i
,
c
ardHeight
)
(
int
i
)
=>
new
CardModel
(
i
,
kFixedC
ardHeight
)
);
}
...
...
@@ -73,6 +73,11 @@ class CardCollectionState extends State<CardCollection> {
_initVariableSizedCardModels
();
}
Iterable
<
int
>
get
_cardIndices
sync
*
{
for
(
int
i
=
0
;
i
<
_cardModels
.
length
;
i
+=
1
)
yield
i
;
}
@override
void
initState
()
{
super
.
initState
();
...
...
@@ -99,9 +104,8 @@ class CardCollectionState extends State<CardCollection> {
}
double
_fixedSizeToSnapOffset
(
double
scrollOffset
)
{
double
cardHeight
=
_cardModels
[
0
].
height
;
int
cardIndex
=
(
scrollOffset
.
clamp
(
0.0
,
cardHeight
*
(
_cardModels
.
length
-
1
))
/
cardHeight
).
floor
();
return
cardIndex
*
cardHeight
+
cardHeight
*
0.5
;
int
cardIndex
=
(
scrollOffset
.
clamp
(
0.0
,
kFixedCardHeight
*
(
_cardModels
.
length
-
1
))
/
kFixedCardHeight
).
floor
();
return
cardIndex
*
kFixedCardHeight
+
kFixedCardHeight
*
0.5
;
}
double
_toSnapOffset
(
double
scrollOffset
,
Size
containerSize
)
{
...
...
@@ -300,7 +304,7 @@ class CardCollectionState extends State<CardCollection> {
Widget
card
=
new
Dismissable
(
key:
new
ObjectKey
(
cardModel
),
direction:
_dismissDirection
,
onResize:
()
{
_invalidator
(<
int
>[
index
]);
},
onResize:
()
{
if
(
_invalidator
!=
null
)
_invalidator
(<
int
>[
index
]);
},
onDismissed:
(
DismissDirection
direction
)
{
dismissCard
(
cardModel
);
},
child:
new
Card
(
color:
_primaryColor
[
cardModel
.
color
],
...
...
@@ -321,7 +325,7 @@ class CardCollectionState extends State<CardCollection> {
)
:
new
DefaultTextStyle
(
style:
DefaultTextStyle
.
of
(
context
).
merge
(
cardLabelStyle
).
merge
(
_textStyle
).
copyWith
(
fontSize:
_varyFontSizes
?
_cardModels
.
length
.
toDouble
()
:
null
fontSize:
_varyFontSizes
?
5.0
+
index
:
null
),
child:
new
Column
(
children:
<
Widget
>[
...
...
@@ -409,10 +413,11 @@ class CardCollectionState extends State<CardCollection> {
Widget
build
(
BuildContext
context
)
{
Widget
cardCollection
;
if
(
_fixedSizeCards
)
{
cardCollection
=
new
ScrollableList
(
_invalidator
=
null
;
cardCollection
=
new
ScrollableList
(
snapOffsetCallback:
_snapToCenter
?
_toSnapOffset
:
null
,
itemExtent:
_cardModels
[
0
].
h
eight
,
children:
_card
Models
.
map
((
CardModel
card
)
=>
_buildCard
(
context
,
card
.
value
))
itemExtent:
kFixedCardH
eight
,
children:
_card
Indices
.
map
/*<Widget>*/
((
int
index
)
=>
_buildCard
(
context
,
index
))
);
}
else
{
cardCollection
=
new
ScrollableMixedWidgetList
(
...
...
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