98 lines
2.3 KiB
Dart
98 lines
2.3 KiB
Dart
import 'package:flutter_card_swiper/card_swiper.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ExampleButton extends StatelessWidget {
|
|
final Function onTap;
|
|
final Widget child;
|
|
|
|
const ExampleButton({
|
|
required this.onTap,
|
|
required this.child,
|
|
Key? key,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: () => onTap(),
|
|
child: child,
|
|
);
|
|
}
|
|
}
|
|
|
|
//swipe card to the right side
|
|
Widget swipeRightButton(CardSwiperController controller) {
|
|
return ExampleButton(
|
|
onTap: () => controller.swipeRight(),
|
|
child: Container(
|
|
height: 60,
|
|
width: 60,
|
|
decoration: BoxDecoration(
|
|
color: CupertinoColors.activeGreen,
|
|
borderRadius: BorderRadius.circular(50),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: CupertinoColors.activeGreen.withOpacity(0.9),
|
|
spreadRadius: -10,
|
|
blurRadius: 20,
|
|
offset: const Offset(0, 20), // changes position of shadow
|
|
),
|
|
],
|
|
),
|
|
alignment: Alignment.center,
|
|
child: const Icon(
|
|
Icons.check,
|
|
color: CupertinoColors.white,
|
|
size: 40,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
//swipe card to the left side
|
|
Widget swipeLeftButton(CardSwiperController controller) {
|
|
return ExampleButton(
|
|
onTap: () => controller.swipeLeft(),
|
|
child: Container(
|
|
height: 60,
|
|
width: 60,
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFFF3868),
|
|
borderRadius: BorderRadius.circular(50),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: const Color(0xFFFF3868).withOpacity(0.9),
|
|
spreadRadius: -10,
|
|
blurRadius: 20,
|
|
offset: const Offset(0, 20), // changes position of shadow
|
|
),
|
|
],
|
|
),
|
|
alignment: Alignment.center,
|
|
child: const Icon(
|
|
Icons.close,
|
|
color: CupertinoColors.white,
|
|
size: 40,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
//unswipe card
|
|
Widget unswipeButton(CardSwiperController controller) {
|
|
return ExampleButton(
|
|
onTap: () => controller.unswipe(),
|
|
child: Container(
|
|
height: 60,
|
|
width: 60,
|
|
alignment: Alignment.center,
|
|
child: const Icon(
|
|
Icons.rotate_left_rounded,
|
|
color: CupertinoColors.systemGrey2,
|
|
size: 40,
|
|
),
|
|
),
|
|
);
|
|
}
|