Commit 3638c385 authored by Izol's avatar Izol

push adjustv3

parent a4e322ba
...@@ -61,14 +61,14 @@ android { ...@@ -61,14 +61,14 @@ android {
versionName flutterVersionName versionName flutterVersionName
// Sun miT2S // Sun miT2S
// ndk {
// abiFilters 'armeabi', 'armeabi-v7a'
// }
// Sun miT2Mini
ndk { ndk {
abiFilters 'arm64-v8a', 'armeabi', 'armeabi-v7a' abiFilters 'armeabi', 'armeabi-v7a'
} }
// Sun miT2Mini
// ndk {
// abiFilters 'arm64-v8a', 'armeabi', 'armeabi-v7a'
// }
} }
buildTypes { buildTypes {
...@@ -96,7 +96,8 @@ dependencies { ...@@ -96,7 +96,8 @@ dependencies {
implementation 'androidx.annotation:annotation:1.5.0' implementation 'androidx.annotation:annotation:1.5.0'
// library mdd // library mdd
implementation(group: 'com.mdd.topup', name: 'mifare_mdd_lib', version: '0.0.11', ext: 'aar') // change 11
implementation(group: 'com.mdd.topup', name: 'mifare_mdd_lib', version: '0.0.40', ext: 'aar')
implementation(group: 'com.mdd.payment', name: 'aar-deviceid-release', version: '2.0.6', ext: 'aar') implementation(group: 'com.mdd.payment', name: 'aar-deviceid-release', version: '2.0.6', ext: 'aar')
implementation(group: 'com.mdd.library', name: 'android-escpos-receipt', version: '1.0.1', ext: 'aar') implementation(group: 'com.mdd.library', name: 'android-escpos-receipt', version: '1.0.1', ext: 'aar')
implementation(group: 'com.mdd.payment', name: 'nativecripto-release', version: '2.0.1', ext: 'aar') implementation(group: 'com.mdd.payment', name: 'nativecripto-release', version: '2.0.1', ext: 'aar')
......
// ignore_for_file: prefer_typing_uninitialized_variables, avoid_print // ignore_for_file: prefer_typing_uninitialized_variables, avoid_print
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:self_service_3/shared/preference_constant.dart'; import 'package:self_service_3/shared/preference_constant.dart';
...@@ -54,6 +55,18 @@ class StartService { ...@@ -54,6 +55,18 @@ class StartService {
String status, String status,
) async { ) async {
var result; var result;
debugPrint('=============PARAMETER PRINT===========');
debugPrint('ticketJson: $ticketJson');
debugPrint('companyName: $companyName');
debugPrint('companyAddress: $companyAddress');
debugPrint('companyPhone: $companyPhone');
debugPrint('approvalCode: $approvalCode');
debugPrint('prevBalance: $prevBalance');
debugPrint('serviceCharge: $serviceCharge');
debugPrint('serviceChargeAmount: $serviceChargeAmount');
debugPrint('denom: $denom');
debugPrint('metodeBayar: $metodeBayar');
debugPrint('status: $status');
try { try {
result = await platform.invokeMethod("print_topup", <String, dynamic>{ result = await platform.invokeMethod("print_topup", <String, dynamic>{
"ticket_json": ticketJson, "ticket_json": ticketJson,
...@@ -81,7 +94,8 @@ class StartService { ...@@ -81,7 +94,8 @@ class StartService {
String samReport, String samReport,
String approvalCode, String approvalCode,
String paymentMethod, String paymentMethod,
String paymentProvider) async { String paymentProvider,
) async {
var result; var result;
try { try {
result = await platform.invokeMethod("topup_confirm", <String, dynamic>{ result = await platform.invokeMethod("topup_confirm", <String, dynamic>{
...@@ -121,7 +135,8 @@ class StartService { ...@@ -121,7 +135,8 @@ class StartService {
return await platform.invokeMethod('bypass_activation'); return await platform.invokeMethod('bypass_activation');
} }
static Future<bool> activateLibrary() async { static Future<bool>
activateLibrary() async {
return await platform.invokeMethod('activate_library'); return await platform.invokeMethod('activate_library');
} }
......
...@@ -74,12 +74,25 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -74,12 +74,25 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
late Timer? timer; late Timer? timer;
bool isShowingDialog = false; bool isShowingDialog = false;
var infoCard, prevInfoCard, balance, var infoCard,
cardExpirity, cardType, deposit, prevInfoCard,
cardNumber, name, getRegDb, balance,
lastBalance, approvalCode, cardExpirity,
amount , report, infoM, cardType,
infoMulti, companyAddress, num; deposit,
cardNumber,
name,
getRegDb,
lastBalance,
approvalCode,
amount,
report,
infoM,
dateTimeCardExpirity,
infoMulti,
companyAddress,
num,
plainCardExpirity;
Map<String, dynamic>? dataQris; Map<String, dynamic>? dataQris;
var countMax = 0; var countMax = 0;
...@@ -231,14 +244,38 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -231,14 +244,38 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
var infoInquiry = jsonDecode(responseInquiry); var infoInquiry = jsonDecode(responseInquiry);
var name = infoMap["name"].toString().trim(); var name = infoMap["name"].toString().trim();
if (infoInquiry["response"]["code"].toString() == "200") { var currentDate = DateTime.now();
print("ini adalah kadaluarsa pada $cardExpirity");
// menyesuaikan tanggal hari ini
var cardExpDate = dateTimeCardExpirity;
// var cardExpDate = DateTime.now().subtract(Duration(days:1));
if (infoInquiry["response"]["code"].toString() == "200" &&
currentDate.isBefore(cardExpDate)) {
print("ini response sukses : ${infoInquiry['response']['message']}"); print("ini response sukses : ${infoInquiry['response']['message']}");
approvalCode = infoInquiry["data"]["approval_code"].toString(); approvalCode = infoInquiry["data"]["approval_code"].toString();
_showQris(context); _showQris(context);
} else if (currentDate.isAfter(cardExpDate)) {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title: 'Maaf Wristband anda sudah habis masa berlakunya!',
desc: "Sorry, your wristband has expired",
btnOkOnPress: () {
setState(() {
isShowingDialog = false;
});
if (timer != null) timer?.cancel();
tapIdle();
},
btnOkIcon: Icons.error,
btnOkColor: Colors.red)
.show();
} else { } else {
print("ini response fail : ${infoInquiry['errors'][0]['details'][0]}"); print("ini response fail : ${infoInquiry['errors'][0]['details'][0]}");
String error = infoInquiry['errors'][0]['details'][0]; String error = infoInquiry['errors'][0]['details'][0];
if(error == "Card not found"){ if (error == "Card not found") {
AwesomeDialog( AwesomeDialog(
context: context, context: context,
dialogType: DialogType.error, dialogType: DialogType.error,
...@@ -247,7 +284,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -247,7 +284,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
title: 'Maaf kartu anda tidak dapat digunakan untuk isi saldo', title: 'Maaf kartu anda tidak dapat digunakan untuk isi saldo',
desc: "Sorry, your card cannot be used to top up", desc: "Sorry, your card cannot be used to top up",
btnOkOnPress: () { btnOkOnPress: () {
setState((){ setState(() {
isShowingDialog = false; isShowingDialog = false;
}); });
if (timer != null) timer?.cancel(); if (timer != null) timer?.cancel();
...@@ -261,7 +298,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -261,7 +298,14 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
} }
Future<String> topUpBalance(String approvalCode) async { Future<String> topUpBalance(String approvalCode) async {
var info, infoMap, lastBalance, samReport, paymentMethod, paymentProvider,metodeBayar,status; var info,
infoMap,
lastBalance,
samReport,
paymentMethod,
paymentProvider,
metodeBayar,
status;
info = await StartService.topupBalanceCard(cardNumber, int.parse(amount)); info = await StartService.topupBalanceCard(cardNumber, int.parse(amount));
infoMap = jsonDecode(info); infoMap = jsonDecode(info);
lastBalance = infoMap['balance'].toString(); lastBalance = infoMap['balance'].toString();
...@@ -274,7 +318,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -274,7 +318,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
var infoConfirm = await StartService.topUpConfirm(cardNumber, lastBalance, var infoConfirm = await StartService.topUpConfirm(cardNumber, lastBalance,
samReport, approvalCode, paymentMethod, paymentProvider); samReport, approvalCode, paymentMethod, paymentProvider);
String readerDate, gateId, persoReff, kodeGate, outletName, versionApp, rawData; String readerDate,
gateId,
persoReff,
kodeGate,
outletName,
versionApp,
rawData;
readerDate = DateFormat("ddMMyyyyHHmmss").format(DateTime.now()); readerDate = DateFormat("ddMMyyyyHHmmss").format(DateTime.now());
gateId = PreferencesHelper.getString('tid'); gateId = PreferencesHelper.getString('tid');
...@@ -284,16 +334,40 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -284,16 +334,40 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
versionApp = PreferencesHelper.getString(kVersionApp); versionApp = PreferencesHelper.getString(kVersionApp);
rawData = (report == null) rawData = (report == null)
? "balance|""$report,""$kodeGate,""$outletName,""$gateId," ? "balance|"
"$cardNumber,""$readerDate,""$amount,""$lastBalance,""$versionApp" "$report,"
: "$kodeGate,""$outletName,""$gateId,""$cardNumber,""$readerDate," "$kodeGate,"
"$amount,""$lastBalance,""$versionApp"; "$outletName,"
"$gateId,"
"$cardNumber,"
"$readerDate,"
"$amount,"
"$lastBalance,"
"$versionApp"
: "$kodeGate,"
"$outletName,"
"$gateId,"
"$cardNumber,"
"$readerDate,"
"$amount,"
"$lastBalance,"
"$versionApp";
print("proses define wristband info"); print("proses define wristband info");
WristbandInfo wristbandInfo = WristbandInfo( WristbandInfo wristbandInfo = WristbandInfo(
readerDate, int.parse(amount), gateId, 'TOPUP', readerDate,
cardNumber, 'card_topup', lastBalance, prevBalance!, int.parse(amount),
"M", rawData, persoReff, 'Link-Aja', 'Berhasil' ); gateId,
'TOPUP',
cardNumber,
'card_topup',
lastBalance,
prevBalance!,
"M",
rawData,
persoReff,
'Link-Aja',
'Berhasil');
DatabaseHelper.insertTransaction(wristbandInfo); DatabaseHelper.insertTransaction(wristbandInfo);
print("ini pesan tersimpan berhasil ke database$wristbandInfo"); print("ini pesan tersimpan berhasil ke database$wristbandInfo");
...@@ -316,7 +390,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -316,7 +390,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
companyPhone, companyPhone,
approvalCode, approvalCode,
prevBalance!, prevBalance!,
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, metodeBayar,
...@@ -400,35 +474,43 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -400,35 +474,43 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Kartu tidak sama ! tempelkan kartu sebelumnya', title: 'Kartu tidak sama ! tempelkan kartu sebelumnya',
desc: "Cards are not the same! please put the previous card ${countMax}", desc:
"Cards are not the same! please put the previous card ${countMax}",
btnOkOnPress: () async { btnOkOnPress: () async {
if (timer != null) timer?.cancel(); if (timer != null) timer?.cancel();
if (countMax < 3) { if (countMax < 3) {
// var isTap = await StartService.getCard(); // var isTap = await StartService.getCard();
// _getInfoBeforeTopup(isTap); // _getInfoBeforeTopup(isTap);
tapBalance(); tapBalance();
}else{ } else {
AwesomeDialog( AwesomeDialog(
context: context, context: context,
dismissOnTouchOutside: false, dismissOnTouchOutside: false,
dialogType: DialogType.error, dialogType: DialogType.error,
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Transaksi anda gagal ! dikarenakan tidak menempelkan kartu sebelumnya', title:
desc: "Your transaction failed ! because didn't attach the previous card!", 'Transaksi anda gagal ! dikarenakan tidak menempelkan kartu sebelumnya',
btnOkOnPress: (){ desc:
countMax = 0 ; "Your transaction failed ! because didn't attach the previous card!",
btnOkOnPress: () {
countMax = 0;
if (timer != null) timer?.cancel(); if (timer != null) timer?.cancel();
String companyName, companyPhone,metodeBayar; String companyName, companyPhone, metodeBayar;
companyName = PreferencesHelper.getString('outletname'); companyName =
companyName = PreferencesHelper.getString('outletname'); PreferencesHelper.getString('outletname');
companyPhone = PreferencesHelper.getString('companyphone'); companyName =
companyAddress = PreferencesHelper.getString('multioutletaddress'); PreferencesHelper.getString('outletname');
companyPhone =
PreferencesHelper.getString('companyphone');
companyAddress = PreferencesHelper.getString(
'multioutletaddress');
lastBalance = infoMap['balance'].toString(); lastBalance = infoMap['balance'].toString();
metodeBayar = "link-aja"; metodeBayar = "link-aja";
String sca = String sca = PreferencesHelper.getString(
PreferencesHelper.getString("multioutletservicechargeamount"); "multioutletservicechargeamount");
String sc = PreferencesHelper.getString("multioutletservicecharge"); String sc = PreferencesHelper.getString(
"multioutletservicecharge");
StartService.print( StartService.print(
prevInfoCard, prevInfoCard,
companyName.split("-")[0], companyName.split("-")[0],
...@@ -436,8 +518,11 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -436,8 +518,11 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
companyPhone, companyPhone,
approvalCode, approvalCode,
lastBalance!, lastBalance!,
sca!+sc!, sca! + sc!,
(int.parse(amount) + int.parse(sca) + int.parse(sc)).toString(), (int.parse(amount) +
int.parse(sca) +
int.parse(sc))
.toString(),
'0', '0',
metodeBayar, metodeBayar,
'Gagal', 'Gagal',
...@@ -454,7 +539,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -454,7 +539,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
.show(); .show();
} }
} }
}); });
} }
...@@ -631,27 +715,32 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -631,27 +715,32 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
} }
void tapDial() async { void tapDial() async {
Future.delayed(const Duration(milliseconds: 200), () async { Future.delayed(const Duration(milliseconds: 500), () async {
var isTap = await StartService.getCard(); var isTap = await StartService.getCard();
try {
var infoMap = jsonDecode(isTap);
_getInfoCard(isTap); _getInfoCard(isTap);
// timer?.cancel();
} catch (e){
print("Error $isTap");
tapDial();
}
}); });
} }
void tapBalance() async { void tapBalance() async {
Future.delayed(const Duration(milliseconds: 200), () async { Future.delayed(const Duration(milliseconds: 200), () async {
var isTap = await StartService.getCard(); var isTap = await StartService.getCard();
print("ini tapcard $isTap"); print("ini tapcard balance $isTap");
if(isTap == "Failed detect card"){ if (isTap == "Failed detect card") {
tapBalance(); tapBalance();
}else{ } else {
_getInfoBeforeTopup(isTap); _getInfoBeforeTopup(isTap);
} }
}); });
} }
Future<void> _showTap() { Future<void> _showTap() {
return showDialog<void>( return showDialog<void>(
context: context, context: context,
barrierDismissible: false, // user must tap button! barrierDismissible: false, // user must tap button!
...@@ -681,6 +770,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -681,6 +770,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
"assets/logo.png", "assets/logo.png",
height: 60, height: 60,
width: 120, width: 120,
// fit:,
), ),
SizedBox( SizedBox(
width: 90, width: 90,
...@@ -852,7 +942,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -852,7 +942,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
setState((){ setState(() {
isShowingDialog = false; isShowingDialog = false;
}); });
Navigator.pop(context); Navigator.pop(context);
...@@ -1057,8 +1147,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1057,8 +1147,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
setState((){ setState(() {
isShowingDialog =false; isShowingDialog = false;
}); });
if (timer != null) timer?.cancel(); if (timer != null) timer?.cancel();
tapIdle(); tapIdle();
...@@ -1362,7 +1452,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1362,7 +1452,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
int.parse(amountController! int.parse(amountController!
.text .text
.replaceAll(",", ""))); .replaceAll(",", "")));
} }
}); });
...@@ -1445,7 +1534,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1445,7 +1534,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
decoration: BoxDecoration( decoration: BoxDecoration(
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.grey.withOpacity(0.3), color: Colors.white.withOpacity(0.3),
//color of shadow //color of shadow
spreadRadius: 3, spreadRadius: 3,
//spread radius //spread radius
...@@ -1546,7 +1635,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1546,7 +1635,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
"Are you sure you want to cancel the payment ?", "Are you sure you want to cancel the payment ?",
btnOkOnPress: () { btnOkOnPress: () {
Navigator.pop(context); Navigator.pop(context);
setState((){ setState(() {
dataQris = null; dataQris = null;
isShowingDialog = false; isShowingDialog = false;
}); });
...@@ -1617,11 +1706,12 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1617,11 +1706,12 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
), ),
//button saya sudah bayar di showqris //button saya sudah bayar di showqris
TextButton( TextButton(
onPressed: () { onPressed: () async {
setState(() => isProcessCheck = true); setState(() => isProcessCheck = true);
_cekStatus().then((value) { try {
bool result = await _cekStatus();
setState(() { setState(() {
if (value) { if (result) {
print("pembayaran berhasil dilakukan"); print("pembayaran berhasil dilakukan");
Navigator.pop(context); Navigator.pop(context);
showPop(approvalCode); showPop(approvalCode);
...@@ -1640,8 +1730,37 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1640,8 +1730,37 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
} }
isProcessCheck = false; isProcessCheck = false;
}); });
}); } catch (e) {
print("Error: $e");
}
}, },
// onPressed: () {
// setState(() => isProcessCheck = true);
// _cekStatus().then((value) {
// setState(() {
// if (value) {
// print("pembayaran berhasil dilakukan");
// Navigator.pop(context);
// showPop(approvalCode);
// } else {
// 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();
// }
// isProcessCheck = false;
// });
// });
// },
child: (isProcessCheck) child: (isProcessCheck)
? Column( ? Column(
children: [ children: [
...@@ -1727,37 +1846,51 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1727,37 +1846,51 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
dismissOnTouchOutside: false, dismissOnTouchOutside: false,
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
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 !",
btnOkOnPress: () { btnOkOnPress: () {
setState(() => isProcessCheck = true); setState(
() => isProcessCheck = true);
_cekStatus().then((value) { _cekStatus().then((value) {
setState(() { setState(() {
if (value) { if (value) {
print("pembayaran berhasil dilakukan"); print(
"pembayaran berhasil dilakukan");
showPop(approvalCode); showPop(approvalCode);
} else { } else {
AwesomeDialog( AwesomeDialog(
context: context, context: context,
dialogType: DialogType.warning, dialogType:
dismissOnTouchOutside: false, DialogType
animType: AnimType.rightSlide, .warning,
headerAnimationLoop: true, dismissOnTouchOutside:
false,
animType: AnimType
.rightSlide,
headerAnimationLoop:
true,
title: title:
'Silakan Ulangi Kembali !', 'Silakan Ulangi Kembali !',
desc: desc:
"please try again !", "please try again !",
btnOkOnPress: () { btnOkOnPress: () {
Navigator.pop(context); Navigator.pop(
setState((){ context);
setState(() {
dataQris = null; dataQris = null;
isShowingDialog = false; isShowingDialog =
false;
}); });
if (timer != null) timer?.cancel(); if (timer != null)
timer?.cancel();
tapIdle(); tapIdle();
}, },
btnOkIcon: Icons.cancel, btnOkIcon:
btnOkColor: Colors.red) Icons.cancel,
btnOkColor:
Colors.red)
.show(); .show();
} }
isProcessCheck = false; isProcessCheck = false;
...@@ -1782,9 +1915,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1782,9 +1915,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
twoDigits(value.inSeconds % 60); twoDigits(value.inSeconds % 60);
// todo for checking in 30 seconds lates // todo for checking in 30 seconds lates
// debugPrint("values in seconds ${value.inSeconds}"); // debugPrint("values in seconds ${value.inSeconds}");
debugPrint("ini pesan second: ${seconds}"); // debugPrint("ini pesan second: ${seconds}");
debugPrint("ini pesan minutes: ${minutes}"); // debugPrint("ini pesan minutes: ${minutes}");
if (minutes == '00' && int.parse(seconds) == int.parse("30") ) { if (minutes == '00' &&
int.parse(seconds) == int.parse("30")) {
if (!isHitApi) { if (!isHitApi) {
isHitApi = true; isHitApi = true;
_cekStatus(isBackgroundServices: true); _cekStatus(isBackgroundServices: true);
...@@ -2132,8 +2266,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2132,8 +2266,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
tapIdle(); tapIdle();
amountController?.clear(); amountController?.clear();
var infoMap = jsonDecode(infoCard); var infoMap = jsonDecode(infoCard);
plainCardExpirity = infoMap['cardExpirity'];
var change = DateTime.fromMillisecondsSinceEpoch( var change = DateTime.fromMillisecondsSinceEpoch(
int.parse(infoMap['cardExpirity']) * 1000); int.parse(infoMap['cardExpirity']) * 1000);
dateTimeCardExpirity = change;
final DateFormat formatter = DateFormat('dd-MMM-yyyy'); final DateFormat formatter = DateFormat('dd-MMM-yyyy');
cardExpirity = formatter.format(change); cardExpirity = formatter.format(change);
deposit = CurrencyFormat.convertToIdr( deposit = CurrencyFormat.convertToIdr(
...@@ -2162,7 +2298,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2162,7 +2298,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Nomor telepon tidak ditemukan !', title: 'Nomor telepon tidak ditemukan !',
desc: "phone number not found !", desc: "phone number not found !",
btnOkOnPress: () {}, btnOkOnPress: () {
setState(() {
isShowingDialog = false;
});
if (timer != null) timer?.cancel();
tapIdle();
},
btnOkIcon: Icons.cancel, btnOkIcon: Icons.cancel,
btnOkColor: Colors.red) btnOkColor: Colors.red)
.show(); .show();
...@@ -2187,6 +2329,30 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2187,6 +2329,30 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
subtitle: 'balance', subtitle: 'balance',
), ),
), ),
// TextButton(
// onPressed: () async{
// var info = {"balance":4004,"cardExpirity":"1706869211","cardNumber":"9876540165008514","cardType":4,"cardUid":"E46B63BA000000000000000000000000","deposit":10000,"isMember":false,"listGate":[],"minBalance":0,"name":"Enzo-08756789987654","point":0,"regDb":"1675333210000000","report":"00000000000000000000000000000000F3003EA8DB630100BB0B0000A40F0000FFFFFFFFFFFFFFFFFFFFFFFF4968968A","ticketExpirity":"1675357199"}.toString();
// print("TestButton Press");
// await StartService.print(
// info,
// "Terminal POS Self Service",
// "Jagakarsa",
// "companyPhone",
// "63dba48c81979",
// "3003",
// "10",
// "10",
// "10",
// "linkaja",
// "Berhasil",
// );
// },
// child: const HomeServices(
// iconUrl: 'assets/ic_send.png',
// title: 'Print test',
// subtitle: 'print',
// ),
// ),
// Container( // Container(
// height: 100, // height: 100,
// width: 100, // width: 100,
......
...@@ -86,35 +86,50 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin{ ...@@ -86,35 +86,50 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin{
} }
void permissionState() async { void permissionState() async {
// Request multiple permissions at once if (await Permission.storage.request().isGranted &&
Map<Permission, PermissionStatus> status = await [Permission.storage, Permission.phone].request(); await Permission.phone.request().isGranted) {
StartService.initLibrary().then((value) {
// Check if all permissions were granted
bool allGranted = true;
status.forEach((permission, permissionStatus) {
if (permissionStatus != PermissionStatus.granted) {
allGranted = false;
}
});
if (allGranted) {
// All permissions were granted
// Initialize library and check activation
StartService.initLibrary().then((value){
Future.delayed(Duration(seconds: 3), () { Future.delayed(Duration(seconds: 3), () {
if (mounted){
checkAktivation(); checkAktivation();
}
}); });
}); });
} else {
// Handle denied permissions Future.delayed(Duration(seconds: 10), () {
status.forEach((permission, permissionStatus) { showDialog(
if (permissionStatus == PermissionStatus.denied) { context: context,
print('$permission permission was denied'); builder: (BuildContext context) {
} return AlertDialog(
title: Text("Error"),
content: Text("The app is taking too long to start. Please try again."),
actions: <Widget>[
TextButton(
child: Text("Try Again"),
onPressed: () {
Navigator.of(context).pop();
permissionState();
},
),
TextButton(
child: Text("Cancel"),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}); });
} }
// You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await [
Permission.phone,
Permission.storage,
].request();
print("phone : ${statuses[Permission.phone]}");
print("storage : ${statuses[Permission.storage]}");
} }
void checkAktivation() { void checkAktivation() {
...@@ -157,7 +172,15 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin{ ...@@ -157,7 +172,15 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin{
), ),
), ),
), ),
// child: Text(
// 'UNDER MAINTENANCE',
// style: blackTextStyle.copyWith(
// fontSize: 30,
// fontWeight: semiBold,
// ),
// ),
), ),
), ),
), ),
] ]
......
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