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.

377 lines
13 KiB

3 years ago
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart';
import 'package:teso/Classes/API%20Clasess/CouponDetails.dart';
import 'package:teso/util/consts.dart';
class SuccessfullyRedeemed extends StatefulWidget {
final CouponDetails couponDetails;
final int? returns;
3 years ago
const SuccessfullyRedeemed({
Key? key,
required this.couponDetails,
3 years ago
this.returns,
}) : super(key: key);
@override
_SuccessfullyRedeemedState createState() => _SuccessfullyRedeemedState();
}
class _SuccessfullyRedeemedState extends State<SuccessfullyRedeemed> {
var timestamp;
@override
void initState() {
super.initState();
timestamp = Jiffy(DateTime.now().toString()).yMMMMEEEEdjm;
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: ListView(
scrollDirection: Axis.vertical,
children: [
Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.only(
top: 20,
),
height: 200,
child: Center(
child: Container(
width: 200,
height: 200,
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: CachedNetworkImage(
imageUrl: widget.couponDetails.targetProduct != null
? productURL +
widget.couponDetails.targetProduct!.productImage!
3 years ago
: "",
imageBuilder: (context, imageProvider) => Image(
width: MediaQuery.of(context).size.width * 0.28,
height: 110,
fit: BoxFit.fill,
image: imageProvider,
),
),
),
),
),
),
SizedBox(
height: 20,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: new RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 14.0,
color: Theme.of(context).primaryColorLight,
),
children: <TextSpan>[
new TextSpan(
text: "Product ID : ",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
new TextSpan(
text: widget.couponDetails.targetProduct!.productID),
3 years ago
],
),
),
),
),
SizedBox(
height: 10,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: new RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 14.0,
color: Theme.of(context).primaryColorLight,
),
children: <TextSpan>[
new TextSpan(
text: "Product Name : ",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
new TextSpan(
text: widget.couponDetails.targetProduct!.productName),
3 years ago
],
),
),
),
),
SizedBox(
height: 10,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: new RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 14.0,
color: Theme.of(context).primaryColorLight,
),
children: <TextSpan>[
new TextSpan(
text: "Shop Name : ",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
new TextSpan(
text: widget.couponDetails.issuer!.businessName),
3 years ago
],
),
),
),
),
SizedBox(
height: 10,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: new RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 14.0,
color: Theme.of(context).primaryColorLight,
),
children: <TextSpan>[
new TextSpan(
text: "Coupon ID : ",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
new TextSpan(text: widget.couponDetails.couponId),
],
),
),
),
),
SizedBox(
height: 10,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: new RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 14.0,
color: Theme.of(context).primaryColorLight,
),
children: <TextSpan>[
new TextSpan(
text: "Timestamp : ",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
new TextSpan(text: timestamp),
],
),
),
),
),
SizedBox(
height: 10,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: new RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 14.0,
color: Theme.of(context).primaryColorLight,
),
children: <TextSpan>[
new TextSpan(
text: "Product Cost : GH¢ ",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
new TextSpan(
text: widget.couponDetails.productCost!
3 years ago
.toStringAsFixed(2)),
],
),
),
),
),
SizedBox(
height: 10,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: new RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 14.0,
color: Theme.of(context).primaryColorLight,
),
children: <TextSpan>[
new TextSpan(
text: "Discount : GH¢ ",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
new TextSpan(
text: (widget.couponDetails.productCost! *
(widget.couponDetails.worth! / 100))
3 years ago
.toStringAsFixed(2),
style: new TextStyle(
color: Colors.green,
)),
],
),
),
),
),
SizedBox(
height: 10,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: new RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 14.0,
color: Theme.of(context).primaryColorLight,
),
children: <TextSpan>[
new TextSpan(
text: "Coin Refund : ",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
new TextSpan(text: widget.returns.toString()),
],
),
),
),
),
SizedBox(
height: 10,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: new RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 14.0,
color: Theme.of(context).primaryColorLight,
),
children: <TextSpan>[
new TextSpan(
text: "Amount Due : GH¢ ",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
new TextSpan(
text: (widget.couponDetails.productCost! -
(widget.couponDetails.productCost! *
(widget.couponDetails.worth! / 100)))
3 years ago
.toStringAsFixed(2),
style: new TextStyle(
color: Colors.red,
)),
],
),
),
),
),
Container(
child: Icon(
Icons.check_circle,
color: Colors.green,
size: 30,
),
),
SizedBox(
height: 10,
),
Container(
width: MediaQuery.of(context).size.width,
child: Center(
child: Text(
"verified",
style: TextStyle(
color: Colors.green,
),
),
),
),
SizedBox(
height: 20,
),
Container(
width: double.infinity,
child: Align(
alignment: Alignment.center,
child: Container(
width: 100,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(20.0),
),
),
primary: accentMain,
),
onPressed: () => Navigator.pop(context),
child: Text("Close"),
),
),
),
),
],
),
),
);
}
}