Skip to content

Commit

Permalink
Added Tinder-like page for liking products
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Sep 12, 2023
1 parent 113a47a commit 5bb9800
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions lib/pages/tinder_like_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_tindercard/flutter_tindercard.dart';
import 'package:eccomernce/providers/products_provider.dart';

class TinderLikePage extends StatelessWidget {
static const String id = 'tinder_like_page';

@override
Widget build(BuildContext context) {
final productsData = Provider.of<ProductsProvider>(context);
final products = productsData.items;

CardController controller;

return Scaffold(
appBar: AppBar(
title: Text('Tinder Like Page'),
),
body: Center(
child: Container(
height: MediaQuery.of(context).size.height * 0.6,
child: TinderSwapCard(
swipeUp: true,
swipeDown: true,
orientation: AmassOrientation.BOTTOM,
totalNum: products.length,
stackNum: 3,
swipeEdge: 4.0,
maxWidth: MediaQuery.of(context).size.width * 0.9,
maxHeight: MediaQuery.of(context).size.width * 0.9,
minWidth: MediaQuery.of(context).size.width * 0.8,
minHeight: MediaQuery.of(context).size.width * 0.8,
cardBuilder: (context, index) => Card(
child: Column(
children: <Widget>[
Image.network(products[index].imageUrl),
ListTile(
title: Text(products[index].title),
subtitle: Text(products[index].description),
),
],
),
),
cardController: controller = CardController(),
swipeUpdateCallback:
(DragUpdateDetails details, Alignment align) {
if (align.x < 0) {
//Card is swiped left
} else if (align.x > 0) {
//Card is swiped right
productsData.likeProduct(products[index].id);
}
},
swipeCompleteCallback:
(CardSwipeOrientation orientation, int index) {
// Get information about the swiped card's orientation and index
},
),
),
),
);
}
}

0 comments on commit 5bb9800

Please sign in to comment.