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.
 
 

275 lines
12 KiB

import 'dart:math';
import 'package:flutter/material.dart';
import 'package:teso/Classes/API Clasess/ProximityCoupon.dart';
import 'package:teso/util/consts.dart';
Positioned activeCard(
ProximityCoupon 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,
double selectedDiscount) {
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: () {
//print("here");
// setState(() {
// var i = data.removeLast();
// data.insert(0, i);
// });
},
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: new Hero(
tag: img.couponId,
child: new GestureDetector(
// onTap: () {
// // Navigator.push(
// // context,
// // new MaterialPageRoute(
// // builder: (context) => new DetailPage(type: img)));
// Navigator.of(context).push(new PageRouteBuilder(
// pageBuilder: (_, __, ___) => new DetailPage(type: img),
// ));
// },
child: Column(
children: [
new Container(
margin: EdgeInsets.all(40),
width: screenSize.width * 0.93,
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: [accentMain, darkAccent],
//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(
selectedDiscount.toString() + "% off",
style: TextStyle(fontSize: 18),
),
),
),
],
),
Container(
margin: EdgeInsets.all(8),
width: double.infinity,
child: Center(
child: Text(
img.targetName,
style: TextStyle(
fontSize: 18, color: Colors.white),
),
),
),
Container(
margin: EdgeInsets.all(8),
width: double.infinity,
child: Center(
child: Text(
"Item Original Price : GH¢ " +
img.targetCost.toString(),
style: TextStyle(
fontSize: 18, color: Colors.white),
),
),
),
Container(
margin: EdgeInsets.all(10),
width: double.infinity,
child: Center(
child: Text(
"Item Discounted Price : GH¢ " + 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(
"Interested",
style: new TextStyle(color: Colors.white),
),
),
),
],
)
],
),
),
),
),
),
),
);
}