Commit 14275ca8 authored by Dio Maulana's avatar Dio Maulana

toast jadiin modal dialog

parent 83dab250
......@@ -28,7 +28,7 @@ import 'package:excelso_attendance/resource/size.dart';
import 'package:excelso_attendance/resource/style.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
// import 'package:quiver/async.dart';
import 'package:quiver/async.dart';
class AbsentCameraView extends StatefulWidget {
const AbsentCameraView({
......@@ -130,6 +130,7 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
errorMessage: Strings.cameraNotActive,
),
);
break;
default:
// setState(() {
// errorCamera = "$e";
......@@ -195,6 +196,7 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
errorMessage: Strings.cameraNotActive,
),
);
break;
default:
// setState(() {
// errorCamera = "$e";
......@@ -232,30 +234,45 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
}
// untuk mengetahui lama proses taking foto sampai response sukses
// final int _start = 10000;
// int _longTime = 0;
// CountdownTimer? countDownTimer;
final int _start = 10000;
// ignore: unused_field
int _longTime = 0;
CountdownTimer? countDownTimer;
// void startTimer() {
// print("START TIMER");
// countDownTimer = CountdownTimer(
// Duration(milliseconds: _start),
// const Duration(milliseconds: 1),
// );
void startTimer() {
// print("START TIMER");
countDownTimer = CountdownTimer(
Duration(milliseconds: _start),
const Duration(milliseconds: 1),
);
// var sub = countDownTimer!.listen(null);
// sub.onData((duration) {
// setState(() {
// _longTime = duration.elapsed.inMilliseconds;
// });
// });
// }
var sub = countDownTimer!.listen(null);
sub.onData((duration) {
setState(() {
_longTime = duration.elapsed.inMilliseconds;
});
});
}
// void stopTimer() {
// print("TIMER STOP");
// print("LAMA PROSES $_longTime miliseconds");
// countDownTimer!.cancel();
// }
void stopTimer() async {
// const filename = 'processAttendace.txt';
// String typeAbsen;
// if (widget.isIn) {
// typeAbsen = "Masuk";
// } else {
// typeAbsen = 'Keluar';
// }
// String content = '''User Name: ${widget.profile.name}
// Lama proses absen $typeAbsen : $_longTime ms
// ''';
// print("TIMER STOP");
// print("LAMA PROSES $_longTime miliseconds");
countDownTimer!.cancel();
// await File(filename).writeAsString(content, mode: FileMode.append);
// sendTotelegram(content);
}
@override
Widget build(BuildContext context) {
......@@ -345,7 +362,7 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
left: AppMargin.m16,
),
child: Text(
"Verifikasi Wajah (${cameras!.length})",
"Verifikasi Wajah",
style: getBoldStyle(
color: Colors.white,
fontSize: 17,
......@@ -375,7 +392,7 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
CustomButton(
text: "Submit",
onTap: () async {
// startTimer();
startTimer();
await EasyLoading.show(
status: Strings.pleaseWait,
maskType: EasyLoadingMaskType.none,
......@@ -387,11 +404,20 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
widget.shiftModel!.id,
imageBase64!,
).then((apiResponse) {
// stopTimer();
stopTimer();
EasyLoading.dismiss();
if (apiResponse.error) {
EasyLoading.showToast(
apiResponse.msg);
modalDialogGlobal(
context: context,
size:
MediaQuery.of(context).size,
title: "Gagal",
contentBody: apiResponse.msg,
buttonText: "OK",
tapButton: () {
Navigator.pop(context);
},
);
return;
}
AbsentSuccessModel absentSuccess =
......@@ -415,11 +441,19 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
widget.nik,
imageBase64!,
).then((apiResponse) {
// stopTimer();
stopTimer();
EasyLoading.dismiss();
if (apiResponse.error) {
EasyLoading.showToast(
apiResponse.msg,
modalDialogGlobal(
context: context,
size:
MediaQuery.of(context).size,
title: "Gagal",
contentBody: apiResponse.msg,
buttonText: "OK",
tapButton: () {
Navigator.pop(context);
},
);
return;
}
......
......@@ -138,8 +138,8 @@ Sukses''',
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
blurRadius: 2,
offset: const Offset(5, 5),
blurRadius: 5,
offset: const Offset(0.8, 0.8),
),
],
),
......@@ -212,7 +212,7 @@ Sukses''',
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"[${absentSuccess.branchCode}] ${absentSuccess.branchName}",
absentSuccess.branchName,
style: getSemiBoldStyle(
color: ColorManager.fontBlack,
fontSize: FontSize.s16,
......
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