|
|
|
@ -37,7 +37,8 @@ class Utils {
|
|
|
|
timeInSecForIosWeb: 1,
|
|
|
|
timeInSecForIosWeb: 1,
|
|
|
|
backgroundColor: Colors.black54,
|
|
|
|
backgroundColor: Colors.black54,
|
|
|
|
textColor: Colors.white,
|
|
|
|
textColor: Colors.white,
|
|
|
|
fontSize: 13.0);
|
|
|
|
fontSize: 13.0,
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static dynamic getNotNullValue(List<dynamic> list, int index) {
|
|
|
|
static dynamic getNotNullValue(List<dynamic> list, int index) {
|
|
|
|
@ -63,12 +64,7 @@ class Utils {
|
|
|
|
static void showLoading(BuildContext context) {
|
|
|
|
static void showLoading(BuildContext context) {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
_isLoadingVisible = true;
|
|
|
|
_isLoadingVisible = true;
|
|
|
|
showDialog(
|
|
|
|
showDialog(context: context, barrierColor: Colors.black.withOpacity(0.5), useRootNavigator: false, builder: (BuildContext context) => LoadingDialog()).then((value) {
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
barrierColor: Colors.black.withOpacity(0.5),
|
|
|
|
|
|
|
|
useRootNavigator: false,
|
|
|
|
|
|
|
|
builder: (BuildContext context) => LoadingDialog(),
|
|
|
|
|
|
|
|
).then((value) {
|
|
|
|
|
|
|
|
_isLoadingVisible = false;
|
|
|
|
_isLoadingVisible = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -118,7 +114,8 @@ class Utils {
|
|
|
|
showDialog(
|
|
|
|
showDialog(
|
|
|
|
barrierDismissible: false,
|
|
|
|
barrierDismissible: false,
|
|
|
|
context: cxt,
|
|
|
|
context: cxt,
|
|
|
|
builder: (cxt) => ConfirmDialog(
|
|
|
|
builder:
|
|
|
|
|
|
|
|
(cxt) => ConfirmDialog(
|
|
|
|
message: errorMessage,
|
|
|
|
message: errorMessage,
|
|
|
|
onTap: () {
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pushNamedAndRemoveUntil(cxt, AppRoutes.login, (Route<dynamic> route) => false);
|
|
|
|
Navigator.pushNamedAndRemoveUntil(cxt, AppRoutes.login, (Route<dynamic> route) => false);
|
|
|
|
@ -138,33 +135,18 @@ class Utils {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future showErrorDialog({required BuildContext context, required VoidCallback onOkTapped, required String message}) async {
|
|
|
|
static Future showErrorDialog({required BuildContext context, required VoidCallback onOkTapped, required String message}) async {
|
|
|
|
return showDialog(
|
|
|
|
return showDialog(context: context, builder: (BuildContext context) => ConfirmDialog(message: message, onTap: onOkTapped));
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
builder: (BuildContext context) => ConfirmDialog(
|
|
|
|
|
|
|
|
message: message,
|
|
|
|
|
|
|
|
onTap: onOkTapped,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void confirmDialog(cxt, String message, {VoidCallback? onTap}) {
|
|
|
|
static void confirmDialog(cxt, String message, {VoidCallback? onTap}) {
|
|
|
|
showDialog(
|
|
|
|
showDialog(context: cxt, builder: (BuildContext cxt) => ConfirmDialog(message: message, onTap: onTap));
|
|
|
|
context: cxt,
|
|
|
|
|
|
|
|
builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
|
|
|
message: message,
|
|
|
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Widget getNoDataWidget(BuildContext context) {
|
|
|
|
static Widget getNoDataWidget(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
children: [SvgPicture.asset('assets/images/not_found.svg', width: 110.0, height: 110.0), LocaleKeys.noDataAvailable.tr().toText16().paddingOnly(top: 15)],
|
|
|
|
SvgPicture.asset('assets/images/not_found.svg', width: 110.0, height: 110.0),
|
|
|
|
|
|
|
|
LocaleKeys.noDataAvailable.tr().toText16().paddingOnly(top: 15),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
).center;
|
|
|
|
).center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -172,10 +154,7 @@ class Utils {
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
children: [SvgPicture.asset('assets/images/not_found.svg', width: 110.0, height: 110.0), LocaleKeys.noDataAvailable.tr().toText16().paddingOnly(top: 15)],
|
|
|
|
SvgPicture.asset('assets/images/not_found.svg', width: 110.0, height: 110.0),
|
|
|
|
|
|
|
|
LocaleKeys.noDataAvailable.tr().toText16().paddingOnly(top: 15),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
).center;
|
|
|
|
).center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -209,17 +188,7 @@ class Utils {
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
children: [6.height, alignCenter ? text.toText12().center : text.toText12(), 5.height, if (showDivider) const Divider(height: 1, color: Color(0xff2E303A), thickness: 1)],
|
|
|
|
6.height,
|
|
|
|
|
|
|
|
alignCenter ? text.toText12().center : text.toText12(),
|
|
|
|
|
|
|
|
5.height,
|
|
|
|
|
|
|
|
if (showDivider)
|
|
|
|
|
|
|
|
const Divider(
|
|
|
|
|
|
|
|
height: 1,
|
|
|
|
|
|
|
|
color: Color(0xff2E303A),
|
|
|
|
|
|
|
|
thickness: 1,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -228,16 +197,14 @@ class Utils {
|
|
|
|
color: background,
|
|
|
|
color: background,
|
|
|
|
border: Border.all(
|
|
|
|
border: Border.all(
|
|
|
|
width: 1, //
|
|
|
|
width: 1, //
|
|
|
|
color: background // <--- border width here
|
|
|
|
color: background, // <--- border width here
|
|
|
|
),
|
|
|
|
),
|
|
|
|
borderRadius: BorderRadius.circular(radius),
|
|
|
|
borderRadius: BorderRadius.circular(radius),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Widget mHeight(double h) {
|
|
|
|
static Widget mHeight(double h) {
|
|
|
|
return Container(
|
|
|
|
return Container(height: h);
|
|
|
|
height: h,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Widget mDivider(Color color) {
|
|
|
|
static Widget mDivider(Color color) {
|
|
|
|
@ -352,7 +319,8 @@ class Utils {
|
|
|
|
if (!Platform.isIOS) {
|
|
|
|
if (!Platform.isIOS) {
|
|
|
|
await showCupertinoModalPopup(
|
|
|
|
await showCupertinoModalPopup(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext cxt) => Container(
|
|
|
|
builder:
|
|
|
|
|
|
|
|
(BuildContext cxt) => Container(
|
|
|
|
height: 250,
|
|
|
|
height: 250,
|
|
|
|
color: Colors.white,
|
|
|
|
color: Colors.white,
|
|
|
|
child: CupertinoDatePicker(
|
|
|
|
child: CupertinoDatePicker(
|
|
|
|
@ -377,9 +345,12 @@ class Utils {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void readNFc({required Function(String) onRead}) {
|
|
|
|
static void readNFc({required Function(String) onRead}) {
|
|
|
|
NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async {
|
|
|
|
NfcManager.instance
|
|
|
|
|
|
|
|
.startSession(
|
|
|
|
|
|
|
|
onDiscovered: (NfcTag tag) async {
|
|
|
|
MifareUltralight f;
|
|
|
|
MifareUltralight f;
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
|
|
|
|
print(tag);
|
|
|
|
f = MifareUltralight(tag: tag, identifier: tag.data["nfca"]["identifier"], type: 2, maxTransceiveLength: 252, timeout: 22);
|
|
|
|
f = MifareUltralight(tag: tag, identifier: tag.data["nfca"]["identifier"], type: 2, maxTransceiveLength: 252, timeout: 22);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
f = MifareUltralight(tag: tag, identifier: tag.data["mifare"]["identifier"], type: 2, maxTransceiveLength: 252, timeout: 22);
|
|
|
|
f = MifareUltralight(tag: tag, identifier: tag.data["mifare"]["identifier"], type: 2, maxTransceiveLength: 252, timeout: 22);
|
|
|
|
@ -387,7 +358,10 @@ class Utils {
|
|
|
|
String identifier = f.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
|
|
|
|
String identifier = f.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
|
|
|
|
NfcManager.instance.stopSession();
|
|
|
|
NfcManager.instance.stopSession();
|
|
|
|
onRead(identifier);
|
|
|
|
onRead(identifier);
|
|
|
|
}).catchError((err) {
|
|
|
|
},
|
|
|
|
|
|
|
|
pollingOptions: {NfcPollingOption.iso14443},
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.catchError((err) {
|
|
|
|
print(err);
|
|
|
|
print(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|