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.
 
 

575 lines
29 KiB

import 'package:flutter/material.dart';
import 'package:teso/Classes/API Clasess/ProximityCoupon.dart';
import 'package:provider/provider.dart';
import 'package:teso/Classes/CouponRateCalculator.dart';
import 'package:teso/providers/user_provider.dart';
import 'package:teso/Classes/API Clasess/CouponHead.dart';
import 'package:page_transition/page_transition.dart';
import 'package:teso/Pages/productView.dart';
import 'package:teso/Classes/API Clasess/CouponDetails.dart';
import 'package:teso/Classes/API Clasess/Product.dart';
import 'package:teso/util/SizeConfig.dart';
import 'package:teso/util/consts.dart';
Positioned buildActiveDiscountCoupon(
ProximityCoupon img,
double bottom,
double right,
double left,
double cardWidth,
double rotation,
double skew,
BuildContext context,
int flag,
Function swipeRight,
Function swipeLeft,
double worth,
Function calWorth) {
SizeConfig().init(context);
if (worth < img.lowerLimit) {
worth = img.lowerLimit;
}
return new Positioned(
bottom: bottom,
right: flag == 0
? right != 0.0
? right
: null
: null,
left: flag == 1
? right != 0.0
? right
: null
: null,
child: new Transform(
alignment: flag == 0 ? Alignment.bottomRight : Alignment.bottomLeft,
transform: new Matrix4.skewX(skew),
child: new RotationTransition(
turns: new AlwaysStoppedAnimation(
flag == 0 ? rotation / 360 : -rotation / 360),
child: Column(
children: [
new Row(
children: [
InkWell(
onTap: () async {
CouponsHead head = new CouponsHead();
head.businessId = img.business.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.targetID;
head.type = img.type;
CouponDetails details = new CouponDetails();
details.businessId = img.business.businessId;
details.countID = "null";
details.couponId = img.couponId;
details.expiration = img.expiration;
details.issuer = img.business;
details.lowerLimit = img.lowerLimit;
details.upperLimit = img.upperLimit;
details.quantity = img.quantity;
details.state = img.state;
details.type = img.type;
details.targetProduct = new Product();
details.targetProduct.businessID = details.businessId;
details.targetProduct.productImage = img.targetImage;
details.targetProduct.productName = img.targetName;
details.targetProduct.unitPrice = img.targetCost;
details.targetProduct.productDesc = img.tagretDescription;
Provider.of<UserProvider>(context, listen: false)
.viewCoupon(head);
Navigator.push(
context,
PageTransition(
type: PageTransitionType.rightToLeft,
child: ProductView(
couponDetails: details,
),
),
);
},
child: Container(
width: (MediaQuery.of(context).size.width * 0.75),
height: MediaQuery.of(context).size.height * 0.65,
margin: EdgeInsets.only(
left: MediaQuery.of(context).size.width * 0.12,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
color: Colors.white,
),
child: ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
child: Material(
elevation: 5.0,
child: Container(
width: (MediaQuery.of(context).size.width * 0.75),
height: MediaQuery.of(context).size.height * 0.68,
color: Colors.white,
child: Column(
children: [
Container(
width:
(MediaQuery.of(context).size.width * 0.75),
height:
MediaQuery.of(context).size.height * 0.50,
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: Colors.white,
image: img.upperLimit < 50.1
? DecorationImage(
fit: BoxFit.fill,
image: AssetImage(
"assets/images/blue.png"),
colorFilter: new ColorFilter.mode(
Color(0xFF0031ed)
.withOpacity(1.0),
BlendMode.multiply),
)
: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(
"assets/images/redBack.png"),
colorFilter: new ColorFilter.mode(
Colors.red.withOpacity(1.0),
BlendMode.multiply),
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(80),
bottomRight: Radius.circular(80),
),
),
child: Stack(
children: [
Align(
alignment: Alignment.topLeft,
child: Row(
children: [
Image(
width: 30,
image: AssetImage(
"assets/images/tesoCouponInsignia.png")),
SizedBox(
width: 5,
),
Text(
"TESO",
style: TextStyle(
color: Colors.white,
fontSize: 15),
),
],
),
),
Align(
alignment: Alignment.topCenter,
child: Container(
margin: EdgeInsets.only(
top: MediaQuery.of(context)
.size
.width *
0.125,
),
child: Column(
children: [
Text(
img.business.businessName,
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w700,
),
),
Container(
width: double.infinity,
margin: EdgeInsets.symmetric(
vertical: 10,
),
child: Center(
child: Text(
"VOUCHER",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 25,
fontWeight: FontWeight.w900,
),
),
),
),
],
),
),
),
Align(
alignment: Alignment.center,
child: Container(
height:
SizeConfig.safeBlockHorizontal * 16,
padding: EdgeInsets.all(4.5),
decoration: BoxDecoration(
border: Border.all(
color: Colors.white)),
child: Column(
children: [
Text(
"ORIGINAL PRICE : GH¢ " +
img.targetCost
.toStringAsFixed(2),
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: SizeConfig
.safeBlockHorizontal *
3,
),
),
Text(
"DISCOUNTED PRICE : GH¢ " +
(img.targetCost -
(img.targetCost *
(worth / 100)))
.toStringAsFixed(2),
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: SizeConfig
.safeBlockHorizontal *
3,
),
),
new Wrap(
direction: Axis.horizontal,
children: [
Image(
width: SizeConfig
.safeBlockHorizontal *
5,
image: AssetImage(
"assets/images/silver1.png"),
),
Container(
margin: EdgeInsets.only(
top: 5,
),
child: Text(
"SILVER COIN COST : ",
style: TextStyle(
color: Colors.white,
fontWeight:
FontWeight.bold,
fontSize: SizeConfig
.safeBlockHorizontal *
3,
),
),
),
Container(
margin: EdgeInsets.only(
top: 5,
),
child: Text(
CouponRateCalculator
.getRate(
img.targetCost *
(worth /
100))
.toString(),
style: TextStyle(
color: Colors.white,
fontWeight:
FontWeight.bold,
fontSize: SizeConfig
.safeBlockHorizontal *
3,
),
),
),
],
),
],
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.symmetric(
vertical: MediaQuery.of(context)
.size
.width *
0.15),
child: Text(
img.targetName.toUpperCase(),
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
Container(
padding: EdgeInsets.symmetric(
horizontal:
MediaQuery.of(context).size.width * 0.010,
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Container(
width: MediaQuery.of(context).size.width *
0.4,
height: 70,
padding: EdgeInsets.only(
top: 5,
),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
Container(
child: Text(
"Pay : GH¢ " +
(img.targetCost -
(img.targetCost *
(worth / 100)))
.toStringAsFixed(2) +
" only",
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
),
),
),
img.condition == 'none'
? Container()
: Container(
child: Text(
"Condition : " +
img.condition
.replaceAll(
'"', ""),
),
),
],
),
),
),
Container(
width:
SizeConfig.safeBlockHorizontal * 22,
height:
SizeConfig.safeBlockHorizontal * 22,
padding: EdgeInsets.all(2.5),
decoration: BoxDecoration(
border: Border.all(
color: Colors.red,
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(80),
topRight: Radius.circular(80),
bottomLeft: Radius.circular(80),
bottomRight: Radius.circular(80),
),
),
child: Container(
width:
SizeConfig.safeBlockHorizontal * 22,
height:
SizeConfig.safeBlockHorizontal * 22,
padding: EdgeInsets.all(2),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
border: Border.all(color: Colors.red),
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(
"assets/images/red.png"),
colorFilter: new ColorFilter.mode(
Colors.red.withOpacity(0.5),
BlendMode.overlay),
),
),
child: Center(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text(
worth.toStringAsFixed(1) + "%",
style: TextStyle(
color: Colors.white,
fontSize: SizeConfig
.safeBlockHorizontal *
6,
fontWeight: FontWeight.w900,
),
),
Container(
margin: EdgeInsets.only(
left: 22,
),
child: Text(
"OFF",
textAlign: TextAlign.end,
style: TextStyle(
color: Colors.white,
fontSize: SizeConfig
.safeBlockHorizontal *
4,
),
),
),
],
),
),
),
),
],
),
),
],
),
),
),
),
),
),
Container(
// width: SizeConfig.safeBlockHorizontal * 30,
height: SizeConfig.safeBlockVertical * 60,
// padding: EdgeInsets.all(SizeConfig.safeBlockVertical * 2),
child: new Column(
children: [
Container(
child: Text(
img.upperLimit.toStringAsFixed(1) + " %",
textAlign: TextAlign.center,
style: TextStyle(
foreground: Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Colors.blue,
),
),
),
Container(
height: SizeConfig.safeBlockVertical * 50,
child: new RotatedBox(
quarterTurns: 3,
child: Slider(
value: worth,
min: img.lowerLimit,
max: img.upperLimit,
divisions: 20,
activeColor: accentMain,
inactiveColor: darkAccent,
label: worth.toStringAsFixed(1) + "%",
onChanged: (double newValue) => calWorth(newValue),
),
),
),
Container(
child: Text(
img.lowerLimit.toString() + " %",
textAlign: TextAlign.center,
style: TextStyle(
foreground: Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Colors.blue,
),
),
),
],
),
)
],
),
SizedBox(
height: 20,
),
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[200],
padding: new EdgeInsets.all(10.0),
),
onPressed: () => swipeLeft(img),
child: new Container(
height: 30.0,
width: 100.0,
alignment: Alignment.center,
decoration: new BoxDecoration(
color: Colors.red[200],
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,
padding: new EdgeInsets.all(10.0),
),
onPressed: () => swipeRight(img),
child: new Container(
height: 30.0,
width: 100.0,
alignment: Alignment.center,
decoration: new BoxDecoration(
color: Colors.green,
borderRadius: new BorderRadius.circular(60.0),
),
child: new Text(
"Interested",
style: new TextStyle(color: Colors.white),
),
),
),
],
)
],
),
),
),
);
}