chore(package): rename the package to `flutter_card_swiper`

This commit is contained in:
Ricardo Dalarme 2023-01-15 22:06:46 -03:00
parent 04b2346ad2
commit ead2b3f8b5
8 changed files with 65 additions and 65 deletions

View File

@ -1,4 +1,4 @@
```appinio_swiper``` is a Flutter package for a Tinder Card Swiper. ✨
```card_swiper``` is a Flutter package for a Tinder Card Swiper. ✨
It allows swiping in all directions with any Custom Widget (Stateless or Statefull).
@ -20,7 +20,7 @@ We build this package because we wanted to:
## ❗NEW Features ❗
### Trigger swipe left and swipe right through controller
You can now trigger swipe left and swipe right with our ```AppinioSwiperController``` regardless of the chosen ```AppinioSwipeDirection``` (which is still used when ```swipe``` is called through the controller). Just like the unswipe and swipe call, you can call ```swipeLeft``` or ```swipeRight``` through the controller anywhere you want.
You can now trigger swipe left and swipe right with our ```CardSwiperController``` regardless of the chosen ```AppinioSwipeDirection``` (which is still used when ```swipe``` is called through the controller). Just like the unswipe and swipe call, you can call ```swipeLeft``` or ```swipeRight``` through the controller anywhere you want.
### Unswipe all cards
You can now unswipe as many cards as possible. If you set the parameter ```unlimitedUnswipe```to ```true``` (default value: ```false```) the limit of 1 card is extended to the number of cards that have been swiped away. The way to call ```unswipe``` hasn't changed.
@ -32,7 +32,7 @@ We've added the direction in which the card was swiped away to the function ```o
We've added the function ```unswipe``` that now gets returned with the boolean ```true``` when the last card is unswiped and with boolean ```false``` when there is no last card to unswipe.
### Trigger swipe through controller
You can now trigger the swipe with our ```AppinioSwiperController```. Just like the unswipe call, you can call the ```swipe``` trough the controller anywhere you want. Just make sure to pass the controller to the parameter ```controller``` from our ```AppinioSwiper```.
You can now trigger the swipe with our ```CardSwiperController```. Just like the unswipe call, you can call the ```swipe``` trough the controller anywhere you want. Just make sure to pass the controller to the parameter ```controller``` from our ```CardSwiper```.
## Show Cases
@ -62,14 +62,14 @@ flutter create MyApp
```
Add
```yaml
appinio_swiper: ...
card_swiper: ...
```
to your `pubspec.yaml` of your flutter project.
**OR**
run
```yaml
flutter pub add appinio_swiper
flutter pub add card_swiper
```
in your project's root directory.
@ -77,16 +77,16 @@ in your project's root directory.
In your library add the following import:
```dart
import 'package:appinio_swiper/appinio_swiper.dart';
card_swiperimport 'package:flutter_card_swiper/card_swiper.dart';
```
For help getting started with Flutter, view the online [documentation](https://flutter.io/).
## Usage
You can place your `AppinioSwiper` inside of a `Scaffold` or `CupertinoPageScaffold` like we did here. Optional parameters can be defined to enable different features. See the following example..
You can place your `CardSwiper` inside of a `Scaffold` or `CupertinoPageScaffold` like we did here. Optional parameters can be defined to enable different features. See the following example..
```dart
import 'package:appinio_swiper/appinio_swiper.dart';
card_swiperimport 'package:flutter_card_swiper/card_swiper.dart';
import 'package:flutter/cupertino.dart';
class Example extends StatelessWidget {
@ -113,7 +113,7 @@ class Example extends StatelessWidget {
return CupertinoPageScaffold(
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.75,
child: AppinioSwiper(
child: CardSwiper(
cards: cards,
),
),
@ -145,7 +145,7 @@ class Example extends StatelessWidget {
#### Controller
The ```Controller``` is used to control the ```swipe```, ```swipeLeft```, ```swipeRight``` or ```unswipe``` function of the swiper from outside of the widget. You can create a controller called ```AppinioSwiperController``` and save the instance for further usage. Please have a closer look to our Example for the usage.
The ```Controller``` is used to control the ```swipe```, ```swipeLeft```, ```swipeRight``` or ```unswipe``` function of the swiper from outside of the widget. You can create a controller called ```CardSwiperController``` and save the instance for further usage. Please have a closer look to our Example for the usage.
| Method | Description
| ------------- |:-------------

View File

@ -1,8 +1,7 @@
import 'package:flutter_card_swiper/card_swiper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:appinio_swiper/appinio_swiper.dart';
class ExampleButton extends StatelessWidget {
final Function onTap;
final Widget child;
@ -23,7 +22,7 @@ class ExampleButton extends StatelessWidget {
}
//swipe card to the right side
Widget swipeRightButton(AppinioSwiperController controller) {
Widget swipeRightButton(CardSwiperController controller) {
return ExampleButton(
onTap: () => controller.swipeRight(),
child: Container(
@ -52,7 +51,7 @@ Widget swipeRightButton(AppinioSwiperController controller) {
}
//swipe card to the left side
Widget swipeLeftButton(AppinioSwiperController controller) {
Widget swipeLeftButton(CardSwiperController controller) {
return ExampleButton(
onTap: () => controller.swipeLeft(),
child: Container(
@ -81,7 +80,7 @@ Widget swipeLeftButton(AppinioSwiperController controller) {
}
//unswipe card
Widget unswipeButton(AppinioSwiperController controller) {
Widget unswipeButton(CardSwiperController controller) {
return ExampleButton(
onTap: () => controller.unswipe(),
child: Container(

View File

@ -1,9 +1,10 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:appinio_swiper/appinio_swiper.dart';
import 'package:flutter_card_swiper/card_swiper.dart';
import 'package:example/example_candidate_model.dart';
import 'package:example/example_card.dart';
import 'package:flutter/cupertino.dart';
import 'example_buttons.dart';
void main() {
@ -34,7 +35,7 @@ class Example extends StatefulWidget {
}
class _ExamplePageState extends State<Example> {
final AppinioSwiperController controller = AppinioSwiperController();
final CardSwiperController controller = CardSwiperController();
List<ExampleCard> cards = [];
@ -64,7 +65,7 @@ class _ExamplePageState extends State<Example> {
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.75,
child: AppinioSwiper(
child: CardSwiper(
unlimitedUnswipe: true,
controller: controller,
unswipe: _unswipe,
@ -100,7 +101,7 @@ class _ExamplePageState extends State<Example> {
);
}
void _swipe(int index, AppinioSwiperDirection direction) {
void _swipe(int index, CardSwiperDirection direction) {
log("the card was swiped to the: " + direction.name);
}

View File

@ -1,13 +1,6 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
appinio_swiper:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.1.1"
characters:
dependency: transitive
description:
@ -27,6 +20,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_card_swiper:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.0.0"
material_color_utilities:
dependency: transitive
description:

View File

@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
appinio_swiper:
flutter_card_swiper:
path: ../
flutter:

View File

@ -2,12 +2,12 @@ import 'dart:math';
import 'package:flutter/material.dart';
class AppinioSwiper extends StatefulWidget {
class CardSwiper extends StatefulWidget {
/// list of widgets for the swiper
final List<Widget?>? cards;
/// controller to trigger unswipe action
final AppinioSwiperController? controller;
final CardSwiperController? controller;
/// duration of every animation
final Duration duration;
@ -43,9 +43,9 @@ class AppinioSwiper extends StatefulWidget {
final Function unswipe;
/// direction in which the card gets swiped when triggered by controller, default set to right
final AppinioSwiperDirection direction;
final CardSwiperDirection direction;
const AppinioSwiper({
const CardSwiper({
Key? key,
required this.cards,
this.controller,
@ -60,17 +60,17 @@ class AppinioSwiper extends StatefulWidget {
this.onSwipe = emptyFunctionIndex,
this.onEnd = emptyFunction,
this.unswipe = emptyFunctionBool,
this.direction = AppinioSwiperDirection.right,
this.direction = CardSwiperDirection.right,
}) : assert(maxAngle >= 0 && maxAngle <= 360),
assert(threshold >= 1 && threshold <= 100),
assert(direction != AppinioSwiperDirection.none),
assert(direction != CardSwiperDirection.none),
super(key: key);
@override
State createState() => _AppinioSwiperState();
State createState() => _CardSwiperState();
}
class _AppinioSwiperState extends State<AppinioSwiper>
class _CardSwiperState extends State<CardSwiper>
with SingleTickerProviderStateMixin {
double _left = 0;
double _top = 0;
@ -100,7 +100,7 @@ class _AppinioSwiperState extends State<AppinioSwiper>
AppinioUnswipeCard? _lastCard;
// ignore: prefer_final_fields
List<AppinioUnswipeCard?> _lastCards = [];
AppinioSwiperDirection detectedDirection = AppinioSwiperDirection.none;
CardSwiperDirection detectedDirection = CardSwiperDirection.none;
@override
void initState() {
@ -110,22 +110,22 @@ class _AppinioSwiperState extends State<AppinioSwiper>
widget.controller!
//swipe widget from the outside
..addListener(() {
if (widget.controller!.state == AppinioSwiperState.swipe) {
if (widget.controller!.state == CardSwiperState.swipe) {
if (widget.cards!.isNotEmpty) {
switch (widget.direction) {
case AppinioSwiperDirection.right:
case CardSwiperDirection.right:
_swipeHorizontal(context);
break;
case AppinioSwiperDirection.left:
case CardSwiperDirection.left:
_swipeHorizontal(context);
break;
case AppinioSwiperDirection.top:
case CardSwiperDirection.top:
_swipeVertical(context);
break;
case AppinioSwiperDirection.bottom:
case CardSwiperDirection.bottom:
_swipeVertical(context);
break;
case AppinioSwiperDirection.none:
case CardSwiperDirection.none:
break;
}
_animationController.forward();
@ -134,7 +134,7 @@ class _AppinioSwiperState extends State<AppinioSwiper>
})
//swipe widget left from the outside
..addListener(() {
if (widget.controller!.state == AppinioSwiperState.swipeLeft) {
if (widget.controller!.state == CardSwiperState.swipeLeft) {
if (widget.cards!.isNotEmpty) {
_left = -1;
_swipeHorizontal(context);
@ -144,7 +144,7 @@ class _AppinioSwiperState extends State<AppinioSwiper>
})
//swipe widget right from the outside
..addListener(() {
if (widget.controller!.state == AppinioSwiperState.swipeRight) {
if (widget.controller!.state == CardSwiperState.swipeRight) {
if (widget.cards!.isNotEmpty) {
_left = widget.threshold + 1;
_swipeHorizontal(context);
@ -154,7 +154,7 @@ class _AppinioSwiperState extends State<AppinioSwiper>
})
//unswipe widget from the outside
..addListener(() {
if (widget.controller!.state == AppinioSwiperState.unswipe) {
if (widget.controller!.state == CardSwiperState.unswipe) {
if (widget.allowUnswipe) {
if (!_isUnswiping) {
if (_lastCard != null || _lastCards.isNotEmpty) {
@ -393,7 +393,7 @@ class _AppinioSwiperState extends State<AppinioSwiper>
_leftAnimation = Tween<double>(
begin: _left,
end: (_left == 0)
? (widget.direction == AppinioSwiperDirection.right)
? (widget.direction == CardSwiperDirection.right)
? MediaQuery.of(context).size.width
: -MediaQuery.of(context).size.width
: (_left > widget.threshold)
@ -414,12 +414,12 @@ class _AppinioSwiperState extends State<AppinioSwiper>
).animate(_animationController);
});
if (_left > widget.threshold ||
_left == 0 && widget.direction == AppinioSwiperDirection.right) {
_left == 0 && widget.direction == CardSwiperDirection.right) {
_swipedDirectionHorizontal = 1;
detectedDirection = AppinioSwiperDirection.right;
detectedDirection = CardSwiperDirection.right;
} else {
_swipedDirectionHorizontal = -1;
detectedDirection = AppinioSwiperDirection.left;
detectedDirection = CardSwiperDirection.left;
}
(_top <= 0) ? _swipedDirectionVertical = 1 : _swipedDirectionVertical = -1;
_horizontal = true;
@ -436,7 +436,7 @@ class _AppinioSwiperState extends State<AppinioSwiper>
_topAnimation = Tween<double>(
begin: _top,
end: (_top == 0)
? (widget.direction == AppinioSwiperDirection.bottom)
? (widget.direction == CardSwiperDirection.bottom)
? MediaQuery.of(context).size.height
: -MediaQuery.of(context).size.height
: (_top > widget.threshold)
@ -453,12 +453,12 @@ class _AppinioSwiperState extends State<AppinioSwiper>
).animate(_animationController);
});
if (_top > widget.threshold ||
_top == 0 && widget.direction == AppinioSwiperDirection.bottom) {
_top == 0 && widget.direction == CardSwiperDirection.bottom) {
_swipedDirectionVertical = -1;
detectedDirection = AppinioSwiperDirection.bottom;
detectedDirection = CardSwiperDirection.bottom;
} else {
_swipedDirectionVertical = 1;
detectedDirection = AppinioSwiperDirection.top;
detectedDirection = CardSwiperDirection.top;
}
(_left >= 0)
? _swipedDirectionHorizontal = 1
@ -547,34 +547,34 @@ class _AppinioSwiperState extends State<AppinioSwiper>
//for null safety
void emptyFunction() {}
void emptyFunctionIndex(int index, AppinioSwiperDirection direction) {}
void emptyFunctionIndex(int index, CardSwiperDirection direction) {}
void emptyFunctionBool(bool unswiped) {}
//to call the swipe or unswipe function from outside of the appinio swiper
class AppinioSwiperController extends ChangeNotifier {
AppinioSwiperState? state;
class CardSwiperController extends ChangeNotifier {
CardSwiperState? state;
//swipe the card by changing the status of the controller
void swipe() {
state = AppinioSwiperState.swipe;
state = CardSwiperState.swipe;
notifyListeners();
}
//swipe the card to the left side by changing the status of the controller
void swipeLeft() {
state = AppinioSwiperState.swipeLeft;
state = CardSwiperState.swipeLeft;
notifyListeners();
}
//swipe the card to the right side by changing the status of the controller
void swipeRight() {
state = AppinioSwiperState.swipeRight;
state = CardSwiperState.swipeRight;
notifyListeners();
}
//calls unswipe the card by changing the status of the controller
void unswipe() {
state = AppinioSwiperState.unswipe;
state = CardSwiperState.unswipe;
notifyListeners();
}
}
@ -595,6 +595,6 @@ class AppinioUnswipeCard {
});
}
enum AppinioSwiperState { swipe, swipeLeft, swipeRight, unswipe }
enum CardSwiperState { swipe, swipeLeft, swipeRight, unswipe }
enum AppinioSwiperDirection { none, left, right, top, bottom }
enum CardSwiperDirection { none, left, right, top, bottom }

View File

@ -1,4 +1,4 @@
name: swipeable_cards_stack
name: flutter_card_swiper
description: This is Tinder like swipeable cards package. You can add your own widgets to the stack, receive all four events, left, right, up and down. You can define your own business logic for each direction.
homepage: https://github.com/ricardodalarme/swipeable-cards-stack
issue_tracker: https://github.com/ricardodalarme/swipeable-cards-stack/issues