hkjg
This commit is contained in:
@@ -164,41 +164,46 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
Expanded(
|
||||
child: BlocBuilder<CustomersCubit, CustomersState>(
|
||||
builder: (context, state) {
|
||||
/* Decommenta e adatta al tuo CustomersState
|
||||
if (state.status == CustomersStatus.loading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
if (state.customers.isEmpty) {
|
||||
return const Center(child: Text('Nessun cliente trovato.', style: TextStyle(color: Colors.grey)));
|
||||
return const Center(
|
||||
child: Text(
|
||||
'Nessun cliente trovato.',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
return ListView.builder(
|
||||
controller: scrollController,
|
||||
itemCount: 10, // Sostituisci con state.customers.length
|
||||
itemCount: state.customers.length,
|
||||
itemBuilder: (context, index) {
|
||||
// final customer = state.customers[index];
|
||||
final customer = state.customers[index];
|
||||
return ListTile(
|
||||
leading: const CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
leading: CircleAvatar(
|
||||
child: Text(
|
||||
customer.name.substring(0, 1).toUpperCase(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
'Cliente $index',
|
||||
customer.name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
), // Sostituisci con customer.name
|
||||
subtitle: const Text(
|
||||
'333 1234567',
|
||||
), // Sostituisci con customer.phoneNumber
|
||||
),
|
||||
subtitle: Text(
|
||||
'${customer.phoneNumber} • ${customer.email}',
|
||||
),
|
||||
onTap: () {
|
||||
// Aggiorniamo il form tramite il Cubit delle operazioni
|
||||
context
|
||||
.read<OperationsCubit>()
|
||||
.updateOperationFields(
|
||||
customerId:
|
||||
'id_del_cliente_$index', // customer.id
|
||||
customerId: customer.id, // customer.id
|
||||
customerDisplayName:
|
||||
'Cliente $index', // customer.name
|
||||
customer.name, // customer.name
|
||||
);
|
||||
Navigator.pop(modalContext);
|
||||
},
|
||||
@@ -433,8 +438,8 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
|
||||
// SOTTO-TIPO (Reattivo)
|
||||
if (['Energy', 'Fin', 'Entertainment'].contains(currentType)) ...[
|
||||
DropdownButtonFormField<String>(
|
||||
value:
|
||||
DropdownButtonFormField<String?>(
|
||||
initialValue:
|
||||
null, // Sostituisci con currentOp?.subtype quando lo aggiungi
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Dettaglio (es. Luce, Gas...)',
|
||||
@@ -481,6 +486,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
onTap: () async {
|
||||
final operationsCubit = context.read<OperationsCubit>();
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now().add(const Duration(days: 365)),
|
||||
@@ -488,9 +494,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
lastDate: DateTime.now().add(const Duration(days: 3650)),
|
||||
);
|
||||
if (date != null) {
|
||||
context.read<OperationsCubit>().updateOperationFields(
|
||||
expirationDate: date,
|
||||
);
|
||||
operationsCubit.updateOperationFields(expirationDate: date);
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -505,10 +509,11 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
icon: const Icon(Icons.remove),
|
||||
onPressed: () {
|
||||
final q = currentOp?.quantity ?? 1;
|
||||
if (q > 1)
|
||||
if (q > 1) {
|
||||
context.read<OperationsCubit>().updateOperationFields(
|
||||
quantity: q - 1,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
Text(
|
||||
|
||||
Reference in New Issue
Block a user