attendence login/logout has been implemented
This commit is contained in:
@@ -4,6 +4,12 @@ import 'package:coda_project/presentation/screens/user_settings_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import '../widgets/settings_bar.dart';
|
||||
import '../../core/di/injection_container.dart';
|
||||
import '../../domain/models/attendance_login_request.dart';
|
||||
import '../../domain/models/attendance_logout_request.dart';
|
||||
import '../../domain/usecases/attendance_login_usecase.dart';
|
||||
import '../../domain/usecases/attendance_logout_usecase.dart';
|
||||
import '../../data/datasources/user_local_data_source.dart';
|
||||
|
||||
class AttendanceScreen extends StatelessWidget {
|
||||
const AttendanceScreen({super.key});
|
||||
@@ -138,12 +144,40 @@ class AttendanceScreen extends StatelessWidget {
|
||||
child: _FingerButton(
|
||||
icon: "assets/images/faceLogin.svg",
|
||||
label: "تسجيل الدخول",
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => OvalCameraCapturePage(isLogin: true),
|
||||
),
|
||||
);
|
||||
onTap: () async {
|
||||
final employeeId =
|
||||
await sl<UserLocalDataSource>().getCachedEmployeeId();
|
||||
print("ATTENDANCE_SCREEN: Retrieved EmployeeId: $employeeId");
|
||||
if (employeeId == null) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('خطأ: لم يتم العثور على رقم الموظف'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(_) => OvalCameraCapturePage(
|
||||
isLogin: true,
|
||||
onCapture: (imageFile) async {
|
||||
final loginUseCase =
|
||||
sl<AttendanceLoginUsecase>();
|
||||
await loginUseCase(
|
||||
AttendanceLoginRequest(
|
||||
employeeId: employeeId,
|
||||
faceImage: imageFile,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -178,12 +212,39 @@ class AttendanceScreen extends StatelessWidget {
|
||||
child: _FingerButton(
|
||||
icon: "assets/images/faceLogout.svg",
|
||||
label: "تسجيل خروج",
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => OvalCameraCapturePage(isLogin: false),
|
||||
),
|
||||
);
|
||||
onTap: () async {
|
||||
final employeeId =
|
||||
await sl<UserLocalDataSource>().getCachedEmployeeId();
|
||||
if (employeeId == null) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('خطأ: لم يتم العثور على رقم الموظف'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(_) => OvalCameraCapturePage(
|
||||
isLogin: false,
|
||||
onCapture: (imageFile) async {
|
||||
final logoutUseCase =
|
||||
sl<AttendanceLogoutUseCase>();
|
||||
await logoutUseCase(
|
||||
AttendanceLogoutRequest(
|
||||
employeeId: employeeId,
|
||||
faceImage: imageFile,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user