Commit bbf42789 authored by Izol's avatar Izol

added hidden button already paid and cancel

parent 917ce335
......@@ -97,6 +97,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
bool checkCountZero = false;
bool isDenomDialogShowing = false;
bool isPaymentProcessed = false;
bool isShowingButton = true;
double _targetDuration = 3; // Durasi yang dituju (dalam detik)
double _maxDurationPage = 3; // Durasi maksimum (dalam detik)
......@@ -968,7 +969,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
// }
void tapIdle() {
var connectivityResult = Connectivity().checkConnectivity();
var connectivityResult = Connectivity().checkConnectivity();
if (connectivityResult == ConnectivityResult.none) {
AwesomeDialog(
......@@ -978,9 +979,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: 'Internet Tidak Tersedia',
desc: 'Tidak ada koneksi internet. Pastikan Anda terhubung ke internet untuk melanjutkan.',
desc:
'Tidak ada koneksi internet. Pastikan Anda terhubung ke internet untuk melanjutkan.',
btnOkOnPress: () {
tapIdle();
tapIdle();
},
btnOkIcon: Icons.error,
btnOkColor: Colors.red,
......@@ -1078,7 +1080,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: 'Internet Tidak Tersedia',
desc: 'Tidak ada koneksi internet. Pastikan Anda terhubung ke internet untuk melanjutkan.',
desc:
'Tidak ada koneksi internet. Pastikan Anda terhubung ke internet untuk melanjutkan.',
btnOkOnPress: () {
tapDial();
},
......@@ -1110,7 +1113,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: 'Internet Tidak Tersedia',
desc: 'Tidak ada koneksi internet. Pastikan Anda terhubung ke internet untuk melanjutkan.',
desc:
'Tidak ada koneksi internet. Pastikan Anda terhubung ke internet untuk melanjutkan.',
btnOkOnPress: () {
countMax = 0;
tapBalance();
......@@ -1603,9 +1607,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
tapIdle();
},
onFieldSubmitted: (value) {
if (timer != null) {
timer!.cancel();
}
AwesomeDialog(
context: context,
dialogType:
......@@ -1634,7 +1635,9 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
fontWeight: light,
),
).show().then((value) {
// isProcessGet = true;
if (timer != null) {
timer!.cancel();
}
if (amountController!
.text.isEmpty) {
AwesomeDialog(
......@@ -2055,6 +2058,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}
void _showQris(BuildContext context) async {
isProcessCheck = false;
isProcessGet = false;
await showDialog(
context: context,
......@@ -2170,174 +2174,152 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TextButton(
onPressed: () async {
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(
context: context,
dismissOnTouchOutside: false,
dialogType: DialogType.warning,
autoHide: Duration(seconds: 3),
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title: 'Anda telah membatalkan transaksi',
desc: "You have canceled the transaction",
).show().then((value) {
Navigator.of(context).pop();
timer?.cancel();
dataQris = null;
checkCountZero = false;
isShowingDialog = true;
_showTap();
tapDial();
Visibility(
visible: isShowingButton,
maintainState: true,
child: FutureBuilder(
future: Future.delayed(Duration(seconds: 5)),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Container(); // Placeholder widget while waiting
} else {
return TextButton(
onPressed: isProcessCheck
? null
: () async {
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(
context: context,
dismissOnTouchOutside: false,
dialogType: DialogType.warning,
autoHide: Duration(seconds: 3),
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title: 'Anda telah membatalkan transaksi',
desc: "You have canceled the transaction",
).show().then((value) {
Navigator.of(context).pop();
timer?.cancel();
dataQris = null;
checkCountZero = false;
isShowingDialog = true;
_showTap();
tapDial();
});
}
} catch (e) {
// Handle any errors that occur during _cekStatus()
} finally {
setState(() => isProcessCheck = false);
}
},
child: ButtonQris(
iconUrl: 'assets/cancel.png',
title: 'batalkan',
subtitle: 'cancel',
),
);
}
} catch (e) {
// Handle any errors that occur during _cekStatus()
} finally {
setState(() => isProcessCheck = false);
}
},
child: (isProcessCheck)
? Column(
children: [
Container(
width: 250,
height: 70,
margin: const EdgeInsets.only(bottom: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: purpleColor,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(3, 3),
),
],
),
child: Center(
child: CircularProgressIndicator(
color: lightBackgroundColor,
),
),
),
Text(
'Mohon Tunggu ...',
style: blackTextStyle.copyWith(
},
)),
Visibility(
visible: isShowingButton,
maintainState: true,
child: FutureBuilder(
future: Future.delayed(Duration(seconds: 5)),
builder: (context, snapshot){
if (snapshot.connectionState == ConnectionState.waiting){
return Container();
} else {
return TextButton(
onPressed: isProcessCheck
? null
: () async {
AwesomeDialog(
context: context,
dialogType:
DialogType.info,
animType:
AnimType.rightSlide,
dismissOnTouchOutside:
false,
autoHide:
Duration(seconds: 2),
headerAnimationLoop: true,
title:
'Mohon Tunggu Sebentar ...',
titleTextStyle:
blackTextStyle
.copyWith(
fontSize: 20,
fontWeight: bold,
fontSize: 15,
),
),
Text(
'please wait ...',
style: greyTextStyle.copyWith(
desc:
"Please wait a moment ...",
descTextStyle:
greyTextStyle
.copyWith(
fontSize: 18,
fontWeight: light,
fontStyle: FontStyle.italic,
fontSize: 8,
),
),
],
)
: ButtonQris(
iconUrl: 'assets/cancel.png',
title: 'batalkan',
subtitle: 'cancel',
),
),
TextButton(
onPressed: () async {
print("Click-button-saya-sudah-bayar");
if (isProcessCheck) return;
setState(() => isProcessCheck = true);
try {
bool result = await _cekStatus();
if (result) {
isProcessGet = false;
).show().then((value) async {
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;
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
autoHide: Duration(seconds:2),
headerAnimationLoop: true,
title: 'Belum Terbayar !',
desc: "Not paid yet !",
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red,
).show();
}
});
} catch (e) {
print("Error: $e");
setState(() => isProcessCheck = false);
}
});
},
child: ButtonQris(
iconUrl: 'assets/check-mark.png',
title: 'Saya Sudah Bayar',
subtitle: 'i have already paid',
),
);
}
setState(() {
if (result) {
isProcessCheck = true;
print("pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
isProcessCheck = false;
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title: 'Belum Terbayar !',
desc: "Not paid yet !",
btnOkOnPress: () {},
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red,
).show();
}
});
} catch (e) {
print("Error: $e");
setState(() => isProcessCheck = false);
}
},
child: (isProcessCheck)
? Column(
children: [
Container(
width: 250,
height: 70,
margin: const EdgeInsets.only(
bottom: 10,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: purpleColor,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
//color of shadow
spreadRadius: 3,
//spread radius
blurRadius: 7,
// blur radius
offset: Offset(3,
3), // changes position of shadow
),
],
),
child: Center(
child: CircularProgressIndicator(
color: lightBackgroundColor,
),
),
),
Text(
'Mohon Tunggu ...',
style: blackTextStyle.copyWith(
fontWeight: bold,
fontSize: 15,
),
),
],
)
: ButtonQris(
iconUrl: 'assets/check-mark.png',
title: 'Saya Sudah Bayar',
subtitle: 'i have already paid',
),
),
),
// Time DI Menu Qris
Column(
......@@ -2374,57 +2356,56 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dialogType: DialogType.warning,
dismissOnTouchOutside: false,
animType: AnimType.rightSlide,
autoHide: Duration(seconds: 2),
headerAnimationLoop: true,
title:
'Waktu pembayaran anda sudah habis !',
desc:
"Your payment time has expired !",
btnOkOnPress: () async {
setState(() {
isProcessCheck = true;
});
try {
bool result = await _cekStatus();
setState(() {
if (result) {
isProcessGet = false;
print(
"pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
setState(() =>
isProcessCheck = false);
AwesomeDialog(
context: context,
dismissOnTouchOutside: false,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
autoHide: Duration(seconds: 3),
headerAnimationLoop: true,
title: 'Belum Terbayar , Silahkan Ulangi Kembali !',
desc: "Not paid yet , please try again !",
).show().then((value){
Navigator.of(context).pop();
timer?.cancel();
dataQris = null;
checkCountZero = false;
isShowingDialog = true;
_showTap();
tapDial();
});
}
// isProcessCheck = false;
});
} catch (e) {
print("Error: $e");
setState(
() => isProcessCheck = false);
}
},
title: 'Waktu pembayaran anda sudah habis !',
desc: "Your payment time has expired !",
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red)
.show();
.show()
.then((value) async {
setState(() {
isProcessCheck = true;
});
try {
bool result = await _cekStatus();
setState(() {
if (result) {
isProcessGet = false;
print("pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
setState(
() => isProcessCheck = false);
AwesomeDialog(
context: context,
dismissOnTouchOutside: false,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
autoHide: Duration(seconds: 2),
headerAnimationLoop: true,
title:
'Belum Terbayar , Silahkan Ulangi Kembali !',
desc:
"Not paid yet , please try again !",
).show().then((value) {
Navigator.of(context).pop();
timer?.cancel();
dataQris = null;
checkCountZero = false;
isShowingDialog = true;
_showTap();
tapDial();
});
}
// isProcessCheck = false;
});
} catch (e) {
print("Error: $e");
setState(() => isProcessCheck = false);
}
});
},
builder: (BuildContext context, Duration value,
Widget? child) {
......@@ -2438,8 +2419,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
int.parse(seconds) == int.parse("30")) {
if (!isHitApi) {
isHitApi = true;
isProcessCheck = true;
_cekStatus(isBackgroundServices: true);
print("pembayaran berhasil dilakukan");
}
}
......
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