This commit is contained in:
2026-05-19 16:00:40 +02:00
parent 364474471c
commit 8a1b582f4e
5 changed files with 62 additions and 47 deletions

View File

@@ -67,36 +67,39 @@ class _QuickCustomerDialogState extends State<QuickCustomerDialog> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
ChoiceChip(
label: const Text('Privato (Domestico)'),
selected: _isBusiness == false,
selectedColor: Colors.blue.withValues(alpha: 0.2),
checkmarkColor: Colors.blue.shade700,
onSelected: (selected) {
if (selected) {
setState(() {
_isBusiness = false;
});
}
},
),
const SizedBox(width: 12),
ChoiceChip(
label: const Text('Business (P.IVA)'),
selected: _isBusiness == true,
selectedColor: Colors.orange.withValues(alpha: 0.2),
checkmarkColor: Colors.orange.shade700,
onSelected: (selected) {
if (selected) {
setState(() {
_isBusiness = true;
});
}
},
),
],
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
ChoiceChip(
label: const Text('Privato (Domestico)'),
selected: _isBusiness == false,
selectedColor: Colors.blue.withValues(alpha: 0.2),
checkmarkColor: Colors.blue.shade700,
onSelected: (selected) {
if (selected) {
setState(() {
_isBusiness = false;
});
}
},
),
const SizedBox(width: 12),
ChoiceChip(
label: const Text('Business (P.IVA)'),
selected: _isBusiness == true,
selectedColor: Colors.orange.withValues(alpha: 0.2),
checkmarkColor: Colors.orange.shade700,
onSelected: (selected) {
if (selected) {
setState(() {
_isBusiness = true;
});
}
},
),
],
),
),
const Divider(height: 32),
TextField(

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/widgets/shared_forms/attachments_section.dart';
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
import 'package:flux/features/operations/blocs/operation_form_cubit.dart';
import 'package:flux/features/operations/models/operation_model.dart';
@@ -39,7 +40,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
'Energy',
'Fin',
'Entertainment',
'Custom',
'Altro',
];
bool _isInitialized = false;
@@ -113,9 +114,10 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
Future<String?> _generateIdForQr() async {
if (!_formKey.currentState!.validate()) return null;
_flushControllersToCubit();
// Lo leggiamo pulito pulito dal context, perché c'è!
final attachmentsBloc = context.read<AttachmentsBloc>();
// Assicurati che questo metodo esista nel Cubit (come per il Ticket)
final newId = await context.read<OperationFormCubit>().saveOperationDraft();
if (newId != null && context.mounted) {
attachmentsBloc.add(ParentEntitySavedEvent(newId));
@@ -602,8 +604,10 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
icon: Icons.attach_file,
themeColor: Colors.deepPurple,
children: [
SharedFilesSection(
titleNameForUpload: state.operation.customer?.name ?? 'Nuova Pratica',
SharedAttachmentsSection(
parentType: AttachmentParentType.operation,
parentId: state.operation.id,
titleForUpload: state.operation.customer?.name ?? 'Nuova Pratica',
onGenerateIdForQr: _generateIdForQr,
),
],

View File

@@ -27,7 +27,7 @@ class OperationDetailsSection extends StatelessWidget {
ProviderModel provider,
String operationType,
) {
if (operationType == 'Custom') return true;
if (operationType == 'Altro') return true;
// Controlliamo che il fornitore abbia il ruolo specifico nel suo array
switch (operationType) {
@@ -241,7 +241,7 @@ class OperationDetailsSection extends StatelessWidget {
],
// 3. SCENARIO ENTERTAINMENT O CUSTOM (Testo libero)
if (currentType == 'Entertainment' || currentType == 'Custom') ...[
if (currentType == 'Entertainment' || currentType == 'Altro') ...[
TextFormField(
controller: freeTextSubtypeController,
decoration: InputDecoration(
@@ -258,7 +258,7 @@ class OperationDetailsSection extends StatelessWidget {
'Energy',
'Fin',
'Entertainment',
'Custom',
'Altro',
].contains(currentType)) ...[
const SizedBox(height: 8),
durationQuickPicks, // Passiamo i chips dall'esterno