fix macos pdf
This commit is contained in:
@@ -213,8 +213,12 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
.generateTicketReceipt(ticket);
|
||||
final bytes = await doc.save();
|
||||
final fileName = 'Ricevuta_${ticket.referenceId}.pdf';
|
||||
await Printing.layoutPdf(
|
||||
onLayout: (format) async => bytes,
|
||||
name: fileName,
|
||||
);
|
||||
|
||||
if (kIsWeb || Platform.isMacOS) {
|
||||
/* if (kIsWeb || Platform.isMacOS) {
|
||||
// Forza il download/salvataggio senza passare per il print spooler
|
||||
await Printing.sharePdf(
|
||||
bytes: bytes,
|
||||
@@ -222,11 +226,8 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
);
|
||||
} else {
|
||||
// Su Android/iOS continuiamo a usare la stampa diretta che funziona
|
||||
await Printing.layoutPdf(
|
||||
onLayout: (format) async => bytes,
|
||||
name: fileName,
|
||||
);
|
||||
}
|
||||
|
||||
} */
|
||||
},
|
||||
),
|
||||
if (company.labelFormat != LabelFormat.none)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import 'package:flutter/foundation.dart' show kIsWeb, defaultTargetPlatform;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||
import 'package:flux/features/documents/models/shipment_document_model.dart';
|
||||
import 'package:flux/features/tickets/models/shipment_document_model.dart';
|
||||
import 'package:flux/features/master_data/providers/models/provider_location_model.dart';
|
||||
import 'package:flux/features/master_data/providers/models/provider_model.dart';
|
||||
import 'package:flux/features/tickets/blocs/ticket_list_cubit.dart';
|
||||
@@ -148,24 +147,10 @@ class TicketList extends StatelessWidget {
|
||||
document: result.document,
|
||||
tickets: state.selectedTickets.toList(),
|
||||
);
|
||||
|
||||
// 4. LANCIAMO LA STAMPA (Anteprima nativa / Browser)
|
||||
// Check sicuro: se NON siamo sul web E la piattaforma nativa è macOS
|
||||
if (!kIsWeb &&
|
||||
defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
// Scialuppa di salvataggio per il Mac
|
||||
await Printing.sharePdf(
|
||||
bytes: pdfBytes,
|
||||
filename: 'ddt_${result.document.docNumber}.pdf',
|
||||
);
|
||||
} else {
|
||||
// Per Web, Windows, Linux, Android e iOS... diamo spettacolo!
|
||||
await Printing.layoutPdf(
|
||||
onLayout: (PdfPageFormat format) async =>
|
||||
pdfBytes,
|
||||
name: 'ddt_${result.document.docNumber}.pdf',
|
||||
);
|
||||
}
|
||||
await Printing.layoutPdf(
|
||||
onLayout: (PdfPageFormat format) async => pdfBytes,
|
||||
name: 'ddt_${result.document.docNumber}.pdf',
|
||||
);
|
||||
|
||||
// 5. Pulizia finale: Deselezioniamo tutti i ticket e ricarichiamo la lista
|
||||
ticketListCubit.clearSelection();
|
||||
|
||||
@@ -185,7 +185,7 @@ class _TicketShippingModalState extends State<TicketShippingModal> {
|
||||
TicketShippingState state,
|
||||
) {
|
||||
return DropdownButtonFormField<String>(
|
||||
value: state.document.providerId.isEmpty
|
||||
initialValue: state.document.providerId.isEmpty
|
||||
? null
|
||||
: state.document.providerId,
|
||||
decoration: const InputDecoration(
|
||||
@@ -207,7 +207,7 @@ class _TicketShippingModalState extends State<TicketShippingModal> {
|
||||
TicketShippingState state,
|
||||
) {
|
||||
return DropdownButtonFormField<String>(
|
||||
value: state.document.destinationLocationId.isEmpty
|
||||
initialValue: state.document.destinationLocationId.isEmpty
|
||||
? null
|
||||
: state.document.destinationLocationId,
|
||||
decoration: const InputDecoration(
|
||||
@@ -280,6 +280,7 @@ class _TicketShippingModalState extends State<TicketShippingModal> {
|
||||
),
|
||||
trailing: const Icon(Icons.calendar_month),
|
||||
onTap: () async {
|
||||
final ticketShippingCubit = context.read<TicketShippingCubit>();
|
||||
final newDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: date,
|
||||
@@ -287,7 +288,7 @@ class _TicketShippingModalState extends State<TicketShippingModal> {
|
||||
lastDate: DateTime.now().add(const Duration(days: 365)),
|
||||
);
|
||||
if (newDate != null) {
|
||||
context.read<TicketShippingCubit>().updateDocument(docDate: newDate);
|
||||
ticketShippingCubit.updateDocument(docDate: newDate);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user