Commit 34ddac0d authored by Izol's avatar Izol

bug fixing tap card

parent 29812bae
......@@ -20,7 +20,7 @@ buildscript {
allprojects {
repositories {
maven {
url "https://mobile-repo.mdd.co.id:8081/artifactory/android-library/"
url "https://mobile-repo.mdd.co.id/artifactory/android-library/"
allowInsecureProtocol = true
credentials {
username = "admin"
......
......@@ -89,6 +89,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
Color _tapColor2 = Colors.grey;
Color _tapColor3 = Colors.grey;
int _activeContainerIndex = 1;
int callInit = 10;
int callBalanceInit = 10;
double _downloadSpeed = 0;
bool checkCountZero = false;
bool isDenomDialogShowing = false;
......@@ -455,9 +457,28 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
status;
info = await StartService.topupBalanceCard(cardNumber, int.parse(amount));
infoMap = jsonDecode(info);
lastBalance = infoMap['balance'].toString();
samReport = infoMap['report'].toString();
// if (info == null){
// tapBalance();
// return "";
// }
// if(info.toString().contains("{"))
// infoMap = jsonDecode(info);
// lastBalance = infoMap['balance'].toString();
// samReport = infoMap['report'].toString();
if (info == null) {
tapBalance();
return "";
}
if (info.toString().contains("{")) {
infoMap = jsonDecode(info);
lastBalance = infoMap['balance'].toString();
samReport = infoMap['report'].toString();
} else {
// Handle ketika info tidak mengandung data JSON
tapBalance();
return "";
}
paymentMethod = 'Qris';
var infoPaymentNotes = jsonDecode(info);
......@@ -649,7 +670,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
_getInfoBeforeTopup(var info) {
setState(() {
countMax += 1;
if (info.toString().toLowerCase().contains('failed')) {
if (info.toString().toLowerCase().contains('failed')) {
print('ini pesan salah');
message = "Silakan Tempel Wristband Anda Di Reader";
tapBalance();
......@@ -1037,6 +1058,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
});
}
void tapBalance() async {
Future.delayed(const Duration(milliseconds: 500), () async {
var isTap = await StartService.getCard();
......@@ -1044,28 +1066,81 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
var infoMap = jsonDecode(isTap);
_getInfoBeforeTopup(isTap);
} catch (e) {
print("Error $isTap");
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: 'Pastikan Wristband Anda Tertempel Di Reader !',
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc: "Make sure your wristband is attached to the reader !",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
btnOkOnPress: () {
tapBalance();
},
btnOkColor: Colors.blue)
.show();
if (isTap == "Card Not Found") {
print("Card Not Found");
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: 'Pastikan Wristband Anda Tertempel Di Reader!',
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc: "Make sure your wristband is attached to the reader!",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
btnOkOnPress: () {
countMax = 0;
tapBalance();
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "Error Get Card Type"){
print("Error Get Card Type");
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: 'Coba Lagi!',
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc: "Try Again!",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
btnOkOnPress: () {
countMax = 0;
tapBalance();
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "CardInfoError: 5001"){
print("CardInfoError: 5001");
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: 'Coba Lagi!',
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc: "Try Again!",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
btnOkOnPress: () {
countMax = 0;
tapBalance();
},
btnOkColor: Colors.blue,
).show();
} else{
print("Error $isTap");
}
}
});
}
......
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