Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget now accepts 'enable' property which can disable swiping #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/flutter_tindercard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class TinderSwapCard extends StatefulWidget {

final bool _allowVerticalMovement;

final bool _enabled;

final CardSwipeCompleteCallback? swipeCompleteCallback;

final CardDragUpdateCallback? swipeUpdateCallback;
Expand Down Expand Up @@ -62,6 +64,7 @@ class TinderSwapCard extends StatefulWidget {
double? minWidth,
double? minHeight,
bool allowVerticalMovement = true,
bool enabled = true,
this.cardController,
this.swipeCompleteCallback,
this.swipeUpdateCallback,
Expand All @@ -77,7 +80,8 @@ class TinderSwapCard extends StatefulWidget {
_swipeEdgeVertical = swipeEdgeVertical,
_swipeUp = swipeUp,
_swipeDown = swipeDown,
_allowVerticalMovement = allowVerticalMovement {
_allowVerticalMovement = allowVerticalMovement,
_enabled = enabled {
final widthGap = maxWidth! - minWidth!;
final heightGap = maxHeight! - minHeight!;

Expand Down Expand Up @@ -127,11 +131,11 @@ class TinderSwapCard extends StatefulWidget {

class _TinderSwapCardState extends State<TinderSwapCard>
with TickerProviderStateMixin {
late Alignment frontCardAlign;
late Alignment frontCardAlign;

late AnimationController _animationController;
late AnimationController _animationController;

late int _currentFront;
late int _currentFront;

static TriggerDirection? _trigger;

Expand Down Expand Up @@ -213,6 +217,7 @@ class _TinderSwapCardState extends State<TinderSwapCard>
cards.add(SizedBox.expand(
child: GestureDetector(
onPanUpdate: (final details) {
if (!widget._enabled) return;
setState(() {
if (widget._allowVerticalMovement == true) {
frontCardAlign = Alignment(
Expand Down