upgraded flutter and refactor document sequences
This commit is contained in:
@@ -1,6 +1,22 @@
|
|||||||
// Se un domani ci saranno nuovi tipi di documento, basterà aggiungerli qui
|
// Se un domani ci saranno nuovi tipi di documento, basterà aggiungerli qui
|
||||||
// e alla mappa nella DocumentSequenceSection dei documenti supportati
|
// e alla mappa nella DocumentSequenceSection dei documenti supportati
|
||||||
enum DocumentType { ticket, shipment }
|
enum DocumentType {
|
||||||
|
ticket(name: 'ticket', label: 'Ticket', defaultPrefix: 'TCK'),
|
||||||
|
ticketsShipping(
|
||||||
|
name: 'tickets_shipping',
|
||||||
|
label: 'DDT (Documento di Trasporto)',
|
||||||
|
defaultPrefix: 'DDT',
|
||||||
|
);
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
final String label;
|
||||||
|
final String defaultPrefix;
|
||||||
|
const DocumentType({
|
||||||
|
required this.name,
|
||||||
|
required this.label,
|
||||||
|
required this.defaultPrefix,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
class DocumentSequence {
|
class DocumentSequence {
|
||||||
final String docType;
|
final String docType;
|
||||||
|
|||||||
@@ -6,22 +6,6 @@ import 'package:flux/features/settings/document_sequence/models/document_sequenc
|
|||||||
class DocumentSequenceSection extends StatelessWidget {
|
class DocumentSequenceSection extends StatelessWidget {
|
||||||
const DocumentSequenceSection({super.key});
|
const DocumentSequenceSection({super.key});
|
||||||
|
|
||||||
// La nostra lista "Ninja" di tutti i documenti gestiti dall'app
|
|
||||||
// Se domani aggiungo le fatture, basta aggiungere una riga qui!
|
|
||||||
// e all'enum DocumentType nel model
|
|
||||||
static final supportedDocumentTypes = [
|
|
||||||
{
|
|
||||||
'type': DocumentType.ticket.name,
|
|
||||||
'label': 'TICKET',
|
|
||||||
'defaultPrefix': 'TCK',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'type': DocumentType.shipment.name,
|
|
||||||
'label': 'DDT (Documento di Trasporto)',
|
|
||||||
'defaultPrefix': 'DDT',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final year = DateTime.now().year;
|
final year = DateTime.now().year;
|
||||||
@@ -46,19 +30,17 @@ class DocumentSequenceSection extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
|
|
||||||
// Invece di mappare state.sequences, mappiamo i documenti supportati
|
// Invece di mappare state.sequences, mappiamo i documenti supportati
|
||||||
...supportedDocumentTypes.map((docDef) {
|
...DocumentType.values.map((docType) {
|
||||||
final docType = docDef['type']!;
|
|
||||||
|
|
||||||
// Cerchiamo se c'è già una configurazione nello stato per questo documento
|
// Cerchiamo se c'è già una configurazione nello stato per questo documento
|
||||||
final existingList = state.sequences
|
final existingList = state.sequences
|
||||||
.where((s) => s.docType == docType)
|
.where((s) => s.docType == docType.name)
|
||||||
.toList();
|
.toList();
|
||||||
final existingSeq = existingList.isNotEmpty
|
final existingSeq = existingList.isNotEmpty
|
||||||
? existingList.first
|
? existingList.first
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
// Se esiste usiamo i suoi valori, altrimenti i default
|
// Se esiste usiamo i suoi valori, altrimenti i default
|
||||||
final prefix = existingSeq?.prefix ?? docDef['defaultPrefix']!;
|
final prefix = existingSeq?.prefix ?? docType.defaultPrefix;
|
||||||
final nextValue = existingSeq?.nextValue ?? 1;
|
final nextValue = existingSeq?.nextValue ?? 1;
|
||||||
|
|
||||||
// Anteprima dinamica (aggiornata a 4 zeri come nel DB!)
|
// Anteprima dinamica (aggiornata a 4 zeri come nel DB!)
|
||||||
@@ -73,7 +55,7 @@ class DocumentSequenceSection extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
docDef['label']!,
|
docType.label,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
@@ -92,7 +74,10 @@ class DocumentSequenceSection extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
onChanged: (val) => context
|
onChanged: (val) => context
|
||||||
.read<DocumentSequenceCubit>()
|
.read<DocumentSequenceCubit>()
|
||||||
.updateLocalSequence(docType, prefix: val),
|
.updateLocalSequence(
|
||||||
|
docType.name,
|
||||||
|
prefix: val,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
@@ -107,7 +92,7 @@ class DocumentSequenceSection extends StatelessWidget {
|
|||||||
onChanged: (val) => context
|
onChanged: (val) => context
|
||||||
.read<DocumentSequenceCubit>()
|
.read<DocumentSequenceCubit>()
|
||||||
.updateLocalSequence(
|
.updateLocalSequence(
|
||||||
docType,
|
docType.name,
|
||||||
nextValue: int.tryParse(val) ?? 1,
|
nextValue: int.tryParse(val) ?? 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class TicketShippingCubit extends Cubit<TicketShippingState> {
|
|||||||
if (state.isAutoNumber) {
|
if (state.isAutoNumber) {
|
||||||
try {
|
try {
|
||||||
final nextNumber = await _sequenceRepository.getNextDocumentNumber(
|
final nextNumber = await _sequenceRepository.getNextDocumentNumber(
|
||||||
DocumentType.shipment.name,
|
DocumentType.ticketsShipping.name,
|
||||||
);
|
);
|
||||||
updateDocument(docNumber: nextNumber);
|
updateDocument(docNumber: nextNumber);
|
||||||
// 3. GENERIAMO I BYTES DEL PDF
|
// 3. GENERIAMO I BYTES DEL PDF
|
||||||
|
|||||||
44
pubspec.lock
44
pubspec.lock
@@ -77,10 +77,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: bloc
|
name: bloc
|
||||||
sha256: a48653a82055a900b88cd35f92429f068c5a8057ae9b136d197b3d56c57efb81
|
sha256: e03b235924e4f509c27b5d6b2f949200e0a91149a9818b4f65eeb56662b75413
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "9.2.0"
|
version: "9.2.1"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -319,10 +319,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_svg
|
name: flutter_svg
|
||||||
sha256: "1ded017b39c8e15c8948ea855070a5ff8ff8b3d5e83f3446e02d6bb12add7ad9"
|
sha256: "35882981abcbfb8c15b286f0cd690ff25bac12d95eff3e25ee207f37d4c42e7f"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.4"
|
version: "2.3.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -369,10 +369,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: go_router
|
name: go_router
|
||||||
sha256: "08b742eef4f71c9df5af543751cd0b7f1c679c4088488f4223ecaddc1a813b79"
|
sha256: "92d8cee7c57dff0a6c409c05597b460002434eccf7424a712283225b3962d03f"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "17.2.2"
|
version: "17.2.3"
|
||||||
google_fonts:
|
google_fonts:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -393,10 +393,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: gtk
|
name: gtk
|
||||||
sha256: e8ce9ca4b1df106e4d72dad201d345ea1a036cc12c360f1a7d5a758f78ffa42c
|
sha256: "4ff85b2a16724029dd9e5bbb5a94b6918f9973f74ba571c949d2002801879cf5"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.2.0"
|
||||||
hooks:
|
hooks:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -441,10 +441,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: image_picker_android
|
name: image_picker_android
|
||||||
sha256: "66810af8e99b2657ee98e5c6f02064f69bb63f7a70e343937f70946c5f8c6622"
|
sha256: d5b3e1774af29c9ab00103afb0d4614070f924d2e0057ac867ec98800114793f
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.8.13+16"
|
version: "0.8.13+17"
|
||||||
image_picker_for_web:
|
image_picker_for_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -529,10 +529,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: json_annotation
|
name: json_annotation
|
||||||
sha256: cb09e7dac6210041fad964ed7fbee004f14258b4eca4040f72d1234062ace4c8
|
sha256: "2a743920d81b7910627f68ee2c9ac1fc0bfee32b9fc3403587d7c6791ca12f80"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.11.0"
|
version: "4.12.0"
|
||||||
jwt_decode:
|
jwt_decode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -601,10 +601,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.17.0"
|
version: "1.18.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1046,10 +1046,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
|
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.10"
|
version: "0.7.11"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1134,10 +1134,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_web
|
name: url_launcher_web
|
||||||
sha256: d0412fcf4c6b31ecfdb7762359b7206ffba3bbffd396c6d9f9c4616ece476c1f
|
sha256: "85c81589622fbc87c1c683aaea164d3604a7777495a79d91e39ffcdec39ddb34"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.2"
|
version: "2.4.3"
|
||||||
url_launcher_windows:
|
url_launcher_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1158,10 +1158,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_graphics
|
name: vector_graphics
|
||||||
sha256: "6409a25046024f0f8c5d8a59fec314081e81f9d436b66ca4015a8b49772bf445"
|
sha256: "2306c03da2ba81724afeb589c351ebbc0aa7d86005925be8f8735856dbe5e42d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.2"
|
||||||
vector_graphics_codec:
|
vector_graphics_codec:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1174,10 +1174,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_graphics_compiler
|
name: vector_graphics_compiler
|
||||||
sha256: "5a88dd14c0954a5398af544651c7fb51b457a2a556949bfb25369b210ef73a74"
|
sha256: b9b3f391857781aa96acacef96066f2f49b4cd03cf9fce3ca4d8da2ef5ea129e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.3"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
Reference in New Issue
Block a user