Commit 07b8f4fd authored by Gandha Ryanto's avatar Gandha Ryanto

Merge remote-tracking branch 'origin/simplyfy-v2' into simplyfy-v2

parents 0716d907 01335cd2
...@@ -301,51 +301,6 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT ...@@ -301,51 +301,6 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT
) )
print("model ${Build.MODEL}") print("model ${Build.MODEL}")
// if (Build.MODEL == "T2s" || Build.MODEL == "T2Mini" || Build.MODEL == "T2mini") { // if (Build.MODEL == "T2s" || Build.MODEL == "T2Mini" || Build.MODEL == "T2mini") {
if (Build.MODEL == "T2s" || Build.MODEL == "T2Mini") {
var text = """
[C]${companyName}
[C]${companyAddress}
[C]${companyPhone}
[C]--------------------------------
[L]xTanggal : ${sdf.format(timeNow)}
[L]xNo Transaksi : ${approvalCode}
[L] No Kartu : ${ticket.cardNumber.toString()}
[L]Masa Berlaku : ${sdf.format(cardExpiry)}"""
if(status == "Berhasil"){
text += """
[L]Saldo Awal : Rp${formatDecimalToPrice(prevBalance.toDouble()).toString()}
[L]Isi Saldo : Rp${formatDecimalToPrice(denom.toDouble()).toString()}
[L]Saldo Akhir : Rp${formatDecimalToPrice(ticket.balance!!.toDouble()).toString()}
[L]Biaya Layanan : Rp${formatDecimalToPrice(serviceCharge.toDouble()).toString()}
[L]Jumlah Bayar : Rp${formatDecimalToPrice(serviceChargeAmount.toDouble()).toString()}
[L]Metode Bayar : ${metodeBayar}
[L]Status : ${status}
[C]--------------------------------
[C]Top Up Berhasil
[C]powered by dolanapp.com
"""
} else {
text += """
[L]Saldo : Rp${formatDecimalToPrice(prevBalance.toDouble()).toString()}
[L]Biaya Layanan : Rp${formatDecimalToPrice(serviceCharge.toDouble()).toString()}
[L]Jumlah Bayar : Rp${formatDecimalToPrice(serviceChargeAmount.toDouble()).toString()}
[L]Metode Bayar : ${metodeBayar}
[L]Status : ${status}
[C]--------------------------------
[C]Top Up Gagal
[C]powered by dolanapp.com
"""
}
text = text.trimIndent()
_mifareTicketing?.generateReceiptTopup(
null,
text,
bitmapIcon,
paperWidth = 57F,
isBluetooth = true
)
}
else {
var receiptLayout = ReceiptBuilder(570) var receiptLayout = ReceiptBuilder(570)
.setMarginTop(30) .setMarginTop(30)
.setMarginLeft(30) .setMarginLeft(30)
...@@ -389,7 +344,7 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT ...@@ -389,7 +344,7 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT
.addBlankSpace(10) .addBlankSpace(10)
.addText("Masa Berlaku...............: " + sdf.format(cardExpiry)) .addText("Masa Berlaku...............: " + sdf.format(cardExpiry))
.addBlankSpace(10) .addBlankSpace(10)
if (status == "Berhasil"){ if (status == "Isi Saldo Berhasil"){
receiptLayout.addText("Saldo Awal...................: Rp" + formatDecimalToPrice(prevBalance.toDouble()).toString()) receiptLayout.addText("Saldo Awal...................: Rp" + formatDecimalToPrice(prevBalance.toDouble()).toString())
.addBlankSpace(10) .addBlankSpace(10)
.addText("Isi Saldo.........................: Rp" + formatDecimalToPrice(denom.toDouble())) .addText("Isi Saldo.........................: Rp" + formatDecimalToPrice(denom.toDouble()))
...@@ -438,7 +393,7 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT ...@@ -438,7 +393,7 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT
} }
val finalReceiptLayout: ReceiptBuilder = receiptLayout val finalReceiptLayout: ReceiptBuilder = receiptLayout
_mifareTicketing?.generateReceiptTopup(finalReceiptLayout, "", null, paperWidth = 570F, isBluetooth = false) _mifareTicketing?.generateReceiptTopup(finalReceiptLayout, "", null, paperWidth = 570F, isBluetooth = false)
}
} }
} }
...@@ -494,6 +494,17 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -494,6 +494,17 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
print("lastBalance $lastBalance"); print("lastBalance $lastBalance");
print("prevBalance $prevBalance"); print("prevBalance $prevBalance");
String ticketJson, companyName, companyPhone, denom;
companyName = PreferencesHelper.getString('outletname');
companyPhone = PreferencesHelper.getString('companyphone');
companyAddress = PreferencesHelper.getString('multioutletaddress');
denom = amountController!.text.replaceAll(",", "");
String sca =
PreferencesHelper.getString("multioutletservicechargeamount");
String sc = PreferencesHelper.getString("multioutletservicecharge");
// String metodeBayar = PreferencesHelper.getString("provider");
// String status = "Berhasil";
if (int.parse(lastBalance) > int.parse(prevBalance!)) { if (int.parse(lastBalance) > int.parse(prevBalance!)) {
countMax = 0; countMax = 0;
var result = await StartService.topUpConfirm( var result = await StartService.topUpConfirm(
...@@ -562,16 +573,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -562,16 +573,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
DatabaseHelper.insertTransaction(wristbandInfo); DatabaseHelper.insertTransaction(wristbandInfo);
print("ini pesan tersimpan berhasil ke database$wristbandInfo"); print("ini pesan tersimpan berhasil ke database$wristbandInfo");
String ticketJson, companyName, companyPhone, denom;
companyName = PreferencesHelper.getString('outletname');
companyPhone = PreferencesHelper.getString('companyphone');
companyAddress = PreferencesHelper.getString('multioutletaddress');
denom = amountController!.text.replaceAll(",", "");
String sca =
PreferencesHelper.getString("multioutletservicechargeamount");
String sc = PreferencesHelper.getString("multioutletservicecharge");
String metodeBayar = PreferencesHelper.getString("provider");
String status = "Berhasil";
_getInfoBalance(info); _getInfoBalance(info);
...@@ -616,14 +617,48 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -616,14 +617,48 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
sca! + sc!, sca! + sc!,
(int.parse(amount) + int.parse(sca) + int.parse(sc)).toString(), (int.parse(amount) + int.parse(sca) + int.parse(sc)).toString(),
denom.replaceAll(",", ""), denom.replaceAll(",", ""),
metodeBayar, PreferencesHelper.getString("provider"),
status, "Isi Saldo Berhasil",
); );
isHitApi = false; isHitApi = false;
} else { }
else {
print('topup gagal'); print('topup gagal');
AwesomeDialog(
context: context,
autoHide: Duration(seconds: 10),
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title: "Transaksi isi ulang anda tidak berhasil\nsimpan bukti pembayaran untuk di tunjukkan kepada petugas",
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc:
"Your top up transaction was not successful\nSave proof of payment to show to the officer",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
).show().then((value) {
});
isShowingDialog = true; isShowingDialog = true;
dataQris == null; dataQris == null;
StartService.print(
prevInfoCard,
companyName.split("-")[0],
companyAddress,
companyPhone,
approvalCode,
lastBalance!,
sca! + sc!,
(int.parse(amount) + int.parse(sca) + int.parse(sc))
.toString(),
denom.replaceAll(",", ""),
PreferencesHelper.getString("provider"),
"isi saldo tidak berhasil",
);
} }
return ""; return "";
} }
...@@ -702,6 +737,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -702,6 +737,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
AwesomeDialog( AwesomeDialog(
context: context, context: context,
dismissOnTouchOutside: false, dismissOnTouchOutside: false,
autoHide: Duration(seconds: 5),
dialogType: DialogType.error, dialogType: DialogType.error,
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
headerAnimationLoop: true, headerAnimationLoop: true,
...@@ -709,16 +745,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -709,16 +745,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
'Transaksi anda gagal ! dikarenakan tidak menempelkan wristband sebelumnya', 'Transaksi anda gagal ! dikarenakan tidak menempelkan wristband sebelumnya',
desc: desc:
"Your transaction failed ! because didn't attach the previous card!", "Your transaction failed ! because didn't attach the previous card!",
btnOkOnPress: () { ).show().then((value) {
String companyName, companyPhone, metodeBayar; String companyName, companyPhone, metodeBayar;
companyName = companyName = PreferencesHelper.getString('outletname');
PreferencesHelper.getString('outletname'); companyName = PreferencesHelper.getString('outletname');
companyName =
PreferencesHelper.getString('outletname');
companyPhone = companyPhone =
PreferencesHelper.getString('companyphone'); PreferencesHelper.getString('companyphone');
companyAddress = PreferencesHelper.getString( companyAddress =
'multioutletaddress'); PreferencesHelper.getString('multioutletaddress');
lastBalance = infoMap['balance'].toString(); lastBalance = infoMap['balance'].toString();
metodeBayar = "link-aja"; metodeBayar = "link-aja";
String sca = PreferencesHelper.getString( String sca = PreferencesHelper.getString(
...@@ -768,19 +802,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -768,19 +802,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
approvalCode, approvalCode,
lastBalance!, lastBalance!,
sca! + sc!, sca! + sc!,
(int.parse(amount) + (int.parse(amount) + int.parse(sca) + int.parse(sc))
int.parse(sca) +
int.parse(sc))
.toString(), .toString(),
'0', '0',
PreferencesHelper.getString("provider"), PreferencesHelper.getString("provider"),
'Gagal', 'Gagal Wristband Berbeda',
); );
// Navigator.pop(context); // Navigator.pop(context);
}, });
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red)
.show();
} }
}, },
btnOkIcon: Icons.cancel, btnOkIcon: Icons.cancel,
...@@ -1156,7 +1185,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1156,7 +1185,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}, },
btnOkColor: Colors.blue, btnOkColor: Colors.blue,
).show(); ).show();
} else if (isTap == "Error Get Card Type") { }
else if (isTap == "Error Get Card Type") {
print("Error Get Card Type"); print("Error Get Card Type");
await StartService.initLibrary(); await StartService.initLibrary();
AwesomeDialog( AwesomeDialog(
...@@ -1181,7 +1211,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1181,7 +1211,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}, },
btnOkColor: Colors.blue, btnOkColor: Colors.blue,
).show(); ).show();
} else if (isTap == "CardInfoError: 5001") { }
else if (isTap == "CardInfoError: 5001") {
print("CardInfoError: 5001"); print("CardInfoError: 5001");
await StartService.initLibrary(); await StartService.initLibrary();
AwesomeDialog( AwesomeDialog(
...@@ -1206,7 +1237,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1206,7 +1237,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}, },
btnOkColor: Colors.blue, btnOkColor: Colors.blue,
).show(); ).show();
} else if (isTap == "Get TicketList Error 5001") { }
else if (isTap == "Get TicketList Error 5001") {
print("Get TicketList Error 5001"); print("Get TicketList Error 5001");
await StartService.initLibrary(); await StartService.initLibrary();
AwesomeDialog( AwesomeDialog(
...@@ -1231,8 +1263,33 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1231,8 +1263,33 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}, },
btnOkColor: Colors.blue, btnOkColor: Colors.blue,
).show(); ).show();
} else { }
print("Error $isTap"); else {
print("Error Saat Topup Balance $isTap");
await StartService.initLibrary();
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: "Terjadi Kesalahan Saat Isi Saldo",
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc:"An Error Occurred When Topup Balance",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
btnOkText: "Coba lagi",
btnOkColor: Colors.blue,
btnOkOnPress: (){
countMax = 0 ;
tapBalance();
}
).show();
} }
} }
}); });
...@@ -1720,7 +1777,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1720,7 +1777,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
if (timer != null) if (timer != null)
timer?.cancel(); timer?.cancel();
tapIdle(); tapIdle();
if (mounted) { if (mounted) {
setState(() { setState(() {
amountController!.text = amountController!.text =
...@@ -1760,7 +1816,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1760,7 +1816,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
if (timer != null) if (timer != null)
timer?.cancel(); timer?.cancel();
tapIdle(); tapIdle();
if (mounted) { if (mounted) {
setState(() { setState(() {
amountController!.text = amountController!.text =
...@@ -2180,7 +2235,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2180,7 +2235,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
child: FutureBuilder( child: FutureBuilder(
future: Future.delayed(Duration(seconds: 5)), future: Future.delayed(Duration(seconds: 5)),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) { if (snapshot.connectionState ==
ConnectionState.waiting) {
return Container(); // Placeholder widget while waiting return Container(); // Placeholder widget while waiting
} else { } else {
return TextButton( return TextButton(
...@@ -2195,7 +2251,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2195,7 +2251,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
bool value = await _cekStatus(); bool value = await _cekStatus();
if (value) { if (value) {
isProcessGet = false; isProcessGet = false;
print("pembayaran berhasil dilakukan"); print(
"pembayaran berhasil dilakukan");
Navigator.pop(context); Navigator.pop(context);
showPop(approvalCode); showPop(approvalCode);
} else { } else {
...@@ -2206,8 +2263,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2206,8 +2263,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
autoHide: Duration(seconds: 3), autoHide: Duration(seconds: 3),
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Anda telah membatalkan transaksi', title:
desc: "You have canceled the transaction", 'Anda telah membatalkan transaksi',
desc:
"You have canceled the transaction",
).show().then((value) { ).show().then((value) {
Navigator.of(context).pop(); Navigator.of(context).pop();
timer?.cancel(); timer?.cancel();
...@@ -2221,7 +2280,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2221,7 +2280,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
} catch (e) { } catch (e) {
// Handle any errors that occur during _cekStatus() // Handle any errors that occur during _cekStatus()
} finally { } finally {
setState(() => isProcessCheck = false); setState(
() => isProcessCheck = false);
} }
}, },
child: ButtonQris( child: ButtonQris(
...@@ -2232,15 +2292,15 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2232,15 +2292,15 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
); );
} }
}, },
)), )),
Visibility( Visibility(
visible: isShowingButton, visible: isShowingButton,
maintainState: true, maintainState: true,
child: FutureBuilder( child: FutureBuilder(
future: Future.delayed(Duration(seconds: 5)), future: Future.delayed(Duration(seconds: 5)),
builder: (context, snapshot){ builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting){ if (snapshot.connectionState ==
ConnectionState.waiting) {
return Container(); return Container();
} else { } else {
return TextButton( return TextButton(
...@@ -2249,35 +2309,29 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2249,35 +2309,29 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
: () async { : () async {
AwesomeDialog( AwesomeDialog(
context: context, context: context,
dialogType: dialogType: DialogType.info,
DialogType.info, animType: AnimType.rightSlide,
animType: dismissOnTouchOutside: false,
AnimType.rightSlide, autoHide: Duration(seconds: 2),
dismissOnTouchOutside:
false,
autoHide:
Duration(seconds: 2),
headerAnimationLoop: true, headerAnimationLoop: true,
title: title: 'Mohon Tunggu Sebentar ...',
'Mohon Tunggu Sebentar ...',
titleTextStyle: titleTextStyle:
blackTextStyle blackTextStyle.copyWith(
.copyWith(
fontSize: 20, fontSize: 20,
fontWeight: bold, fontWeight: bold,
), ),
desc: desc: "Please wait a moment ...",
"Please wait a moment ...",
descTextStyle: descTextStyle:
greyTextStyle greyTextStyle.copyWith(
.copyWith(
fontSize: 18, fontSize: 18,
fontWeight: light, fontWeight: light,
), ),
).show().then((value) async { ).show().then((value) 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);
try { try {
bool result = await _cekStatus(); bool result = await _cekStatus();
if (result) { if (result) {
...@@ -2286,17 +2340,22 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2286,17 +2340,22 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
setState(() { setState(() {
if (result) { if (result) {
isProcessCheck = true; isProcessCheck = true;
print("pembayaran berhasil dilakukan"); print(
"pembayaran berhasil dilakukan");
Navigator.pop(context); Navigator.pop(context);
showPop(approvalCode); showPop(approvalCode);
} else { } else {
isProcessCheck = false; isProcessCheck = false;
AwesomeDialog( AwesomeDialog(
context: context, context: context,
dialogType: DialogType.error, dialogType:
animType: AnimType.rightSlide, DialogType.error,
dismissOnTouchOutside: false, animType:
autoHide: Duration(seconds:2), 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 !",
...@@ -2307,7 +2366,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2307,7 +2366,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}); });
} catch (e) { } catch (e) {
print("Error: $e"); print("Error: $e");
setState(() => isProcessCheck = false); setState(
() => isProcessCheck = false);
} }
}); });
}, },
...@@ -2318,8 +2378,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2318,8 +2378,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
), ),
); );
} }
} }),
),
), ),
// Time DI Menu Qris // Time DI Menu Qris
Column( Column(
...@@ -2358,8 +2417,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2358,8 +2417,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
autoHide: Duration(seconds: 2), autoHide: Duration(seconds: 2),
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Waktu pembayaran anda sudah habis !', title:
desc: "Your payment time has expired !", 'Waktu pembayaran anda sudah habis !',
desc:
"Your payment time has expired !",
btnOkIcon: Icons.cancel, btnOkIcon: Icons.cancel,
btnOkColor: Colors.red) btnOkColor: Colors.red)
.show() .show()
...@@ -2372,7 +2433,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2372,7 +2433,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
setState(() { setState(() {
if (result) { if (result) {
isProcessGet = false; isProcessGet = false;
print("pembayaran berhasil dilakukan"); print(
"pembayaran berhasil dilakukan");
Navigator.pop(context); Navigator.pop(context);
showPop(approvalCode); showPop(approvalCode);
} else { } else {
......
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