You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							274 lines
						
					
					
						
							11 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							274 lines
						
					
					
						
							11 KiB
						
					
					
				| import 'dart:math'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:teso/Classes/API Clasess/CouponDetails.dart'; | |
| import 'package:provider/provider.dart'; | |
| import 'package:teso/providers/user_provider.dart'; | |
| import 'package:teso/Classes/API Clasess/CouponHead.dart'; | |
| 
 | |
| Positioned buildCoupon( | |
|   CouponDetails img, | |
|   double bottom, | |
|   double right, | |
|   double left, | |
|   double cardWidth, | |
|   double rotation, | |
|   double skew, | |
|   BuildContext context, | |
|   Function dismissImg, | |
|   int flag, | |
|   Function addImg, | |
|   Function swipeRight, | |
|   Function swipeLeft, | |
|   String discount, | |
| ) { | |
|   img.productCost = img.targetProduct.unitPrice; | |
|   Size screenSize = MediaQuery.of(context).size; | |
|   return new Positioned( | |
|     bottom: 45.0 + bottom, | |
|     right: flag == 0 | |
|         ? right != 0.0 | |
|             ? right | |
|             : null | |
|         : null, | |
|     left: flag == 1 | |
|         ? right != 0.0 | |
|             ? right | |
|             : null | |
|         : null, | |
|     child: new Dismissible( | |
|       key: new Key(new Random().toString()), | |
|       crossAxisEndOffset: -0.3, | |
|       onResize: () {}, | |
|       onDismissed: (DismissDirection direction) { | |
| //          _swipeAnimation(); | |
|         if (direction == DismissDirection.endToStart) | |
|           dismissImg(img); | |
|         else | |
|           addImg(img); | |
|       }, | |
|       child: new Transform( | |
|         alignment: flag == 0 ? Alignment.bottomRight : Alignment.bottomLeft, | |
|         //transform: null, | |
|         transform: new Matrix4.skewX(skew), | |
|         //..rotateX(-math.pi / rotation), | |
|         child: new RotationTransition( | |
|           turns: new AlwaysStoppedAnimation( | |
|               flag == 0 ? rotation / 360 : -rotation / 360), | |
|           child: Column( | |
|             children: [ | |
|               InkWell( | |
|                 onTap: () async { | |
|                   CouponsHead head = new CouponsHead(); | |
|                   head.businessId = img.issuer.businessId; | |
|                   head.couponId = img.couponId; | |
|                   head.expiration = img.expiration; | |
|                   head.lower = img.lowerLimit; | |
|                   head.upper = img.upperLimit; | |
|                   head.quantity = img.quantity; | |
|                   head.state = img.state; | |
|                   head.targetProduct = img.targetProduct.productID; | |
|                   head.type = img.type; | |
|                   await Provider.of<UserProvider>(context, listen: false) | |
|                       .viewCoupon(head); | |
|                 }, | |
|                 child: new Container( | |
|                   margin: EdgeInsets.all(40), | |
|                   width: screenSize.width * 0.95, | |
|                   height: MediaQuery.of(context).size.height / 2, | |
|                   decoration: BoxDecoration( | |
|                     border: Border.all( | |
|                       color: Colors.grey, | |
|                       width: 0.5, | |
|                     ), | |
|                     borderRadius: BorderRadius.only( | |
|                       topRight: Radius.circular(30), | |
|                       topLeft: Radius.circular(30), | |
|                       bottomLeft: Radius.circular(30), | |
|                       bottomRight: Radius.circular(30), | |
|                     ), | |
|                   ), | |
|                   child: ClipRRect( | |
|                     borderRadius: BorderRadius.only( | |
|                       topLeft: Radius.circular(30.0), | |
|                       topRight: Radius.circular(30.0), | |
|                       bottomLeft: Radius.circular(30), | |
|                       bottomRight: Radius.circular(30), | |
|                     ), | |
|                     child: Material( | |
|                       elevation: 10.0, | |
|                       borderRadius: BorderRadius.circular(12.0), | |
|                       // shadowColor: Theme.of(context).backgroundColor, | |
|                       child: Container( | |
|                         height: MediaQuery.of(context).size.height / 2, | |
|                         decoration: BoxDecoration( | |
|                           gradient: LinearGradient( | |
|                             begin: Alignment.topCenter, | |
|                             end: Alignment.bottomCenter, | |
|                             colors: [ | |
|                               Color(0xFFfea404), | |
|                               Color(0xFFfd0a35), | |
|                             ], | |
|                             //stops: [0.1, 0.4, 0.7, 0.8], | |
|                           ), | |
|                         ), | |
|                         child: Column( | |
|                           children: [ | |
|                             Stack( | |
|                               children: [ | |
|                                 Align( | |
|                                   alignment: Alignment.topCenter, | |
|                                   child: Container( | |
|                                     width: double.infinity, | |
|                                     padding: | |
|                                         EdgeInsets.symmetric(horizontal: 15), | |
|                                     margin: EdgeInsets.symmetric(vertical: 15), | |
|                                     child: Center( | |
|                                       child: Text( | |
|                                         "Teso Discount Coupon", | |
|                                         style: TextStyle( | |
|                                           fontSize: 22, | |
|                                           color: Colors.white, | |
|                                           fontFamily: 'WickedGrit', | |
|                                         ), | |
|                                       ), | |
|                                     ), | |
|                                   ), | |
|                                 ), | |
|                                 Align( | |
|                                   alignment: Alignment.topRight, | |
|                                   child: Container( | |
|                                     decoration: BoxDecoration( | |
|                                       color: Colors.white38, | |
|                                       borderRadius: BorderRadius.only( | |
|                                         topRight: Radius.circular(30), | |
|                                         topLeft: Radius.circular(30), | |
|                                         bottomLeft: Radius.circular(30), | |
|                                         bottomRight: Radius.circular(30), | |
|                                       ), | |
|                                     ), | |
|                                     padding: EdgeInsets.all(10), | |
|                                     margin: EdgeInsets.only(right: 20, top: 35), | |
|                                     child: Text( | |
|                                       img.worth.toString() + "% off", | |
|                                       style: TextStyle(fontSize: 18), | |
|                                     ), | |
|                                   ), | |
|                                 ), | |
|                               ], | |
|                             ), | |
|                             Container( | |
|                               margin: EdgeInsets.all(8), | |
|                               width: double.infinity, | |
|                               child: Center( | |
|                                 child: Text( | |
|                                   img.targetProduct.productName, | |
|                                   style: TextStyle( | |
|                                       fontSize: 18, color: Colors.white), | |
|                                 ), | |
|                               ), | |
|                             ), | |
|                             Container( | |
|                               margin: EdgeInsets.all(8), | |
|                               width: double.infinity, | |
|                               child: Center( | |
|                                 child: Text( | |
|                                   "Item Original Price : " + | |
|                                       img.targetProduct.unitPrice.toString(), | |
|                                   style: TextStyle( | |
|                                       fontSize: 18, color: Colors.white), | |
|                                 ), | |
|                               ), | |
|                             ), | |
|                             Container( | |
|                               margin: EdgeInsets.all(10), | |
|                               width: double.infinity, | |
|                               child: Center( | |
|                                 child: Text( | |
|                                   "Item Discounted Price : " + discount, | |
|                                   style: TextStyle( | |
|                                       fontSize: 18, color: Colors.white), | |
|                                 ), | |
|                               ), | |
|                             ), | |
|                             Container( | |
|                               width: double.infinity, | |
|                               child: new Wrap( | |
|                                 direction: Axis.horizontal, | |
|                                 children: [ | |
|                                   Align( | |
|                                     alignment: Alignment.bottomCenter, | |
|                                     child: Container( | |
|                                       child: Image( | |
|                                         height: 80, | |
|                                         image: AssetImage( | |
|                                             "assets/images/tesoCouponInsignia.png"), | |
|                                       ), | |
|                                     ), | |
|                                   ), | |
|                                 ], | |
|                               ), | |
|                             ), | |
|                           ], | |
|                         ), | |
|                       ), | |
|                     ), | |
|                   ), | |
|                 ), | |
|               ), | |
|               new Wrap( | |
|                 alignment: WrapAlignment.center, | |
|                 runSpacing: 10, | |
|                 spacing: 10, | |
|                 crossAxisAlignment: WrapCrossAlignment.center, | |
|                 children: <Widget>[ | |
|                   new ElevatedButton(style:ElevatedButton.styleFrom( | |
|                     shape: RoundedRectangleBorder( | |
|                       borderRadius: BorderRadius.circular(18.0), | |
|                     ), | |
|                     primary: Colors.red, | |
|                     padding: new EdgeInsets.all(10.0),), | |
|                     onPressed: swipeLeft, | |
|                     child: new Container( | |
|                       height: 30.0, | |
|                       width: 100.0, | |
|                       alignment: Alignment.center, | |
|                       decoration: new BoxDecoration( | |
|                         color: Colors.red, | |
|                         borderRadius: new BorderRadius.circular(60.0), | |
|                       ), | |
|                       child: new Text( | |
|                         "Not Interested", | |
|                         style: new TextStyle(color: Colors.white), | |
|                       ), | |
|                     ), | |
|                   ), | |
|                  new ElevatedButton(style:ElevatedButton.styleFrom( | |
|                     shape: RoundedRectangleBorder( | |
|                       borderRadius: BorderRadius.circular(18.0), | |
|                     ), | |
|                     primary: Colors.green[200], | |
|                     padding: new EdgeInsets.all(10.0),), | |
|                     onPressed: swipeRight, | |
|                     child: new Container( | |
|                       height: 30.0, | |
|                       width: 100.0, | |
|                       alignment: Alignment.center, | |
|                       decoration: new BoxDecoration( | |
|                         color: Colors.green[200], | |
|                         borderRadius: new BorderRadius.circular(60.0), | |
|                       ), | |
|                       child: new Text( | |
|                         "Redeem", | |
|                         style: new TextStyle(color: Colors.white), | |
|                       ), | |
|                     ), | |
|                   ), | |
|                 ], | |
|               ) | |
|             ], | |
|           ), | |
|         ), | |
|       ), | |
|     ), | |
|   ); | |
| }
 | |
| 
 |