feature aggiunta

This commit is contained in:
2026-04-20 11:18:22 +02:00
parent 023665ae58
commit 78012fdbf3
13 changed files with 631 additions and 80 deletions

View File

@@ -1,4 +1,5 @@
import 'package:equatable/equatable.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/blocs/session/session_bloc.dart';
@@ -129,6 +130,7 @@ class ServicesCubit extends Cubit<ServicesState> {
companyId: _sessionBloc.state.company!.id,
),
status: ServicesStatus.ready,
localAttachments: [],
),
);
}
@@ -208,7 +210,7 @@ class ServicesCubit extends Cubit<ServicesState> {
final serviceToSave = state.currentService!.copyWith(isBozza: isBozza);
// 2. Salvataggio corazzato
await _repository.saveFullService(serviceToSave);
await _repository.saveFullService(serviceToSave, state.localAttachments);
// 3. Reset e ricaricamento
emit(state.copyWith(status: ServicesStatus.saved, currentService: null));
@@ -222,4 +224,18 @@ class ServicesCubit extends Cubit<ServicesState> {
);
}
}
// --- GESTIONE ALLEGATI LOCALI ---
void addAttachments(List<PlatformFile> files) {
// Aggiungiamo i nuovi file a quelli già presenti in memoria
final updatedList = [...state.localAttachments, ...files];
emit(state.copyWith(localAttachments: updatedList));
}
void removeLocalAttachment(int index) {
final updatedList = List<PlatformFile>.from(state.localAttachments);
updatedList.removeAt(index);
emit(state.copyWith(localAttachments: updatedList));
}
}