TinderSwapCard constructor
Constructor requires Card Widget Builder cardBuilder
& your card count totalNum
, option includes: stack orientation orientation
, number of card display in same time stackNum
, and size control params;
Implementation
TinderSwapCard(
{@required CardBuilder cardBuilder,
@required int totalNum,
AmassOrientation orientation = AmassOrientation.BOTTOM,
int stackNum = 3,
double maxWidth,
double maxHeight,
double minWidth,
double minHeight,
this.swipeCompleteCallback,
this.swipeUpdateCallback})
: this._cardBuilder = cardBuilder,
this._totalNum = totalNum,
assert(stackNum > 1),
this._stackNum = stackNum,
assert(maxWidth > minWidth && maxHeight > minHeight)
// this._maxWidth = maxWidth,
// this._minWidth = minWidth,
// this._maxHeight = maxHeight,
// this._minHeight = minHeight
{
double widthGap = maxWidth - minWidth;
double heightGap = maxHeight - minHeight;
_cardAligns = new List();
_cardSizes = new List();
for (int i = 0; i < _stackNum; i++) {
_cardSizes.add(new Size(minWidth + (widthGap / _stackNum) * i,
minHeight + (heightGap / _stackNum) * i));
switch (orientation) {
case AmassOrientation.BOTTOM:
_cardAligns.add(
new Alignment(0.0, (0.5 / (_stackNum - 1)) * (stackNum - i)));
break;
case AmassOrientation.TOP:
_cardAligns.add(
new Alignment(0.0, (-0.5 / (_stackNum - 1)) * (stackNum - i)));
break;
case AmassOrientation.LEFT:
_cardAligns.add(
new Alignment((-0.5 / (_stackNum - 1)) * (stackNum - i), 0.0));
break;
case AmassOrientation.RIGHT:
_cardAligns.add(
new Alignment((0.5 / (_stackNum - 1)) * (stackNum - i), 0.0));
break;
}
}
}