Skip to content

Commit

Permalink
Merge pull request #23 from xrr2016/dev
Browse files Browse the repository at this point in the history
fix: fix onBack callback info index
  • Loading branch information
xrr2016 authored Feb 23, 2021
2 parents 403c543 + 3454962 commit b4ff47e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: "12.x"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.3.1] - 2021.02.23

1. Fix onBack callback info index 🐛

## [1.3.0] - 2021.02.23

1. Add lockYAxis property ✨
Expand Down
10 changes: 6 additions & 4 deletions lib/src/cards.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,12 @@ class TCardState extends State<TCard> with TickerProviderStateMixin {
_resetFrontCard();
_swipInfoList.removeLast();
if (widget.onBack != null && widget.onBack is Function) {
widget.onBack(
_frontCardIndex,
_swipInfoList[_frontCardIndex],
);
int index = _frontCardIndex > 0 ? _frontCardIndex - 1 : 0;
SwipInfo info = _swipInfoList.isNotEmpty
? _swipInfoList[index]
: SwipInfo(-1, SwipDirection.None);

widget.onBack(_frontCardIndex, info);
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/src/swip_info.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
enum SwipDirection {
Left,
Right,
None,
}

class SwipInfo {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: tcard
description: A tinder like cards flutter plugin, can slide it's children left or right. You can use it to show some images, videos and so on.
version: 1.3.0
version: 1.3.1
homepage: https://github.com/xrr2016/tcard

environment:
Expand Down

0 comments on commit b4ff47e

Please sign in to comment.