Used awesome snackbar on attendance_screen
This commit is contained in:
parent
c6f536edeb
commit
52ef36faac
|
|
@ -15,6 +15,7 @@ import '../../providers/whereabouts_provider.dart';
|
||||||
import '../../providers/workforce_provider.dart';
|
import '../../providers/workforce_provider.dart';
|
||||||
import '../../theme/m3_motion.dart';
|
import '../../theme/m3_motion.dart';
|
||||||
import '../../utils/app_time.dart';
|
import '../../utils/app_time.dart';
|
||||||
|
import '../../utils/snackbar.dart';
|
||||||
import '../../widgets/responsive_body.dart';
|
import '../../widgets/responsive_body.dart';
|
||||||
|
|
||||||
class AttendanceScreen extends ConsumerStatefulWidget {
|
class AttendanceScreen extends ConsumerStatefulWidget {
|
||||||
|
|
@ -333,9 +334,7 @@ class _CheckInTabState extends ConsumerState<_CheckInTab> {
|
||||||
inside = dist <= (geoCfg.radiusMeters ?? 0);
|
inside = dist <= (geoCfg.radiusMeters ?? 0);
|
||||||
}
|
}
|
||||||
if (!inside && mounted) {
|
if (!inside && mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
showWarningSnackBar(context, 'You are outside the geofence area.');
|
||||||
const SnackBar(content: Text('You are outside the geofence area.')),
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -347,15 +346,11 @@ class _CheckInTabState extends ConsumerState<_CheckInTab> {
|
||||||
lng: position.longitude,
|
lng: position.longitude,
|
||||||
);
|
);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
showSuccessSnackBar(context, 'Checked in successfully.');
|
||||||
const SnackBar(content: Text('Checked in successfully.')),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
showErrorSnackBar(context, 'Check-in failed: $e');
|
||||||
context,
|
|
||||||
).showSnackBar(SnackBar(content: Text('Check-in failed: $e')));
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) setState(() => _loading = false);
|
if (mounted) setState(() => _loading = false);
|
||||||
|
|
@ -378,15 +373,11 @@ class _CheckInTabState extends ConsumerState<_CheckInTab> {
|
||||||
lng: position.longitude,
|
lng: position.longitude,
|
||||||
);
|
);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
showSuccessSnackBar(context, 'Checked out successfully.');
|
||||||
const SnackBar(content: Text('Checked out successfully.')),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
showErrorSnackBar(context, 'Check-out failed: $e');
|
||||||
context,
|
|
||||||
).showSnackBar(SnackBar(content: Text('Check-out failed: $e')));
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) setState(() => _loading = false);
|
if (mounted) setState(() => _loading = false);
|
||||||
|
|
@ -1334,9 +1325,7 @@ class _PassSlipTabState extends ConsumerState<_PassSlipTab> {
|
||||||
Future<void> _requestSlip(String scheduleId) async {
|
Future<void> _requestSlip(String scheduleId) async {
|
||||||
final reason = _reasonController.text.trim();
|
final reason = _reasonController.text.trim();
|
||||||
if (reason.isEmpty) {
|
if (reason.isEmpty) {
|
||||||
ScaffoldMessenger.of(
|
showWarningSnackBar(context, 'Please enter a reason.');
|
||||||
context,
|
|
||||||
).showSnackBar(const SnackBar(content: Text('Please enter a reason.')));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setState(() => _submitting = true);
|
setState(() => _submitting = true);
|
||||||
|
|
@ -1367,15 +1356,11 @@ class _PassSlipTabState extends ConsumerState<_PassSlipTab> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
showSuccessSnackBar(context, 'Pass slip request submitted.');
|
||||||
const SnackBar(content: Text('Pass slip request submitted.')),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
showErrorSnackBar(context, 'Failed: $e');
|
||||||
context,
|
|
||||||
).showSnackBar(SnackBar(content: Text('Failed: $e')));
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) setState(() => _submitting = false);
|
if (mounted) setState(() => _submitting = false);
|
||||||
|
|
@ -1387,15 +1372,11 @@ class _PassSlipTabState extends ConsumerState<_PassSlipTab> {
|
||||||
try {
|
try {
|
||||||
await ref.read(passSlipControllerProvider).approveSlip(slipId);
|
await ref.read(passSlipControllerProvider).approveSlip(slipId);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
showSuccessSnackBar(context, 'Pass slip approved.');
|
||||||
context,
|
|
||||||
).showSnackBar(const SnackBar(content: Text('Pass slip approved.')));
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
showErrorSnackBar(context, 'Failed: $e');
|
||||||
context,
|
|
||||||
).showSnackBar(SnackBar(content: Text('Failed: $e')));
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) setState(() => _submitting = false);
|
if (mounted) setState(() => _submitting = false);
|
||||||
|
|
@ -1407,15 +1388,11 @@ class _PassSlipTabState extends ConsumerState<_PassSlipTab> {
|
||||||
try {
|
try {
|
||||||
await ref.read(passSlipControllerProvider).rejectSlip(slipId);
|
await ref.read(passSlipControllerProvider).rejectSlip(slipId);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
showSuccessSnackBar(context, 'Pass slip rejected.');
|
||||||
context,
|
|
||||||
).showSnackBar(const SnackBar(content: Text('Pass slip rejected.')));
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
showErrorSnackBar(context, 'Failed: $e');
|
||||||
context,
|
|
||||||
).showSnackBar(SnackBar(content: Text('Failed: $e')));
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) setState(() => _submitting = false);
|
if (mounted) setState(() => _submitting = false);
|
||||||
|
|
@ -1427,15 +1404,11 @@ class _PassSlipTabState extends ConsumerState<_PassSlipTab> {
|
||||||
try {
|
try {
|
||||||
await ref.read(passSlipControllerProvider).completeSlip(slipId);
|
await ref.read(passSlipControllerProvider).completeSlip(slipId);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
showSuccessSnackBar(context, 'Pass slip completed.');
|
||||||
context,
|
|
||||||
).showSnackBar(const SnackBar(content: Text('Pass slip completed.')));
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
showErrorSnackBar(context, 'Failed: $e');
|
||||||
context,
|
|
||||||
).showSnackBar(SnackBar(content: Text('Failed: $e')));
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) setState(() => _submitting = false);
|
if (mounted) setState(() => _submitting = false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user