attendence login/logout has been implemented

This commit is contained in:
Daniah Ayad Al-sultani
2026-01-15 22:35:10 +03:00
parent 3b3ed5e640
commit 56e2c0ffaa
20 changed files with 538 additions and 200 deletions

View File

@@ -2,10 +2,17 @@ import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'dart:async';
import 'dart:io';
class OvalCameraCapturePage extends StatefulWidget {
final bool isLogin;
const OvalCameraCapturePage({super.key, this.isLogin = true});
final Future<void> Function(File image) onCapture;
const OvalCameraCapturePage({
super.key,
this.isLogin = true,
required this.onCapture,
});
@override
State<OvalCameraCapturePage> createState() => _OvalCameraCapturePageState();
@@ -77,20 +84,7 @@ class _OvalCameraCapturePageState extends State<OvalCameraCapturePage> {
_errorMessage = null;
});
_timer = Timer(const Duration(seconds: 3), () {
if (mounted) {
setState(() {
_isSuccess = true;
});
// Auto-close after 2 seconds
Future.delayed(const Duration(seconds: 2), () {
if (mounted) {
Navigator.of(context).pop();
}
});
}
});
_startScan();
} catch (e) {
if (!mounted) return;
@@ -102,6 +96,51 @@ class _OvalCameraCapturePageState extends State<OvalCameraCapturePage> {
}
}
Future<void> _startScan() async {
try {
// Simulate scanning delay
await Future.delayed(const Duration(seconds: 2));
if (!mounted ||
_cameraController == null ||
!_cameraController!.value.isInitialized) {
return;
}
final xFile = await _cameraController!.takePicture();
final file = File(xFile.path);
await widget.onCapture(file);
if (mounted) {
setState(() {
_isSuccess = true;
});
// Auto-close after 2 seconds
Future.delayed(const Duration(seconds: 2), () {
if (mounted) {
Navigator.of(context).pop();
}
});
}
} catch (e) {
if (mounted) {
setState(() {
_errorMessage = e.toString(); // Show error to user
});
// Auto-close or let user retry? For now let's just show error.
// If we want to auto-close on error:
Future.delayed(const Duration(seconds: 3), () {
if (mounted) {
Navigator.of(context).pop();
}
});
}
}
}
@override
void dispose() {
_cameraController?.dispose();