feat-tickets (#14)
Some checks failed
Deploy to Cloudflare Pages / build-and-deploy (push) Has been cancelled

Reviewed-on: #14
Co-authored-by: mark-cachy <marco@catelli.it>
Co-committed-by: mark-cachy <marco@catelli.it>
This commit is contained in:
2026-05-07 16:28:01 +02:00
committed by brontomark
parent 94ad524bae
commit 7d03d0dea5
38 changed files with 3594 additions and 1486 deletions

View File

@@ -6,8 +6,8 @@ import 'package:flux/core/theme/theme.dart';
import 'package:flux/core/widgets/image_viewer_widget.dart';
import 'package:flux/core/widgets/pdf_viewer_widget.dart';
import 'package:flux/core/widgets/qr_upload_dialog.dart';
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
import 'package:flux/features/attachments/models/attachment_model.dart';
import 'package:flux/features/customers/blocs/customer_files_bloc.dart';
import 'package:flux/features/customers/models/customer_model.dart';
class CustomerDetailScreen extends StatefulWidget {
@@ -26,11 +26,13 @@ class _CustomerDetailScreenState extends State<CustomerDetailScreen> {
}
void _loadFiles() {
context.read<CustomerFilesBloc>().add(LoadCustomerFilesEvent());
context.read<AttachmentsBloc>().add(
LoadAttachmentsEvent(parentId: widget.customer.id),
);
}
Future<void> _pickAndUpload() async {
CustomerFilesBloc customerFilesBloc = context.read<CustomerFilesBloc>();
AttachmentsBloc attachmentsBloc = context.read<AttachmentsBloc>();
// Chiamata statica pulita
FilePickerResult? result = await FilePicker.pickFiles(
@@ -40,17 +42,13 @@ class _CustomerDetailScreenState extends State<CustomerDetailScreen> {
);
if (result != null) {
for (var pickedFile in result.files) {
try {
customerFilesBloc.add(
UploadCustomerFileEvent(pickedFile: pickedFile),
);
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Errore upload ${pickedFile.name}: $e")),
);
}
try {
attachmentsBloc.add(UploadAttachmentsEvent(pickedFiles: result.files));
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text("$e")));
}
}
}
@@ -143,7 +141,7 @@ class _CustomerDetailScreenState extends State<CustomerDetailScreen> {
}
Widget _buildDocumentSection() {
return BlocBuilder<CustomerFilesBloc, CustomerFilesState>(
return BlocBuilder<AttachmentsBloc, AttachmentsState>(
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -213,9 +211,9 @@ class _CustomerDetailScreenState extends State<CustomerDetailScreen> {
],
),
const SizedBox(height: 20),
if (state.status == CustomerFilesStatus.loading)
if (state.status == AttachmentsStatus.loading)
const Center(child: CircularProgressIndicator())
else if (state.customerFiles.isEmpty)
else if (state.allFiles.isEmpty)
const Center(child: Text("Nessun documento presente"))
else
Expanded(
@@ -226,9 +224,9 @@ class _CustomerDetailScreenState extends State<CustomerDetailScreen> {
crossAxisSpacing: 16,
childAspectRatio: 1.2,
),
itemCount: state.customerFiles.length,
itemCount: state.allFiles.length,
itemBuilder: (context, index) =>
_FileCard(file: state.customerFiles[index], state: state),
_FileCard(file: state.allFiles[index], state: state),
),
),
],
@@ -268,14 +266,14 @@ class _CustomerDetailScreenState extends State<CustomerDetailScreen> {
class _FileCard extends StatelessWidget {
final AttachmentModel file;
final CustomerFilesState state;
final AttachmentsState state;
const _FileCard({required this.file, required this.state});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => context.read<CustomerFilesBloc>().add(
ToggleCustomerFileSelectionEvent(file),
onTap: () => context.read<AttachmentsBloc>().add(
ToggleAttachmentSelectionEvent(file),
),
onDoubleTap: () => _handleDoubleClickOnFile(context, file),
child: Stack(