si
This commit is contained in:
1 parent
a652232b25
commit
eb31ad7173
5 files changed
+403
-151
No files matched your search
@@ -115,7 +115,6 @@ class _SharedAttachmentsSectionState extends State<SharedAttachmentsSection> {
|
||||
attachmentsBloc.add(ParentEntitySavedEvent(targetId));
|
||||
}
|
||||
|
||||
// Ora che abbiamo la certezza matematica di avere un targetId, apriamo il picker
|
||||
final result = await FilePicker.pickFiles(
|
||||
allowMultiple: true,
|
||||
type: FileType.custom,
|
||||
@@ -123,9 +122,147 @@ class _SharedAttachmentsSectionState extends State<SharedAttachmentsSection> {
|
||||
withData: true,
|
||||
);
|
||||
|
||||
if (result != null && mounted) {
|
||||
// Ora il BLoC eseguirà l'ambiente di "Upload immediato" (Bivio 2) perché ha l'ID aggiornato!
|
||||
attachmentsBloc.add(AddAttachmentsEvent(result.files));
|
||||
if (result == null || result.files.isEmpty || !mounted) return;
|
||||
|
||||
final List<PlatformFile> processedFiles = [];
|
||||
|
||||
for (int i = 0; i < result.files.length; i++) {
|
||||
final file = result.files[i];
|
||||
|
||||
Widget previewWidget;
|
||||
final ext = file.extension?.toLowerCase() ?? '';
|
||||
|
||||
if ((ext == 'jpg' || ext == 'jpeg' || ext == 'png') &&
|
||||
file.bytes != null) {
|
||||
previewWidget = Image.memory(file.bytes!, fit: BoxFit.contain);
|
||||
} else if (ext == 'pdf') {
|
||||
previewWidget = const Center(
|
||||
child: Icon(Icons.picture_as_pdf, size: 80, color: Colors.red),
|
||||
);
|
||||
} else {
|
||||
previewWidget = const Center(
|
||||
child: Icon(Icons.insert_drive_file, size: 80, color: Colors.blue),
|
||||
);
|
||||
}
|
||||
|
||||
final rawOriginalName =
|
||||
file.name.contains('.')
|
||||
? file.name.substring(0, file.name.lastIndexOf('.'))
|
||||
: file.name;
|
||||
|
||||
final defaultSuggested =
|
||||
result.files.length == 1
|
||||
? widget.titleForUpload
|
||||
: '${widget.titleForUpload}_${i + 1}';
|
||||
|
||||
final finalName = await showDialog<String>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder:
|
||||
(_) => QuickRenameDialog(
|
||||
title:
|
||||
result.files.length == 1
|
||||
? 'Nome Allegato'
|
||||
: 'Nome Allegato (${i + 1}/${result.files.length})',
|
||||
suggestedName:
|
||||
defaultSuggested.isNotEmpty
|
||||
? defaultSuggested
|
||||
: rawOriginalName,
|
||||
suffixText: ext.isNotEmpty ? '.$ext' : null,
|
||||
confirmButtonText: 'Importa (Invio)',
|
||||
previewWidget: previewWidget,
|
||||
),
|
||||
);
|
||||
|
||||
if (finalName != null && finalName.trim().isNotEmpty) {
|
||||
final cleanName = finalName.trim();
|
||||
final extString = ext.isNotEmpty ? '.$ext' : '';
|
||||
final fullNewName =
|
||||
cleanName.endsWith(extString) ? cleanName : '$cleanName$extString';
|
||||
|
||||
final updatedFile = PlatformFile(
|
||||
name: fullNewName,
|
||||
size: file.size,
|
||||
path: file.path,
|
||||
bytes: file.bytes,
|
||||
readStream: file.readStream,
|
||||
);
|
||||
processedFiles.add(updatedFile);
|
||||
} else {
|
||||
processedFiles.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (processedFiles.isEmpty || !mounted) return;
|
||||
|
||||
// 1. Aggiungiamo i file rinominati al BLoC
|
||||
attachmentsBloc.add(AddAttachmentsEvent(processedFiles));
|
||||
|
||||
// 2. Chiediamo se cancellare i file fisici dal computer
|
||||
if (!kIsWeb) {
|
||||
final filesOnDisk =
|
||||
processedFiles
|
||||
.where((f) => f.path != null && File(f.path!).existsSync())
|
||||
.toList();
|
||||
|
||||
if (filesOnDisk.isNotEmpty && mounted) {
|
||||
final shouldDelete = await showDialog<bool>(
|
||||
context: context,
|
||||
builder:
|
||||
(dialogContext) => AlertDialog(
|
||||
title: const Row(
|
||||
children: [
|
||||
Icon(Icons.delete_forever, color: Colors.red),
|
||||
SizedBox(width: 8),
|
||||
Text('Eliminare file dal computer?'),
|
||||
],
|
||||
),
|
||||
content: Text(
|
||||
'I file (${filesOnDisk.length}) sono stati importati in Flux.\n\nVuoi cancellare i file originali dal tuo computer per liberare spazio?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, false),
|
||||
child: const Text('No, mantieni sul PC'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
child: const Text('Sì, elimina dal PC'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (shouldDelete == true) {
|
||||
int deletedCount = 0;
|
||||
for (var f in filesOnDisk) {
|
||||
try {
|
||||
final fileObj = File(f.path!);
|
||||
if (fileObj.existsSync()) {
|
||||
await fileObj.delete();
|
||||
deletedCount++;
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Errore durante l\'eliminazione del file locale: $e');
|
||||
}
|
||||
}
|
||||
|
||||
if (mounted && deletedCount > 0) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'$deletedCount file fisici eliminati dal computer.',
|
||||
),
|
||||
backgroundColor: Colors.orange.shade800,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,17 @@ import 'package:flutter/material.dart';
|
||||
class QuickRenameDialog extends StatefulWidget {
|
||||
final String suggestedName;
|
||||
final Widget previewWidget; // Può essere Image.memory o un'icona PDF
|
||||
final String title;
|
||||
final String? suffixText;
|
||||
final String confirmButtonText;
|
||||
|
||||
const QuickRenameDialog({
|
||||
super.key,
|
||||
required this.suggestedName,
|
||||
required this.previewWidget,
|
||||
this.title = 'Rinomina File',
|
||||
this.suffixText = '.pdf',
|
||||
this.confirmButtonText = 'Conferma (Invio)',
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -45,7 +51,7 @@ class _QuickRenameDialogState extends State<QuickRenameDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Rinomina per Export'),
|
||||
title: Text(widget.title),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -60,10 +66,10 @@ class _QuickRenameDialogState extends State<QuickRenameDialog> {
|
||||
TextField(
|
||||
controller: _nameCtrl,
|
||||
focusNode: _focusNode,
|
||||
decoration: const InputDecoration(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Nome del file',
|
||||
suffixText: '.pdf', // Facciamo capire che sarà un PDF
|
||||
border: OutlineInputBorder(),
|
||||
suffixText: widget.suffixText,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
// MAGIA UX 2: Se preme invio sulla tastiera, salva e chiude!
|
||||
onSubmitted: (value) => Navigator.of(context).pop(value),
|
||||
@@ -77,7 +83,7 @@ class _QuickRenameDialogState extends State<QuickRenameDialog> {
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.of(context).pop(_nameCtrl.text),
|
||||
child: const Text('Esporta (Invio)'),
|
||||
child: Text(widget.confirmButtonText),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -159,6 +159,30 @@ class OperationFormCubit extends Cubit<OperationFormState> {
|
||||
}
|
||||
}
|
||||
|
||||
// --- ELIMINAZIONE DEFINITIVA PRATICA ---
|
||||
Future<void> deleteCurrentOperation() async {
|
||||
final id = state.operation.id;
|
||||
if (id == null || id.isEmpty) return;
|
||||
|
||||
emit(state.copyWith(status: OperationFormStatus.saving));
|
||||
try {
|
||||
await _repository.deleteOperation(id);
|
||||
emit(
|
||||
state.copyWith(
|
||||
status: OperationFormStatus.discarded,
|
||||
hasUnsavedChanges: false,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
status: OperationFormStatus.failure,
|
||||
errorMessage: "Errore durante l'eliminazione dell'operazione: $e",
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// --- GESTIONE DEI CAMPI IN TEMPO REALE ---
|
||||
void updateFields({
|
||||
String? reference,
|
||||
|
||||
@@ -114,25 +114,21 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed:
|
||||
() => Navigator.of(
|
||||
dialogContext,
|
||||
).pop(_UnsavedChangesAction.cancel),
|
||||
onPressed: () =>
|
||||
Navigator.of(dialogContext).pop(_UnsavedChangesAction.cancel),
|
||||
child: const Text('Annulla'),
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.red),
|
||||
onPressed:
|
||||
() => Navigator.of(
|
||||
dialogContext,
|
||||
).pop(_UnsavedChangesAction.discard),
|
||||
onPressed: () => Navigator.of(
|
||||
dialogContext,
|
||||
).pop(_UnsavedChangesAction.discard),
|
||||
child: const Text('Chiudi senza salvare'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed:
|
||||
() => Navigator.of(
|
||||
dialogContext,
|
||||
).pop(_UnsavedChangesAction.saveAndClose),
|
||||
onPressed: () => Navigator.of(
|
||||
dialogContext,
|
||||
).pop(_UnsavedChangesAction.saveAndClose),
|
||||
child: const Text('Salva e chiudi'),
|
||||
),
|
||||
],
|
||||
@@ -225,17 +221,15 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
Navigator.maybePop(formContext);
|
||||
},
|
||||
),
|
||||
title: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
'Addetto selezionato: ${formState.operation.staffDisplayName}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (formState.hasUnsavedChanges) ...[
|
||||
const SizedBox(width: 8),
|
||||
Tooltip(
|
||||
title: Text(
|
||||
'Addetto selezionato: ${formState.operation.staffDisplayName}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
actions: [
|
||||
if (formState.hasUnsavedChanges)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 4.0),
|
||||
child: Tooltip(
|
||||
message: 'Modifiche non salvate',
|
||||
child: Container(
|
||||
width: 10,
|
||||
@@ -246,23 +240,63 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.save),
|
||||
tooltip: formState.hasUnsavedChanges
|
||||
? 'Salva modifiche'
|
||||
: 'Nessuna modifica da salvare',
|
||||
onPressed:
|
||||
formState.hasUnsavedChanges &&
|
||||
formState.status != OperationFormStatus.saving
|
||||
? () => _saveOperation(
|
||||
targetStatus: formState.operation.status,
|
||||
isClosingIntent: false,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete_outline, color: Colors.red),
|
||||
tooltip: 'Elimina pratica',
|
||||
onPressed:
|
||||
formState.status != OperationFormStatus.saving
|
||||
? () => _showDeleteConfirmationDialog(formContext)
|
||||
: null,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10),
|
||||
child: Chip(
|
||||
label: Text(
|
||||
formState.operation.status.displayName,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
),
|
||||
child: ActionChip(
|
||||
avatar: Icon(
|
||||
formState.operation.status == OperationStatus.success
|
||||
? Icons.check_circle
|
||||
: Icons.error_outline,
|
||||
color: Colors.white,
|
||||
size: 14,
|
||||
),
|
||||
label: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
formState.operation.status.displayName,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
const Icon(
|
||||
Icons.arrow_drop_down,
|
||||
color: Colors.white,
|
||||
size: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
backgroundColor: _getStatusColor(
|
||||
formState.operation.status,
|
||||
),
|
||||
side: BorderSide.none,
|
||||
onPressed: () => _showStatusBottomSheet(formContext),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -280,12 +314,11 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
child: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth:
|
||||
isUltraWide
|
||||
? 1600
|
||||
: isDesktop
|
||||
? 1200
|
||||
: 800,
|
||||
maxWidth: isUltraWide
|
||||
? 1600
|
||||
: isDesktop
|
||||
? 1200
|
||||
: 800,
|
||||
),
|
||||
child: _buildResponsiveLayout(
|
||||
isUltraWide,
|
||||
@@ -323,22 +356,20 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
),
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed:
|
||||
() => _saveOperation(
|
||||
targetStatus: formState.operation.status,
|
||||
isClosingIntent: true,
|
||||
),
|
||||
child:
|
||||
formState.status == OperationFormStatus.saving
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Text('Salva e chiudi'),
|
||||
onPressed: () => _saveOperation(
|
||||
targetStatus: formState.operation.status,
|
||||
isClosingIntent: true,
|
||||
),
|
||||
child: formState.status == OperationFormStatus.saving
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Text('Salva e chiudi'),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -352,6 +383,117 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showDeleteConfirmationDialog(BuildContext context) async {
|
||||
final cubit = context.read<OperationFormCubit>();
|
||||
final confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertDialog(
|
||||
title: const Row(
|
||||
children: [
|
||||
Icon(Icons.warning_amber_rounded, color: Colors.red),
|
||||
SizedBox(width: 8),
|
||||
Text('Conferma eliminazione'),
|
||||
],
|
||||
),
|
||||
content: const Text(
|
||||
'Sei sicuro di voler eliminare definitivamente questa pratica?\nL\'azione è irreversibile.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||
child: const Text('Annulla'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||
child: const Text('Elimina Pratica'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (confirm == true && context.mounted) {
|
||||
cubit.deleteCurrentOperation();
|
||||
}
|
||||
}
|
||||
|
||||
void _showStatusBottomSheet(BuildContext context) {
|
||||
final cubit = context.read<OperationFormCubit>();
|
||||
final currentStatus = cubit.state.operation.status;
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
builder: (modalContext) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Seleziona Stato Pratica',
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Navigator.pop(modalContext),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(),
|
||||
...OperationStatus.values.map((status) {
|
||||
final isSelected = status == currentStatus;
|
||||
final color = _getStatusColor(status);
|
||||
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
status == OperationStatus.success
|
||||
? Icons.check_circle
|
||||
: Icons.error_outline,
|
||||
color: color,
|
||||
),
|
||||
title: Text(
|
||||
status.displayName,
|
||||
style: TextStyle(
|
||||
fontWeight: isSelected
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
color: isSelected ? color : null,
|
||||
),
|
||||
),
|
||||
trailing: isSelected
|
||||
? Icon(Icons.check_circle, color: color)
|
||||
: null,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
tileColor: isSelected ? color.withValues(alpha: 0.1) : null,
|
||||
onTap: () {
|
||||
cubit.updateFields(status: status);
|
||||
Navigator.pop(modalContext);
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildResponsiveLayout(
|
||||
bool isUltraWide,
|
||||
bool isDesktop,
|
||||
@@ -363,24 +505,41 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [_cardAnagrafica(state), _cardEsito(state)],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 18),
|
||||
Expanded(child: _cardAllegati(state)),
|
||||
Expanded(child: _cardAnagrafica(state)),
|
||||
const SizedBox(width: 18),
|
||||
Expanded(child: _cardNote(state)),
|
||||
const SizedBox(width: 18),
|
||||
Expanded(child: _cardDettagli(state)),
|
||||
],
|
||||
),
|
||||
_cardDettagli(state),
|
||||
_cardAllegati(state),
|
||||
],
|
||||
);
|
||||
} else if (isDesktop) {
|
||||
return Row(children: []);
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [_cardAnagrafica(state), _cardAllegati(state)],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 18),
|
||||
Expanded(
|
||||
child: Column(children: [_cardNote(state), _cardDettagli(state)]),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Column(children: []);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_cardAnagrafica(state),
|
||||
_cardDettagli(state),
|
||||
_cardNote(state),
|
||||
_cardAllegati(state),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,9 +550,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
title: 'Dettagli Servizi',
|
||||
icon: Icons.design_services,
|
||||
themeColor: Colors.deepOrange,
|
||||
children: [
|
||||
const OperationDetailsSection(),
|
||||
],
|
||||
children: [const OperationDetailsSection()],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -420,78 +577,6 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cardEsito(OperationFormState state) {
|
||||
return _buildCard(
|
||||
title: 'Esito Pratica',
|
||||
icon: Icons.fact_check,
|
||||
themeColor: _getStatusColor(state.operation.status),
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: _getStatusColor(
|
||||
state.operation.status,
|
||||
).withValues(alpha: 0.1),
|
||||
border: Border.all(
|
||||
color: _getStatusColor(
|
||||
state.operation.status,
|
||||
).withValues(alpha: 0.3),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<OperationStatus>(
|
||||
isExpanded: true,
|
||||
value: state.operation.status,
|
||||
icon: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
color: _getStatusColor(state.operation.status),
|
||||
),
|
||||
items: OperationStatus.values.map((status) {
|
||||
return DropdownMenuItem(
|
||||
value: status,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
status == OperationStatus.success
|
||||
? Icons.check_circle
|
||||
: Icons.error_outline,
|
||||
color: _getStatusColor(status),
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
status.displayName,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _getStatusColor(status),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (newStatus) {
|
||||
if (newStatus != null) {
|
||||
context.read<OperationFormCubit>().updateFields(
|
||||
status: newStatus,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
state.operation.status == OperationStatus.success
|
||||
? 'Lascia OK se caricata con successo.'
|
||||
: 'Attenzione: pratica salvata in stato anomalo.',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey.shade600),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cardNote(OperationFormState state) {
|
||||
return _buildCard(
|
||||
title: 'Note Interne',
|
||||
|
||||
Reference in new issue
Block a user