refactor(package): split the code into more files
This commit is contained in:
parent
fd0ff6cfd6
commit
3be74fff19
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_card_swiper/card_swiper.dart';
|
||||
import 'package:flutter_card_swiper/flutter_card_swiper.dart';
|
||||
|
||||
class ExampleButton extends StatelessWidget {
|
||||
final Function onTap;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import 'dart:developer';
|
|||
import 'package:example/example_candidate_model.dart';
|
||||
import 'package:example/example_card.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_card_swiper/card_swiper.dart';
|
||||
import 'package:flutter_card_swiper/flutter_card_swiper.dart';
|
||||
|
||||
import 'example_buttons.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
export 'package:flutter_card_swiper/src/card_swiper.dart';
|
||||
export 'package:flutter_card_swiper/src/card_swiper_controller.dart';
|
||||
export 'package:flutter_card_swiper/src/enums.dart';
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_card_swiper/src/card_swiper_controller.dart';
|
||||
import 'package:flutter_card_swiper/src/enums.dart';
|
||||
|
||||
class CardSwiper extends StatefulWidget {
|
||||
/// list of widgets for the swiper
|
||||
|
|
@ -402,32 +404,3 @@ class _CardSwiperState extends State<CardSwiper>
|
|||
//for null safety
|
||||
void emptyFunction() {}
|
||||
void emptyFunctionIndex(int index, CardSwiperDirection direction) {}
|
||||
|
||||
//to call the swipe function from outside of the CardSwiper
|
||||
class CardSwiperController extends ChangeNotifier {
|
||||
CardSwiperState? state;
|
||||
|
||||
//swipe the card by changing the status of the controller
|
||||
void swipe() {
|
||||
state = CardSwiperState.swipe;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
//swipe the card to the left side by changing the status of the controller
|
||||
void swipeLeft() {
|
||||
state = CardSwiperState.swipeLeft;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
//swipe the card to the right side by changing the status of the controller
|
||||
void swipeRight() {
|
||||
state = CardSwiperState.swipeRight;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
enum CardSwiperState { swipe, swipeLeft, swipeRight }
|
||||
|
||||
enum CardSwiperDirection { none, left, right, top, bottom }
|
||||
|
||||
enum SwipeType { none, swipe, back }
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
//to call the swipe function from outside of the CardSwiper
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_card_swiper/src/enums.dart';
|
||||
|
||||
class CardSwiperController extends ChangeNotifier {
|
||||
CardSwiperState? state;
|
||||
|
||||
//swipe the card by changing the status of the controller
|
||||
void swipe() {
|
||||
state = CardSwiperState.swipe;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
//swipe the card to the left side by changing the status of the controller
|
||||
void swipeLeft() {
|
||||
state = CardSwiperState.swipeLeft;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
//swipe the card to the right side by changing the status of the controller
|
||||
void swipeRight() {
|
||||
state = CardSwiperState.swipeRight;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
enum CardSwiperState { swipe, swipeLeft, swipeRight }
|
||||
|
||||
enum CardSwiperDirection { none, left, right, top, bottom }
|
||||
|
||||
enum SwipeType { none, swipe, back }
|
||||
Loading…
Reference in New Issue