feature aggiunta
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user