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