updating sequence of flows

This commit is contained in:
2025-11-02 19:49:25 +02:00
parent 087a9aa4bc
commit 895925d32f
9 changed files with 149 additions and 179 deletions

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:qpay/screens/gateway/gateway_controller.dart';
import 'package:qpay/screens/transaction_controller.dart';
@@ -6,6 +7,7 @@ import 'package:go_router/go_router.dart';
import 'package:qpay/screens/receipt/receipt_controller.dart';
import 'package:share_plus/share_plus.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:timeago/timeago.dart' as timeago;
import 'package:widgets_to_image/widgets_to_image.dart';
class ReceiptScreen extends StatefulWidget {
@@ -96,6 +98,11 @@ class _ReceiptScreenState extends State<ReceiptScreen>
receiptController.setLoading(true);
await gatewayController.poll(receiptController.model.receiptData?["id"]);
if(gatewayController.model.status == "SUCCESS"){
receiptController.getReceiptData(transactionController.model.receiptData?["id"]);
if(transactionController.model.receiptData?["pollingStatus"]) {
receiptController.setLoading(false);
return; // no need to proceed if we've already polled successfully
}
await _retry();
}
receiptController.setLoading(false);
@@ -253,21 +260,22 @@ class _ReceiptScreenState extends State<ReceiptScreen>
CrossAxisAlignment.center,
children: [
SizedBox(height: 5),
// receiptController
// .model
// .receiptData?["providerImage"] !=
// null
// ? Image.asset(
// 'assets/${receiptController.model.receiptData?["providerImage"] ?? ''}',
// width: 50,
// )
// : SizedBox.shrink(),
Text(
receiptController
.model
.receiptData?["billName"] ??
"",
style: TextStyle(fontSize: 14),
style: TextStyle(fontSize: 16),
),
Text(
receiptController
.model
.receiptData?["createdAt"] != null ?
DateFormat.yMMMd().add_jm().format(DateTime.parse(
receiptController
.model
.receiptData?["createdAt"])) : "",
style: TextStyle(fontSize: 15),
),
],
),
@@ -602,43 +610,47 @@ class _ReceiptScreenState extends State<ReceiptScreen>
),
],
),
const SizedBox(height: 10),
if(receiptController.model.receiptData?["integrationStatus"] != "SUCCESS" &&
receiptController.model.receiptData?["paymentStatus"] == "SUCCESS")
Skeletonizer(
enabled:
receiptController
.model
.isLoading,
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
"Additional action",
style: TextStyle(
fontSize: 16,
fontWeight:
FontWeight.bold,
),
),
Expanded(
child: Text("Billing account update failed, please tap on retry to try again",
Column(
children: [
const SizedBox(height: 10),
Skeletonizer(
enabled:
receiptController
.model
.isLoading,
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
"Additional action",
style: TextStyle(
fontSize: 16,
color: Theme.of(
context,
).colorScheme.primary,
fontWeight:
FontWeight.bold,
),
textAlign: TextAlign.end,
softWrap: true,
),
),
],
Expanded(
child: Text("Billing account update failed, please tap on Retry to try again",
style: TextStyle(
fontSize: 16,
color: Theme.of(
context,
).colorScheme.primary,
),
textAlign: TextAlign.end,
softWrap: true,
),
),
],
),
),
),
],
),
SizedBox(height: 10,),
Skeletonizer(
@@ -767,39 +779,44 @@ class _ReceiptScreenState extends State<ReceiptScreen>
.model
.receiptData?["additionalData"]
.map<Widget>((data) {
return Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
data["name"] ??
"",
style: TextStyle(
fontSize:
16,
fontWeight:
FontWeight
.bold,
return Skeletonizer(
enabled: receiptController
.model
.isLoading,
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
data["name"] ??
"",
style: TextStyle(
fontSize:
16,
fontWeight:
FontWeight
.bold,
),
),
),
Text(
data["value"] ??
"",
style:
TextStyle(
fontSize:
16,
),
),
],
),
const SizedBox(
height: 10,
),
],
Text(
data["value"] ??
"",
style:
TextStyle(
fontSize:
16,
),
),
],
),
const SizedBox(
height: 10,
),
],
),
);
})
.toList(),