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 { ...@@ -97,6 +97,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
bool checkCountZero = false; bool checkCountZero = false;
bool isDenomDialogShowing = false; bool isDenomDialogShowing = false;
bool isPaymentProcessed = false; bool isPaymentProcessed = false;
bool isShowingButton = true;
double _targetDuration = 3; // Durasi yang dituju (dalam detik) double _targetDuration = 3; // Durasi yang dituju (dalam detik)
double _maxDurationPage = 3; // Durasi maksimum (dalam detik) double _maxDurationPage = 3; // Durasi maksimum (dalam detik)
...@@ -978,7 +979,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -978,7 +979,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dismissOnTouchOutside: false, dismissOnTouchOutside: false,
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Internet Tidak Tersedia', 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: () { btnOkOnPress: () {
tapIdle(); tapIdle();
}, },
...@@ -1078,7 +1080,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1078,7 +1080,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dismissOnTouchOutside: false, dismissOnTouchOutside: false,
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Internet Tidak Tersedia', 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: () { btnOkOnPress: () {
tapDial(); tapDial();
}, },
...@@ -1110,7 +1113,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1110,7 +1113,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dismissOnTouchOutside: false, dismissOnTouchOutside: false,
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Internet Tidak Tersedia', 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: () { btnOkOnPress: () {
countMax = 0; countMax = 0;
tapBalance(); tapBalance();
...@@ -1603,9 +1607,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1603,9 +1607,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
tapIdle(); tapIdle();
}, },
onFieldSubmitted: (value) { onFieldSubmitted: (value) {
if (timer != null) {
timer!.cancel();
}
AwesomeDialog( AwesomeDialog(
context: context, context: context,
dialogType: dialogType:
...@@ -1634,7 +1635,9 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1634,7 +1635,9 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
fontWeight: light, fontWeight: light,
), ),
).show().then((value) { ).show().then((value) {
// isProcessGet = true; if (timer != null) {
timer!.cancel();
}
if (amountController! if (amountController!
.text.isEmpty) { .text.isEmpty) {
AwesomeDialog( AwesomeDialog(
...@@ -2055,6 +2058,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2055,6 +2058,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
} }
void _showQris(BuildContext context) async { void _showQris(BuildContext context) async {
isProcessCheck = false;
isProcessGet = false; isProcessGet = false;
await showDialog( await showDialog(
context: context, context: context,
...@@ -2170,8 +2174,19 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2170,8 +2174,19 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
TextButton( Visibility(
onPressed: () async { 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"); print("Click-button-cancel");
setState(() { setState(() {
isProcessCheck = true; isProcessCheck = true;
...@@ -2209,56 +2224,57 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2209,56 +2224,57 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
setState(() => isProcessCheck = false); setState(() => isProcessCheck = false);
} }
}, },
child: (isProcessCheck) child: ButtonQris(
? 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(
fontWeight: bold,
fontSize: 15,
),
),
Text(
'please wait ...',
style: greyTextStyle.copyWith(
fontWeight: light,
fontStyle: FontStyle.italic,
fontSize: 8,
),
),
],
)
: ButtonQris(
iconUrl: 'assets/cancel.png', iconUrl: 'assets/cancel.png',
title: 'batalkan', title: 'batalkan',
subtitle: 'cancel', subtitle: 'cancel',
), ),
);
}
},
)),
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,
),
desc:
"Please wait a moment ...",
descTextStyle:
greyTextStyle
.copyWith(
fontSize: 18,
fontWeight: light,
), ),
TextButton( ).show().then((value) async {
onPressed: () async {
print("Click-button-saya-sudah-bayar"); print("Click-button-saya-sudah-bayar");
if (isProcessCheck) return; if (isProcessCheck) return;
setState(() => isProcessCheck = true); setState(() => isProcessCheck = true);
...@@ -2279,10 +2295,11 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2279,10 +2295,11 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
context: context, context: context,
dialogType: DialogType.error, dialogType: DialogType.error,
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
autoHide: Duration(seconds:2),
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Belum Terbayar !', title: 'Belum Terbayar !',
desc: "Not paid yet !", desc: "Not paid yet !",
btnOkOnPress: () {},
btnOkIcon: Icons.cancel, btnOkIcon: Icons.cancel,
btnOkColor: Colors.red, btnOkColor: Colors.red,
).show(); ).show();
...@@ -2292,52 +2309,17 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2292,52 +2309,17 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
print("Error: $e"); print("Error: $e");
setState(() => isProcessCheck = false); setState(() => isProcessCheck = false);
} }
});
}, },
child: (isProcessCheck) child: ButtonQris(
? 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', iconUrl: 'assets/check-mark.png',
title: 'Saya Sudah Bayar', title: 'Saya Sudah Bayar',
subtitle: 'i have already paid', subtitle: 'i have already paid',
), ),
);
}
}
),
), ),
// Time DI Menu Qris // Time DI Menu Qris
Column( Column(
...@@ -2374,12 +2356,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2374,12 +2356,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dialogType: DialogType.warning, dialogType: DialogType.warning,
dismissOnTouchOutside: false, dismissOnTouchOutside: false,
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
autoHide: Duration(seconds: 2),
headerAnimationLoop: true, headerAnimationLoop: true,
title: title: 'Waktu pembayaran anda sudah habis !',
'Waktu pembayaran anda sudah habis !', desc: "Your payment time has expired !",
desc: btnOkIcon: Icons.cancel,
"Your payment time has expired !", btnOkColor: Colors.red)
btnOkOnPress: () async { .show()
.then((value) async {
setState(() { setState(() {
isProcessCheck = true; isProcessCheck = true;
}); });
...@@ -2388,23 +2372,24 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2388,23 +2372,24 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
setState(() { setState(() {
if (result) { if (result) {
isProcessGet = false; isProcessGet = false;
print( print("pembayaran berhasil dilakukan");
"pembayaran berhasil dilakukan");
Navigator.pop(context); Navigator.pop(context);
showPop(approvalCode); showPop(approvalCode);
} else { } else {
setState(() => setState(
isProcessCheck = false); () => isProcessCheck = false);
AwesomeDialog( AwesomeDialog(
context: context, context: context,
dismissOnTouchOutside: false, dismissOnTouchOutside: false,
dialogType: DialogType.error, dialogType: DialogType.error,
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
autoHide: Duration(seconds: 3), autoHide: Duration(seconds: 2),
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Belum Terbayar , Silahkan Ulangi Kembali !', title:
desc: "Not paid yet , please try again !", 'Belum Terbayar , Silahkan Ulangi Kembali !',
).show().then((value){ desc:
"Not paid yet , please try again !",
).show().then((value) {
Navigator.of(context).pop(); Navigator.of(context).pop();
timer?.cancel(); timer?.cancel();
dataQris = null; dataQris = null;
...@@ -2418,13 +2403,9 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2418,13 +2403,9 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}); });
} catch (e) { } catch (e) {
print("Error: $e"); print("Error: $e");
setState( setState(() => isProcessCheck = false);
() => isProcessCheck = false);
} }
}, });
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red)
.show();
}, },
builder: (BuildContext context, Duration value, builder: (BuildContext context, Duration value,
Widget? child) { Widget? child) {
...@@ -2438,8 +2419,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2438,8 +2419,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
int.parse(seconds) == int.parse("30")) { int.parse(seconds) == int.parse("30")) {
if (!isHitApi) { if (!isHitApi) {
isHitApi = true; isHitApi = true;
isProcessCheck = true;
_cekStatus(isBackgroundServices: 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