Added programmer role and fixed snackbar not showing

This commit is contained in:
2026-03-16 07:23:20 +08:00
parent 9f7791e56f
commit 81853c4367
23 changed files with 362 additions and 65 deletions
+14 -17
View File
@@ -663,8 +663,7 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
),
);
if (mounted) {
showSuccessSnackBar(
context,
showSuccessSnackBarGlobal(
'Task resumed',
);
}
@@ -682,16 +681,14 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
),
);
if (mounted) {
showInfoSnackBar(
context,
showInfoSnackBarGlobal(
'Task paused',
);
}
}
} catch (e) {
if (mounted) {
showErrorSnackBar(
context,
showErrorSnackBarGlobal(
e.toString(),
);
}
@@ -4310,8 +4307,7 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
// Validate IT staff assignment before starting or completing
if ((value == 'in_progress' || value == 'completed') &&
!hasAssignedItStaff) {
showWarningSnackBar(
context,
showWarningSnackBarGlobal(
'Please assign at least one IT Staff member before ${value == 'in_progress' ? 'starting' : 'completing'} this task.',
);
return;
@@ -4327,7 +4323,7 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
} catch (e) {
// surface validation or other errors to user
if (mounted) {
showErrorSnackBar(context, e.toString());
showErrorSnackBarGlobal(e.toString());
}
}
},
@@ -4362,6 +4358,7 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
}
final isGlobal =
profile.role == 'admin' ||
profile.role == 'programmer' ||
profile.role == 'dispatcher' ||
profile.role == 'it_staff';
if (isGlobal) {
@@ -4390,7 +4387,7 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
if (bytes == null) {
if (mounted) {
showErrorSnackBar(context, 'Failed to read file');
showErrorSnackBarGlobal('Failed to read file');
}
return;
}
@@ -4399,7 +4396,7 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
const maxSizeBytes = 25 * 1024 * 1024;
if (bytes.length > maxSizeBytes) {
if (mounted) {
showErrorSnackBar(context, 'File size exceeds 25MB limit');
showErrorSnackBarGlobal('File size exceeds 25MB limit');
}
return;
}
@@ -4457,12 +4454,12 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
if (uploadSuccess) {
debugPrint('Showing success message and reloading attachments');
showSuccessSnackBar(context, 'File uploaded successfully');
showSuccessSnackBarGlobal('File uploaded successfully');
// Reload attachments list (non-blocking)
_loadAttachments(taskId);
debugPrint('Attachment reload triggered');
} else {
showErrorSnackBar(context, 'Upload failed: $errorMessage');
showErrorSnackBarGlobal('Upload failed: $errorMessage');
}
} catch (e) {
if (mounted) {
@@ -4536,15 +4533,15 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
if (mounted) {
if (savePath != null && savePath.isNotEmpty) {
showSuccessSnackBar(context, 'File saved to: $savePath');
showSuccessSnackBarGlobal('File saved to: $savePath');
} else {
showInfoSnackBar(context, 'Download cancelled');
showInfoSnackBarGlobal('Download cancelled');
}
}
} catch (e) {
debugPrint('Download error: $e');
if (mounted) {
showErrorSnackBar(context, 'Download error: $e');
showErrorSnackBarGlobal('Download error: $e');
}
}
}
@@ -4576,7 +4573,7 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
]);
if (mounted) {
showSuccessSnackBar(context, 'Attachment deleted');
showSuccessSnackBarGlobal('Attachment deleted');
// Reload attachments list
await _loadAttachments(taskId);
}
+2 -2
View File
@@ -122,6 +122,7 @@ class _TasksListScreenState extends ConsumerState<TasksListScreen>
data: (profile) =>
profile != null &&
(profile.role == 'admin' ||
profile.role == 'programmer' ||
profile.role == 'dispatcher' ||
profile.role == 'it_staff'),
orElse: () => false,
@@ -862,8 +863,7 @@ class _TasksListScreenState extends ConsumerState<TasksListScreen>
);
if (context.mounted) {
Navigator.of(dialogContext).pop();
showSuccessSnackBar(
context,
showSuccessSnackBarGlobal(
'Task "$title" has been created successfully.',
);
}