Commit 34ddac0d authored by Izol's avatar Izol

bug fixing tap card

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