Closed Muntasir2001 closed 11 months ago
Hey @Muntasir2001 , please use the latest version of Appinio Swiper and pass any combination of swiperOptions
if you want to restrict swipe in a particular direction.
@khanmujeeb687 I guess OP wants to go back in the list when swipes left; not restrict swipe direction. This is also my question.
Yep thats what I actually wanted to know. Not sure if that is possible with this package.
If you think about it is not conceptually possible with a deck of card style UI. As next card in list will always be revealed regardless of swipe direction. The closest thing I can think about is a 3D carousel style UI, like some old music apps, which may not be in fashion anymore. I ended up doing it with a traditional PageView. You can also make it an endless loop using a package like loop_page_view.
Hey @Muntasir2001 , please try this solution. This should solve the issue for you.
onSwipe: (int index, AppinioSwiperDirection direction) async{ if (direction == AppinioSwiperDirection.left) { await Future.delayed(const Duration(milliseconds: 500)); controller.unswipe(); } },
Hi @khanmujeeb687
Just tried this, did not work
Could you please share the code snippet ?
On Sat 19. Aug 2023 at 12:39 PM, noobdev54 @.***> wrote:
Hi @khanmujeeb687 https://github.com/khanmujeeb687
Just tried this, did not work
— Reply to this email directly, view it on GitHub https://github.com/appinioGmbH/flutter_packages/issues/122#issuecomment-1684915325, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOBJ2JBMGEAIY6SCE7N64SDXWCJV3ANCNFSM6AAAAAA2NMUOPI . You are receiving this because you were mentioned.Message ID: @.***>
Sure (ignore the weird spacing/indentation, thats not how it is in the actual code)
AppinioSwiper(
cardsCount: reminders.getReminders().length,
loop: true,
controller: controller,
swipeOptions: AppinioSwipeOptions.horizontal,
maxAngle: 0,
onSwiping: (AppinioSwiperDirection direction) {
// debugPrint(direction.toString());
if (direction.name == 'left') {
controller.unswipe();
}
},
unlimitedUnswipe: true,
onSwipe: _swipe,
cardsBuilder: (BuildContext context, int index) {
return Container(
alignment: Alignment.center,
child: getReminderCard(index),
);
},
),
),
Widget getReminderCard(int index) {
return (ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.network(
reminders.getReminder(index),
width: 600,
height: 800,
fit: BoxFit.cover,
),
));
}
void _swipe(int index, AppinioSwiperDirection direction) async {
debugPrint(direction.name);
debugPrint("indexxs $index");
rIndex = index;
// if (direction.name == 'left') {
// controller.unswipe();
// }
if (direction == AppinioSwiperDirection.left) {
await Future.delayed(const Duration(milliseconds: 500));
controller.unswipe();
}
}
yeah, same thing for me. this feature would be super useful!
Hey @Muntasir2001 , I tried your code and here is a short clip and code, It works for me. Are you using stateless widget?
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return const CupertinoApp(
debugShowCheckedModeBanner: false,
home: Example(),
);
}
}
class Example extends StatefulWidget {
const Example({
Key? key,
}) : super(key: key);
@override
State<Example> createState() => _ExamplePageState();
}
class _ExamplePageState extends State<Example> {
final AppinioSwiperController controller = AppinioSwiperController();
void unSwipe(){
controller.unswipe();
}
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: Column(
children: [
const SizedBox(
height: 50,
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.75,
child: AppinioSwiper(
cardsCount: 10,
loop: true,
controller: controller,
swipeOptions: const AppinioSwipeOptions.symmetric(horizontal: true),
maxAngle: 0,
onSwiping: (AppinioSwiperDirection direction) {
// debugPrint(direction.toString());
if (direction.name == 'left') {
controller.unswipe();
}
},
unlimitedUnswipe: true,
onSwipe: _swipe,
cardsBuilder: (BuildContext context, int index) {
return Container(
alignment: Alignment.center,
child: getReminderCard(index),
);
},
),
),
],
),
);
}
Widget getReminderCard(int index) {
return (ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.network(
"https://wallpapers.com/images/high/indian-youtube-star-carryminati-hd-rtpd3i72brgjm0q2.webp",
width: 600,
height: 800,
fit: BoxFit.cover,
),
));
}
void _swipe(int index, AppinioSwiperDirection direction) async {
debugPrint(direction.name);
debugPrint("indexxs $index");
// if (direction.name == 'left') {
// controller.unswipe();
// }
if (direction == AppinioSwiperDirection.left) {
await Future.delayed(const Duration(milliseconds: 500));
controller.unswipe();
}
}
}```
Hi,
I was wondering how to unswipe when swiped left. I tried to use some hacky ways to tackle this but it didn't work. This is my code right now.