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.
319 lines
14 KiB
319 lines
14 KiB
3 years ago
|
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';
|
||
|
import 'dart:math' as math;
|
||
|
import 'package:teso/util/consts.dart';
|
||
|
import 'package:page_transition/page_transition.dart';
|
||
|
import 'package:teso/Pages/productView.dart';
|
||
|
import 'package:teso/Pages/Sub_Pages/@Generic/RedeemingCoupon.dart';
|
||
|
|
||
|
buildActiveFreebieCoupon(
|
||
|
CouponDetails img, double cardWidth, BuildContext context) {
|
||
|
img.productCost = img.targetProduct.unitPrice;
|
||
|
return Container(
|
||
|
width: (MediaQuery.of(context).size.width * 0.80) - cardWidth,
|
||
|
height: MediaQuery.of(context).size.height * 0.68,
|
||
|
margin: EdgeInsets.symmetric(
|
||
|
vertical: MediaQuery.of(context).size.width * 0.10),
|
||
|
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);
|
||
|
Navigator.push(
|
||
|
context,
|
||
|
PageTransition(
|
||
|
type: PageTransitionType.rightToLeft,
|
||
|
child: ProductView(
|
||
|
couponDetails: img,
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
},
|
||
|
child: Container(
|
||
|
width: (MediaQuery.of(context).size.width * 0.80) - cardWidth,
|
||
|
height: MediaQuery.of(context).size.height * 0.65,
|
||
|
margin: EdgeInsets.only(
|
||
|
left: MediaQuery.of(context).size.width * 0.1,
|
||
|
),
|
||
|
child: Material(
|
||
|
elevation: 5.0,
|
||
|
child: Container(
|
||
|
width: (MediaQuery.of(context).size.width * 0.80) - cardWidth,
|
||
|
height: MediaQuery.of(context).size.height * 0.65,
|
||
|
color: Colors.white,
|
||
|
child: Column(
|
||
|
children: [
|
||
|
Container(
|
||
|
width: (MediaQuery.of(context).size.width * 0.80) -
|
||
|
cardWidth,
|
||
|
height: MediaQuery.of(context).size.height * 0.50,
|
||
|
padding: EdgeInsets.all(8.0),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
image: DecorationImage(
|
||
|
fit: BoxFit.fill,
|
||
|
image: AssetImage("assets/images/grey.png"),
|
||
|
colorFilter: new ColorFilter.mode(
|
||
|
tesoAsh.withOpacity(1.0), BlendMode.overlay),
|
||
|
),
|
||
|
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.black,
|
||
|
fontSize: 15,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
Align(
|
||
|
alignment: Alignment.topCenter,
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.only(
|
||
|
top: MediaQuery.of(context).size.width * 0.125,
|
||
|
),
|
||
|
child: Column(
|
||
|
children: [
|
||
|
Text(
|
||
|
img.issuer.businessName.toUpperCase(),
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontSize: 18,
|
||
|
fontWeight: FontWeight.w700,
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
width: double.infinity,
|
||
|
margin: EdgeInsets.symmetric(
|
||
|
vertical: 10,
|
||
|
),
|
||
|
child: Center(
|
||
|
child: Text(
|
||
|
"FREEBIE",
|
||
|
textAlign: TextAlign.center,
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontSize: 25,
|
||
|
fontWeight: FontWeight.w900,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
Align(
|
||
|
alignment: Alignment.center,
|
||
|
child: Container(
|
||
|
height: MediaQuery.of(context).size.width * 0.18,
|
||
|
padding: EdgeInsets.all(5),
|
||
|
decoration: BoxDecoration(
|
||
|
border:
|
||
|
Border.all(color: Colors.black, width: 2),
|
||
|
),
|
||
|
child: Column(
|
||
|
children: [
|
||
|
Text(
|
||
|
"ORIGINAL PRICE : GH¢ " +
|
||
|
img.targetProduct.unitPrice
|
||
|
.toStringAsFixed(2),
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
),
|
||
|
),
|
||
|
Text(
|
||
|
"DISCOUNTED PRICE : GH¢ 0.00",
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
Align(
|
||
|
alignment: Alignment.bottomCenter,
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.symmetric(
|
||
|
vertical:
|
||
|
MediaQuery.of(context).size.width * 0.15),
|
||
|
child: Text(
|
||
|
img.targetProduct.productName.toUpperCase(),
|
||
|
textAlign: TextAlign.center,
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontSize: 20,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
padding: EdgeInsets.symmetric(
|
||
|
horizontal: MediaQuery.of(context).size.width * 0.025,
|
||
|
),
|
||
|
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(
|
||
|
"Price : GH¢ 0.00 only",
|
||
|
style: TextStyle(
|
||
|
color: Colors.red,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
img.condition == 'none'
|
||
|
? Container()
|
||
|
: Container(
|
||
|
child: Text(
|
||
|
"Condition : " + img.condition,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
width: 70,
|
||
|
height: 70,
|
||
|
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: 70,
|
||
|
height: 70,
|
||
|
//padding: EdgeInsets.all(2.5),
|
||
|
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: Transform.rotate(
|
||
|
angle: -math.pi / 4,
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.symmetric(
|
||
|
vertical: 20, horizontal: 5),
|
||
|
height: 10,
|
||
|
child: Text(
|
||
|
"FREE!!!",
|
||
|
style: TextStyle(
|
||
|
color: Colors.white,
|
||
|
fontSize: 16.2,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
SizedBox(
|
||
|
height: 20,
|
||
|
),
|
||
|
new ElevatedButton(
|
||
|
style: ElevatedButton.styleFrom(
|
||
|
shape: RoundedRectangleBorder(
|
||
|
borderRadius: BorderRadius.circular(18.0),
|
||
|
),
|
||
|
primary: tesoGold,
|
||
|
padding: new EdgeInsets.all(10.0),
|
||
|
),
|
||
|
onPressed: () => Navigator.pushReplacement(
|
||
|
context,
|
||
|
PageTransition(
|
||
|
child: RedeemingCoupon(
|
||
|
couponDetails: img,
|
||
|
),
|
||
|
type: PageTransitionType.fade)),
|
||
|
child: new Container(
|
||
|
height: 30.0,
|
||
|
width: 100.0,
|
||
|
alignment: Alignment.center,
|
||
|
decoration: new BoxDecoration(
|
||
|
borderRadius: new BorderRadius.circular(60.0),
|
||
|
),
|
||
|
child: new Text(
|
||
|
"Redeem",
|
||
|
style: new TextStyle(color: Colors.white),
|
||
|
),
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|