Commit eda93267 authored by Izol's avatar Izol

bug fixing transaction cek status , get qr

added validation cekstatus get qr #1
parent 7378ac15
......@@ -81,6 +81,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
late Timer? timer;
late Timer? timerPage;
bool isShowingDialog = false;
bool isProcessGet = false;
bool isProcessCheck = false;
late ConnectivityResult _connectivityResult;
Color _statusColor1 = Colors.grey;
Color _statusColor2 = Colors.grey;
......@@ -133,7 +135,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
bool isHitApi = false;
bool _isLoading = false;
@override
void initState() {
super.initState();
......@@ -429,7 +430,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title: 'Maaf wristband anda tidak dapat digunakan untuk isi saldo',
title:
'Maaf wristband anda tidak dapat digunakan untuk isi saldo',
desc: "Sorry, your card cannot be used to top up",
btnOkOnPress: () {
setState(() {
......@@ -591,10 +593,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
),
).show().then((value) {
Navigator.of(context).pop();
setState(() => isProcessCheck = false);
countMax = 0;
checkCountZero = false;
timer?.cancel();
isShowingDialog = true;
trxId = "";
reffNo = "";
isShowingDialog = true;
_showTap();
tapDial();
});
......@@ -627,18 +633,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
Map<String, dynamic> response =
await ServiceApi.statusQris(body, PreferencesHelper.getString("mid"));
if (response['response']['code'].toString() == "200") {
if (response['data']['status']
.toString()
.toLowerCase()
.contains('paid') ||
response['data']['status']
.toString()
.toLowerCase()
.contains('success') ||
response['data']['status']
.toString()
.toLowerCase()
.contains('settlement')) {
String status = response['data']['status'].toString().toLowerCase();
if (status.contains('paid') ||
status.contains('success') ||
status.contains('settlement')) {
Navigator.pop(context);
//TODO: getcard
tapBalance();
......@@ -750,6 +748,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
).show().then((value) {
Navigator.of(context).pop();
countMax = 0;
setState(() => isProcessCheck = false);
checkCountZero = false;
timer?.cancel();
isShowingDialog = true;
......@@ -945,7 +944,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
int _minDuration = 3;
late ValueNotifier<int> idleDuration;
// void tapIdle() {
// int duration = int.parse(idle);
// idleDuration.value =
......@@ -1060,7 +1058,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
});
}
void tapBalance() async {
Future.delayed(const Duration(milliseconds: 500), () async {
// await StartService.initLibrary();
......@@ -1094,7 +1091,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "Error Get Card Type"){
} else if (isTap == "Error Get Card Type") {
print("Error Get Card Type");
await StartService.initLibrary();
AwesomeDialog(
......@@ -1119,7 +1116,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "CardInfoError: 5001"){
} else if (isTap == "CardInfoError: 5001") {
print("CardInfoError: 5001");
await StartService.initLibrary();
AwesomeDialog(
......@@ -1144,7 +1141,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "Get TicketList Error 5001"){
} else if (isTap == "Get TicketList Error 5001") {
print("Get TicketList Error 5001");
await StartService.initLibrary();
AwesomeDialog(
......@@ -1169,11 +1166,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
},
btnOkColor: Colors.blue,
).show();
} else{
} else {
print("Error $isTap");
}
}
});
}
......@@ -1476,7 +1472,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
margin: EdgeInsets.only(top: 0),
padding: EdgeInsets.symmetric(horizontal: 17),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Masukkan nominal isi ulang disini',
......@@ -1498,11 +1495,11 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
),
Container(
height: 50,
padding:
EdgeInsets.symmetric(horizontal: 16),
padding: EdgeInsets.symmetric(
horizontal: 16),
decoration: BoxDecoration(
border:
Border.all(color: Colors.black12),
border: Border.all(
color: Colors.black12),
color: Colors.white,
borderRadius:
BorderRadius.circular(12)),
......@@ -1511,7 +1508,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
children: <Widget>[
Expanded(
child: TextFormField(
style: blackTextStyle.copyWith(
style:
blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
color: purpleColor,
......@@ -1549,7 +1547,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}
AwesomeDialog(
context: context,
dialogType: DialogType.info,
dialogType:
DialogType.info,
animType:
AnimType.rightSlide,
dismissOnTouchOutside:
......@@ -1560,26 +1559,29 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
title:
'Mohon Tunggu Sebentar ...',
titleTextStyle:
blackTextStyle.copyWith(
blackTextStyle
.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc:
"Please wait a moment ...",
descTextStyle:
greyTextStyle.copyWith(
greyTextStyle
.copyWith(
fontSize: 18,
fontWeight: light,
),
).show().then((value) {
// isProcessGet = true;
if (amountController!
.text.isEmpty) {
AwesomeDialog(
context: context,
dialogType:
DialogType.error,
animType:
AnimType.rightSlide,
animType: AnimType
.rightSlide,
headerAnimationLoop:
true,
title:
......@@ -1591,8 +1593,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
timer?.cancel();
tapIdle();
},
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red,
btnOkIcon:
Icons.cancel,
btnOkColor:
Colors.red,
).show();
}
if (mounted) {
......@@ -1620,7 +1624,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
Container(
padding: EdgeInsets.symmetric(horizontal: 17),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
SizedBox(
height: 15,
......@@ -1648,7 +1653,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
Expanded(
child: GestureDetector(
onTap: () {
if (timer != null) timer?.cancel();
if (timer != null)
timer?.cancel();
tapIdle();
if (mounted) {
......@@ -1663,8 +1669,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
vertical: 15),
decoration: BoxDecoration(
border: Border.all(
color:
amountController!.text ==
color: amountController!
.text ==
cTopUp1
? purpleColor
: Colors.black12),
......@@ -1687,7 +1693,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
Expanded(
child: GestureDetector(
onTap: () {
if (timer != null) timer?.cancel();
if (timer != null)
timer?.cancel();
tapIdle();
if (mounted) {
......@@ -1702,8 +1709,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
vertical: 15),
decoration: BoxDecoration(
border: Border.all(
color:
(amountController!.text ==
color: (amountController!
.text ==
cTopUp2)
? Color(0xff005DAC)
: Colors.black12),
......@@ -1730,7 +1737,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
Expanded(
child: GestureDetector(
onTap: () {
if (timer != null) timer?.cancel();
if (timer != null)
timer?.cancel();
tapIdle();
if (mounted) {
......@@ -1745,8 +1753,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
vertical: 15),
decoration: BoxDecoration(
border: Border.all(
color:
(amountController!.text ==
color: (amountController!
.text ==
cTopUp3)
? Color(0xff005DAC)
: Colors.black12),
......@@ -1795,8 +1803,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
),
child: Center(
child: Text("200,000",
style:
blackTextStyle.copyWith(
style: blackTextStyle
.copyWith(
fontSize: 25,
fontWeight: bold,
)),
......@@ -1820,55 +1828,76 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
subtitle: ' / proceed',
onPressed: () {
setState(() {
if (timer != null) timer?.cancel();
if (timer != null)
timer?.cancel();
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
autoHide: Duration(seconds: 2),
headerAnimationLoop: true,
dialogType:
DialogType.info,
animType: AnimType
.rightSlide,
dismissOnTouchOutside:
false,
autoHide: Duration(
seconds: 2),
headerAnimationLoop:
true,
title:
'Mohon Tunggu Sebentar ...',
titleTextStyle:
blackTextStyle.copyWith(
blackTextStyle
.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc: "Please wait a moment ...",
desc:
"Please wait a moment ...",
descTextStyle:
greyTextStyle.copyWith(
greyTextStyle
.copyWith(
fontSize: 18,
fontWeight: light,
),
).show().then((value) {
isProcessCheck =
false;
if (amountController!
.text.isEmpty) {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title: 'Terjadi Kesalahan',
dialogType:
DialogType
.error,
animType: AnimType
.rightSlide,
headerAnimationLoop:
true,
title:
'Terjadi Kesalahan',
desc:
"Anda belum mengisi saldo",
btnOkOnPress: () {
if (timer != null)
timer?.cancel();
if (timer !=
null)
timer
?.cancel();
tapIdle();
},
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red,
btnOkIcon:
Icons.cancel,
btnOkColor:
Colors.red,
).show();
}
if (mounted) {
denomLimits(
outletName,
info,
int.parse(amountController!
.text
.replaceAll(",", "")));
.replaceAll(
",",
"")));
}
});
});
......@@ -1884,59 +1913,66 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
Container(
margin: const EdgeInsets.only(
right: 350, left: 350),
child: Row(
children: [
child: Row(children: [
Expanded(
child: CustomFillButton(
title: 'Batal',
subtitle:' / cancel',
onPressed: (){
Navigator.of(context).pop(); timer?.cancel();
subtitle: ' / cancel',
onPressed: () {
setState(
() => isProcessCheck = false);
Navigator.of(context).pop();
timer?.cancel();
checkCountZero = false;
isShowingDialog = true;
_showTap();
tapDial();
},
)
)
]
),
))
]),
),
SizedBox(height: 10),
Align(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children:[
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Stack(
alignment: Alignment.center,
children: [
ValueListenableBuilder(
valueListenable: idleDuration,
builder: (context, value, child) =>
valueListenable:
idleDuration,
builder: (context, value,
child) =>
CircularProgressIndicator(
strokeWidth: 5,
value: (idleDuration.value.toDouble()) /
value: (idleDuration.value
.toDouble()) /
_maxDuration,
valueColor:
AlwaysStoppedAnimation<Color>(
AlwaysStoppedAnimation<
Color>(
Colors.blue),
),
),
RotatedBox(
quarterTurns: 4,
child: ValueListenableBuilder(
valueListenable: idleDuration,
builder: (context, value, child) =>
child:
ValueListenableBuilder(
valueListenable:
idleDuration,
builder: (context, value,
child) =>
Text(
value.toString(),
style: TextStyle(fontSize: 18),
),
style: TextStyle(
fontSize: 18),
),
),
]
),
]),
],
),
),
......@@ -1958,23 +1994,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}
void _showQris(BuildContext context) async {
bool isProcessGet = false;
bool isProcessCheck = false;
Future.delayed(Duration(seconds: 30), () {
if (!isProcessGet) {
isProcessGet = true;
_getQris().then((_qris) {
setState(() {
dataQris = _qris;
});
});
}
});
isProcessGet = false;
await showDialog(
context: context,
builder: (context) {
return StatefulBuilder(builder: (context, StateSetter setState) {
Future.delayed(Duration(seconds: 2), () {
print("is process get $isProcessGet");
if (!isProcessGet) {
isProcessGet = true;
_getQris().then((_qris) {
......@@ -2083,16 +2109,18 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//button batalkan di showqris
TextButton(
onPressed: () async {
setState(() => isProcessCheck = true);
print("Click-button-cancel");
setState(() {
isProcessCheck = true;
});
try {
bool value = await _cekStatus();
if (value) {
isProcessGet = false;
print("pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
await AwesomeDialog(
......@@ -2168,21 +2196,23 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
subtitle: 'cancel',
),
),
// Button Saya sudah Bayar di Showqris
TextButton(
onPressed: () async {
if (isProcessCheck) return; // Tambahkan pengecekan jika proses sedang berjalan
print("Click-button-saya-sudah-bayar");
if (isProcessCheck) return;
setState(() => isProcessCheck = true);
try {
bool result = await _cekStatus();
if (result) {
isProcessGet = false;
}
setState(() {
if (result) {
isProcessCheck = true;
print("pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
// isProcessCheck = false; // Hapus baris ini
setState(() => isProcessCheck = false); // Pindahkan baris ini ke bawah AwesomeDialog
AwesomeDialog(
context: context,
dialogType: DialogType.error,
......@@ -2288,12 +2318,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
desc:
"Your payment time has expired !",
btnOkOnPress: () async {
setState(
() => isProcessCheck = true);
setState(() {
isProcessCheck = true;
});
try {
bool result = await _cekStatus();
setState(() {
if (result) {
isProcessGet = false;
print(
"pembayaran berhasil dilakukan");
Navigator.pop(context);
......@@ -2704,7 +2736,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
// }),
// ],
// ),
],
),
),
......@@ -2847,10 +2878,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
children: [
ValueListenableBuilder(
valueListenable: idleDuration,
builder: (context, value, child) => CircularProgressIndicator(
builder: (context, value, child) =>
CircularProgressIndicator(
strokeWidth: 5,
value: value / 3, // Menggunakan nilai langsung dari value
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
value: value / 3,
// Menggunakan nilai langsung dari value
valueColor:
AlwaysStoppedAnimation<Color>(Colors.blue),
),
),
RotatedBox(
......@@ -2858,13 +2892,15 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
child: ValueListenableBuilder(
valueListenable: idleDuration,
builder: (context, value, child) => Text(
(value.toInt() % 7).toString(), // Menggunakan nilai bulat dari value
(value.toInt() % 7).toString(),
// Menggunakan nilai bulat dari value
style: TextStyle(fontSize: 20),
),
),
),
],
), // TextButton(
),
// TextButton(
// onPressed: () {
// timer?.cancel();
// checkCountZero = false;
......
......@@ -44,7 +44,7 @@ dependencies:
equatable: ^2.0.5
flutter_bloc: ^8.1.1
build_runner: ^2.3.2
intl: ^0.17.0
intl: ^0.18.0
qr_flutter: ^4.0.0
connectivity_plus: ^3.0.3
ping_discover_network_forked: ^0.0.1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment