Compare commits

..
195 Commits
Author SHA1 Message Date
brontomark a33b08a0c3 fix(ci): set User-Agent on Invoke-RestMethod for Windows Supabase update and bump to 2.0.11
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 6m3s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 6m51s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 4m2s
Build and Release FLUX (Multi-Platform) / build-macos (push) Failing after 15m20s
2026-09-21 09:48:09 +02:00
brontomark c8fdd29cf4 v
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m55s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 1m26s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 9m48s
Build and Release FLUX (Multi-Platform) / build-macos (push) Failing after 11m3s
2026-09-21 09:30:44 +02:00
brontomark 00615b92a0 fix(windows): use {autopf} with PrivilegesRequired=lowest and bump to v2.0.9
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m50s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 1m21s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 12m2s
Build and Release FLUX (Multi-Platform) / build-macos (push) Successful in 2m59s
2026-09-19 19:24:11 +02:00
brontomark 832be3d797 feat: supporto latest_version, riga AppImage e gestione aggiornamento facoltativo/obbligatorio
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m53s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 1m20s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 6m18s
Build and Release FLUX (Multi-Platform) / build-macos (push) Failing after 14m10s
2026-09-19 18:42:34 +02:00
brontomark 72f9d88f96 auto update
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m58s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 1m22s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 7m41s
Build and Release FLUX (Multi-Platform) / build-macos (push) Has been cancelled
2026-09-19 18:25:30 +02:00
brontomark d4a6b142c5 v
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 3m5s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m50s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 1m24s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 6m48s
Build and Release FLUX (Multi-Platform) / build-macos (push) Has been cancelled
2026-09-19 17:13:41 +02:00
brontomark 8da4dc9d75 prova
Build and Release FLUX (Multi-Platform) / build-android (push) Failing after 15s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m46s
Build and Release FLUX (Multi-Platform) / build-linux (push) Failing after 1m15s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m44s
Build and Release FLUX (Multi-Platform) / build-macos (push) Failing after 10m4s
2026-09-19 16:51:35 +02:00
brontomark 6ad0aa3e23 v
Build and Release FLUX (Multi-Platform) / build-android (push) Failing after 38s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 2m1s
Build and Release FLUX (Multi-Platform) / build-linux (push) Failing after 1m17s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 4m59s
Build and Release FLUX (Multi-Platform) / build-macos (push) Has been cancelled
2026-09-19 16:33:50 +02:00
brontomark 11c5352555 ritmo singolo addetto
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m40s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m53s
Build and Release FLUX (Multi-Platform) / build-macos (push) Successful in 3m8s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 4m4s
Build and Release FLUX (Multi-Platform) / build-linux (push) Failing after 1m16s
2026-09-19 14:05:29 +02:00
brontomark a0bdb9a535 fix titolo hero target widget su mobile
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m49s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m58s
Build and Release FLUX (Multi-Platform) / build-macos (push) Successful in 2m46s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 4m5s
Build and Release FLUX (Multi-Platform) / build-linux (push) Failing after 1m17s
2026-09-19 13:49:14 +02:00
brontomark 37d69e3ddc aggiunta navigazione al file viewer
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 3m26s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 2m41s
Build and Release FLUX (Multi-Platform) / build-macos (push) Successful in 3m3s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 6m14s
Build and Release FLUX (Multi-Platform) / build-linux (push) Failing after 1m16s
2026-09-19 13:34:54 +02:00
brontomark 524da71a45 gestione obiettivi
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 4m24s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m42s
Build and Release FLUX (Multi-Platform) / build-macos (push) Successful in 2m33s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 10m44s
Build and Release FLUX (Multi-Platform) / build-linux (push) Failing after 1m53s
2026-09-18 11:41:26 +02:00
brontomark 3949d6d13c cambiate metriche, tolti totali aggregati e messo a posto lista obiettivi 2026-09-17 14:02:34 +02:00
brontomark d5591b2c91 a 2026-09-07 07:43:31 +02:00
brontomark 97d19f1d17 targets 2026-09-06 11:21:06 +02:00
brontomark 282a959f88 a 2026-09-06 10:03:27 +02:00
brontomark aaa6cdf704 fix attachments
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 3m39s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 2m14s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 1m57s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m48s
2026-08-19 12:43:01 +02:00
brontomark bc1614c71b fix attachments 2026-08-19 12:42:35 +02:00
brontomark b71656d0a6 controllo versione su linux
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 4m51s
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled
Build and Release FLUX (Multi-Platform) / build-linux (push) Has been cancelled
Build and Release FLUX (Multi-Platform) / build-web (push) Has been cancelled
2026-08-18 19:31:58 +02:00
brontomark 9374f4ab46 nuova strategia per le liste delle operazioni e correzione bug indirizzo predefinito di spedizione dei provider
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 4m30s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 9m21s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 2m29s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 2m17s
2026-08-18 19:24:53 +02:00
brontomark 3b3e65bd1c v
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 4m39s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 2m15s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 7m32s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 2m0s
2026-08-18 15:24:16 +02:00
brontomark ce035e2204 a 2026-08-18 12:42:46 +02:00
brontomark 70c0c25521 a
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 9m18s
Build and Release FLUX (Multi-Platform) / build-linux (push) Successful in 2m47s
Build and Release FLUX (Multi-Platform) / build-android (push) Has been cancelled
Build and Release FLUX (Multi-Platform) / build-web (push) Has been cancelled
2026-08-17 19:30:07 +02:00
brontomark 8cd55f53f7 v fix ticket shipping
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m55s
Build and Release FLUX (Multi-Platform) / build-android (push) Failing after 12m32s
Build and Release FLUX (Multi-Platform) / build-web (push) Failing after 15m3s
2026-08-17 19:09:50 +02:00
brontomark 6e01729bf5 fix ticket shipping 2026-08-17 19:08:59 +02:00
brontomark 4b4d0c5cb6 a 2026-08-17 12:13:50 +02:00
brontomark ff27727f10 appdir 2026-08-17 11:55:39 +02:00
brontomark 8f0ad23c0b v 2026-08-17 10:55:21 +02:00
brontomark 729c893463 v
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m5s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m11s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 7m21s
2026-08-16 19:35:20 +02:00
brontomark eb31ad7173 si
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m43s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m22s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 26s
2026-08-16 19:12:51 +02:00
brontomark a652232b25 v
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 5m5s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m16s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 12m10s
2026-08-16 13:43:21 +02:00
brontomark b8f752d246 molto bene 2026-08-16 12:01:43 +02:00
brontomark b837a5fa1e Merge branch 'operation_details' of ssh://vps.catelli.it:2222/brontomark/flux into operation_details 2026-08-15 10:20:19 +02:00
brontomark 9154a16fe1 a 2026-08-15 10:20:03 +02:00
brontomark 48f6f92f9c a 2026-08-14 18:54:37 +02:00
brontomark c6e3594850 a 2026-08-11 08:36:44 +02:00
brontomark c6a1b203ce b 2026-08-08 08:29:59 +02:00
brontomark 1c96ff9516 b 2026-08-08 08:29:07 +02:00
brontomark 409c064902 b 2026-08-07 08:40:24 +02:00
brontomark 66667fb440 a 2026-08-05 19:28:30 +02:00
brontomark c41fcd37b3 operation details 2026-08-05 09:10:27 +02:00
brontomark 9cd0b98a16 feat: add fiscal code field to customer model and UI forms with support for viewing and copying
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 9m19s
Build and Release FLUX (Multi-Platform) / build-android (push) Failing after 10m18s
Build and Release FLUX (Multi-Platform) / build-web (push) Failing after 15m6s
2026-07-14 17:13:31 +02:00
brontomark 8951bff083 F
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 6m19s
Build and Release FLUX (Multi-Platform) / build-android (push) Failing after 11m39s
Build and Release FLUX (Multi-Platform) / build-web (push) Failing after 14m9s
2026-07-11 17:20:43 +02:00
brontomark a514bba8b2 fix search
Build and Release FLUX (Multi-Platform) / build-android (push) Failing after 12m18s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m45s
Build and Release FLUX (Multi-Platform) / build-web (push) Has been cancelled
2026-07-11 16:41:21 +02:00
brontomark f8504d466a fix attachments
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m5s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m7s
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m44s
2026-06-08 14:36:31 +02:00
brontomark 22bb86f052 Merge branch 'main' of ssh.catelli.it:brontomark/flux 2026-06-08 13:20:52 +02:00
brontomark fc850795c9 fix attachments with no parentId 2026-06-08 13:17:33 +02:00
brontomark b60ce96dd7 fix uploads
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m14s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m3s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m48s
2026-06-08 13:15:29 +02:00
brontomark 6582da60d4 edge function per interrogare openai, capire quali immagini sono di documenti d'identità e assegnarli al cliente 2026-06-05 07:50:07 +02:00
brontomark d42cc5af1d v check fix
Build and Release FLUX (Multi-Platform) / build-windows (push) Canceled after 0s
Build and Release FLUX (Multi-Platform) / build-android (push) Canceled after 0s
Build and Release FLUX (Multi-Platform) / build-web (push) Canceled after 0s
2026-06-04 15:21:11 +02:00
brontomark 7ea0e2ac10 changed version check
Build and Release FLUX (Multi-Platform) / build-windows (push) Canceled after 0s
Build and Release FLUX (Multi-Platform) / build-android (push) Canceled after 0s
Build and Release FLUX (Multi-Platform) / build-web (push) Canceled after 0s
2026-06-04 14:21:27 +02:00
brontomark 5ce0110197 fix operations e tasks
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 6m20s
Build and Release FLUX (Multi-Platform) / build-android (push) Failing after 11m52s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m0s
2026-06-04 13:42:29 +02:00
brontomark 4efc3ce182 mmmh
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m11s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m1s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m5s
2026-06-04 12:34:38 +02:00
brontomark 01515910b6 mah....volare 2026-06-03 19:16:15 +02:00
brontomark f27ede7625 v - changed operation list
Build and Release FLUX (Multi-Platform) / build-windows (push) Canceled after 0s
Build and Release FLUX (Multi-Platform) / build-web (push) Canceled after 0s
Build and Release FLUX (Multi-Platform) / build-android (push) Canceled after 32s
2026-06-03 13:22:47 +02:00
brontomark 99ab7abf6e adfadsf 2026-06-03 13:20:22 +02:00
brontomark a7fd37a894 buono 2026-06-03 12:08:59 +02:00
brontomark 8ad2b7cf7e operation reference not mandatory
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m54s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m20s
Build and Release FLUX (Multi-Platform) / build-windows (push) Canceled after 0s
2026-06-02 13:28:24 +02:00
brontomark 3210b4fcfa default provider
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m58s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m12s
Build and Release FLUX (Multi-Platform) / build-windows (push) Canceled after 8m8s
2026-06-02 13:12:21 +02:00
brontomark a51ac8fe7f ticket refinements 2026-06-02 11:52:31 +02:00
brontomark 7fad6ee02b pw reset con edge function
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m24s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m14s
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled
2026-06-02 10:55:59 +02:00
brontomark 6a6e792cd9 fixed reset password 2026-06-02 10:55:26 +02:00
brontomark 3c33c8765a v
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m12s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m24s
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled
2026-06-02 10:20:43 +02:00
brontomark 27a5bc16bc ricostruzione sessione manuale per aggirare gorouter che distrugge il token 2026-06-02 10:20:25 +02:00
brontomark 808de7b354 altra prova
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m54s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m7s
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled
2026-06-02 09:39:45 +02:00
brontomark 618cbc0396 prova per inviti
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m28s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m31s
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled
2026-06-02 09:32:30 +02:00
brontomark 67a56f2954 fix per notifiche su web 2026-06-01 10:55:28 +02:00
brontomark 88b1a618bd deep link from dead app
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m41s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m12s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 7m58s
2026-06-01 10:08:44 +02:00
brontomark d989b14967 bump
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m54s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m18s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 7m59s
2026-05-31 19:06:04 +02:00
brontomark d4ff2b9a7e task notifications 2026-05-31 19:05:21 +02:00
brontomark 06ee11521d v1.1.6 2026-05-31 19:04:48 +02:00
brontomark 55d6429dc5 bump version
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled
Build and Release FLUX (Multi-Platform) / build-web (push) Has been cancelled
Build and Release FLUX (Multi-Platform) / build-android (push) Has been cancelled
2026-05-30 18:10:10 +02:00
brontomark 44c85766fc notes cubit 2026-05-30 18:06:43 +02:00
brontomark b69308e1ef refactor dashboard note list 2026-05-30 16:45:12 +02:00
brontomark 6394e5a2cd refactor dashboard store ticket list 2026-05-30 16:26:59 +02:00
brontomark f31ff19a74 refactor dashboard operation list e task list with applifecycle 2026-05-30 15:19:22 +02:00
brontomark 064179a753 bumped version
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m45s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m9s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m12s
2026-05-30 13:07:21 +02:00
brontomark 727eaac3d9 resend e fcm 2026-05-30 12:26:53 +02:00
brontomark bd81173559 fcm 2026-05-30 12:12:14 +02:00
brontomark 9bace01b93 b 2026-05-29 19:24:40 +02:00
brontomark 5ad3e12b1f b 2026-05-29 12:26:41 +02:00
brontomark 6211cc6729 bump....fixato sharedattachments e notecollaborators
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m1s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m21s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 4m15s
2026-05-28 23:49:55 +02:00
brontomark f15a2aa6e6 fixes 2026-05-28 23:48:30 +02:00
brontomark aed841dc0b firma su exe windows
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 5m1s
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m52s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m6s
2026-05-28 18:06:10 +02:00
brontomark 221260aca3 v
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m10s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m18s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 5m34s
2026-05-28 13:57:11 +02:00
brontomark 83988597d5 tasks 2026-05-28 13:55:28 +02:00
brontomark b298509178 a 2026-05-27 19:38:59 +02:00
brontomark b6e5f9acbe x 2026-05-27 16:00:50 +02:00
brontomark f6ecb33729 refactor: replace string literals with table constants in TaskRepository 2026-05-27 08:41:53 +02:00
brontomark 9d796d6e41 boh 2026-05-26 19:31:25 +02:00
brontomark 45455a16c4 w 2026-05-26 12:28:12 +02:00
brontomark 2afe97c6db spostato aggiornamento tabella supabase sul worker del mac anche per FluxInstaller.exe
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 3m20s
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m44s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m2s
2026-05-25 16:45:51 +02:00
brontomark 4101b736e6 fix windows deployment
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m12s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m3s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 3m52s
2026-05-25 16:34:23 +02:00
brontomark b67354610d prova x sistemare pipeline windows
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m31s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m3s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 3m32s
2026-05-25 15:55:53 +02:00
brontomark b19c91a7dd refinements
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m56s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m9s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 5m9s
2026-05-25 14:29:48 +02:00
brontomark 9b5d19b926 refinements 2026-05-25 12:49:04 +02:00
brontomark aad9a991c2 v
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m36s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m8s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 4m22s
2026-05-24 13:35:59 +02:00
brontomark 7f0d18eed1 aggiorna link aggiornamenti
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m47s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m8s
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled
2026-05-24 12:51:16 +02:00
brontomark 879c848d77 v
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m52s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m13s
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled
2026-05-24 12:42:11 +02:00
brontomark 123c006a1e changed navigation 2026-05-24 10:25:16 +02:00
brontomark 415811f592 app shell 2026-05-24 09:49:07 +02:00
brontomark 31066a4d8f v
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m28s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m2s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 4m1s
2026-05-23 17:16:51 +02:00
brontomark b700c2de8d w
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 3m4s
Build and Release FLUX (Multi-Platform) / build-android (push) Failing after 15m38s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m4s
2026-05-23 16:50:56 +02:00
brontomark fda5b8fe2e v
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m2s
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 3m56s
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m24s
2026-05-23 13:46:27 +02:00
brontomark b7a525056a v
Build and Release FLUX (Multi-Platform) / build-windows (push) Failing after 1m58s
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m56s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m30s
2026-05-23 11:08:59 +02:00
brontomark 7a11e829b3 a 2026-05-23 11:08:39 +02:00
brontomark 361b61a694 pub upgrade 2026-05-23 10:18:20 +02:00
brontomark 0cb060c89c aggiunta build web e android
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled
Build and Release FLUX (Multi-Platform) / build-android (push) Has been cancelled
Build and Release FLUX (Multi-Platform) / build-web (push) Has been cancelled
2026-05-22 11:44:41 +02:00
brontomark 4b9cbf65f9 using dep override pdfx da github
Build and Release FLUX Windows / build (push) Has been cancelled
2026-05-22 11:06:19 +02:00
brontomark 813fc9dd38 prova
Build and Release FLUX Windows / build (push) Failing after 26s
2026-05-22 10:45:46 +02:00
brontomark f574d6197b provato ad aggiustare pipeline windows
Build and Release FLUX Windows / build (push) Failing after 49s
2026-05-22 10:35:52 +02:00
brontomark 2fac3117a4 version 2026-05-22 10:23:10 +02:00
brontomark 7b072a219d feat notes 2026-05-22 10:12:56 +02:00
brontomark 23d3356e6b fg 2026-05-21 19:29:46 +02:00
brontomark 5b2702daed notes 2026-05-21 14:43:47 +02:00
brontomark b9c3eb7091 Merge branch 'main' into feat-notes
ho fatto delle modifiche al main necessarie anche di qui
2026-05-20 20:06:34 +02:00
brontomark 6fbc5d947c df
Build and Release FLUX Windows / build (push) Failing after 41s
2026-05-20 17:21:11 +02:00
brontomark f520a02226 v
Build and Release FLUX Windows / build (push) Failing after 29s
2026-05-20 16:48:09 +02:00
brontomark 3a43b2672a v 2026-05-20 16:48:00 +02:00
brontomark 61959a5a2e v
Build and Release FLUX Windows / build (push) Failing after 42s
2026-05-20 16:41:23 +02:00
brontomark 5f16ee2b38 r 2026-05-20 16:38:21 +02:00
brontomark a8ebb1dada df 2026-05-20 16:13:35 +02:00
brontomark 862719b8b0 fd
Build and Release FLUX Windows / build (push) Failing after 28s
2026-05-20 16:12:32 +02:00
brontomark d1ee6d8a10 a
Build and Release FLUX Windows / build (push) Has been cancelled
2026-05-20 15:58:04 +02:00
brontomark c3268012a5 prova auto build
Build and Release FLUX Windows / build (push) Failing after 26s
2026-05-20 14:24:49 +02:00
brontomark da24b6a5ed impostato per auto build & release windows sul pc bancone 2026-05-20 14:20:10 +02:00
brontomark 8b8dd0a427 i 2026-05-20 12:08:10 +02:00
brontomark 979ab5e86d a 2026-05-20 11:07:29 +02:00
brontomark 9703cb5ce8 d 2026-05-20 11:04:02 +02:00
brontomark c85f4b086e refactor nomi tabelle 2026-05-20 11:03:33 +02:00
brontomark f190ad9353 g 2026-05-19 19:28:24 +02:00
brontomark 659963beb0 controllo versione 2026-05-19 18:53:24 +02:00
brontomark d3b1e52d88 f 2026-05-19 17:35:18 +02:00
brontomark 3c0880f527 fix SharedAttachmentSection windows 2026-05-19 17:16:51 +02:00
brontomark 8a1b582f4e fixes 2026-05-19 16:00:40 +02:00
brontomark 364474471c fix status colors 2026-05-19 13:39:19 +02:00
brontomark 3ecf617998 j 2026-05-19 12:46:13 +02:00
brontomark 3f2f55d6c2 auto isBusiness based on customer selected 2026-05-19 12:03:03 +02:00
brontomark 4e03d52a5d aggiunta scelta business o privato 2026-05-19 11:54:59 +02:00
brontomark 2bdba523ad upgraded flutter and refactor document sequences 2026-05-19 11:17:28 +02:00
brontomark 716de36bfa cambiata visualizzazione ultrawide di operation form screen 2026-05-19 10:41:13 +02:00
brontomark 00d5890a37 rifatta operation form e diverse migliorie generali 2026-05-19 10:32:01 +02:00
brontomark ecb161bc07 b 2026-05-18 19:20:38 +02:00
brontomark 1ee4a3bf45 fix 2026-05-18 12:57:07 +02:00
brontomark 5e99324201 refactor shipping attachments and changed shipment to shipping for coherence 2026-05-18 12:00:07 +02:00
brontomark b06a655bc3 msi 2026-05-18 10:02:07 +02:00
brontomark 906265a0e3 k 2026-05-18 08:31:39 +02:00
brontomark 1a21b44bc8 df 2026-05-16 19:34:33 +02:00
brontomark a8c9e0f253 g 2026-05-16 16:39:56 +02:00
brontomark 491a857f61 d 2026-05-16 15:49:46 +02:00
brontomark b3f463b688 fix macos pdf 2026-05-16 14:30:23 +02:00
brontomark 9a5d0e33bd stampa ddt 2026-05-16 11:51:26 +02:00
brontomark a166992b04 refined document sequence management 2026-05-16 09:04:18 +02:00
brontomark b5ccb0428d fdsg 2026-05-15 19:18:03 +02:00
brontomark f4a8314978 f 2026-05-15 13:32:34 +02:00
brontomark f19f19a279 refactor providers e basi per spedizioni 2026-05-15 10:12:05 +02:00
brontomark ad35f641b3 k 2026-05-14 19:22:02 +02:00
brontomark 6c892bf580 d 2026-05-14 19:16:13 +02:00
brontomark 89099c2cfd lavorazione dei ticket 2026-05-14 15:59:46 +02:00
brontomark 0f9616f19a d 2026-05-14 12:07:05 +02:00
brontomark 3b3cfb5e43 f 2026-05-13 19:24:25 +02:00
brontomark 24004a99da fix routing 2026-05-13 18:12:08 +02:00
brontomark ab7601a74e icons 2026-05-13 16:35:34 +02:00
brontomark f09606e1f7 fix isSingleUserMode inflated in SessionCubit 2026-05-13 15:55:06 +02:00
brontomark c610d68b9c added singleUserMode and removed StaffSection from forms 2026-05-13 15:41:35 +02:00
brontomark efb82b0d4a uff 2026-05-13 12:41:07 +02:00
brontomark 216fd85888 a 2026-05-12 12:36:50 +02:00
brontomark 2aab70aec5 sistemati ticket 2026-05-12 11:14:48 +02:00
brontomark 57061da20d a 2026-05-11 20:44:17 +02:00
brontomark cbc5387097 w 2026-05-11 18:35:53 +02:00
brontomark e52dbee835 mmm 2026-05-11 18:19:48 +02:00
brontomark 1dee51a7cd prova con metodo pdf vecchio programma assistenza 2026-05-11 17:13:57 +02:00
brontomark a76180497e boh 2026-05-11 11:44:14 +02:00
brontomark 5c86483563 ticket labels e ticket receipt 2026-05-10 14:09:57 +02:00
brontomark 385c3da0a5 named router with constants to prevent silent bugs 2026-05-09 20:42:42 +02:00
brontomark 5f39d5b1ad change routes with names 2026-05-09 19:32:40 +02:00
brontomark 1081609530 fix router 2026-05-09 17:30:51 +02:00
brontomark 901f63841f d 2026-05-09 16:00:40 +02:00
brontomark 27a262b54a changed image upload screen from mobile upload screen 2026-05-09 16:00:06 +02:00
brontomark a81515e4d8 dialog qr si chiude quando upload finito 2026-05-09 11:43:54 +02:00
brontomark 73c5751677 Refactor QrUploadDialog to integrate BlocListener for attachment state management 2026-05-09 11:30:02 +02:00
brontomark 0171ee6141 Refactor camera handling to remove image quality setting and streamline processing logic 2026-05-09 11:24:08 +02:00
brontomark 1ee2758756 Improve camera image processing with overlay and error handling 2026-05-09 11:07:38 +02:00
brontomark fbb21dd8a4 f 2026-05-09 11:03:12 +02:00
brontomark 45d49b38f7 tolto upsert nel upload documenti (cozzava con rls) 2026-05-09 10:54:49 +02:00
brontomark 91a7663681 f 2026-05-09 10:20:53 +02:00
brontomark 302bec114f fix 2026-05-09 10:08:29 +02:00
brontomark 65aa3c7de8 fix mobile upload 2026-05-09 09:50:20 +02:00
brontomark c6ef798b22 dfa 2026-05-08 18:51:28 +02:00
brontomark 42a9506f02 j 2026-05-08 12:28:14 +02:00
brontomark 9793ba8348 a 2026-05-07 19:29:39 +02:00
brontomark fbf18acf05 df 2026-05-07 18:37:25 +02:00
brontomark 5c1f9c0ebc upload ticket files 2026-05-07 18:08:45 +02:00
brontomark 4cc1c9d157 df
Deploy to Cloudflare Pages / build-and-deploy (push) Has been cancelled
2026-05-07 16:32:26 +02:00
brontomark 7d03d0dea5 feat-tickets (#14)
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>
2026-05-07 16:28:01 +02:00
329 changed files with 34174 additions and 8517 deletions

No files matched your search

+217
View File
@@ -0,0 +1,217 @@
name: Build and Release FLUX (Multi-Platform)
on:
push:
tags:
- 'v*'
jobs:
# -----------------------------------------------------------------
# JOB 1: WINDOWS (Gira sul PC del collega appena si libera)
# -----------------------------------------------------------------
build-windows:
runs-on: windows-native
steps:
- name: Checkout del codice
uses: actions/checkout@v3
- name: Crea file .env
run: |
Set-Content -Path ".env" -Value "${{ secrets.ENV_FILE_CONTENT }}"
- name: Build Flutter Windows
run: flutter build windows --release
# 1. FIRMA DELL'ESEGUIBILE RAW
- name: Firma Eseguibile Flutter
run: |
# Cerca dinamicamente signtool.exe nell'SDK di Windows per non sbagliare percorso
$Signtool = (Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe" | Sort-Object FullName -Descending | Select-Object -First 1).FullName
# Sostituisci il percorso con dove hai salvato fisicamente il file .pfx sul PC del runner!
& $Signtool sign /f "C:\flux_privato.pfx" /p "${{ secrets.PFX_PASSWORD }}" /fd SHA256 "build\windows\x64\runner\Release\flux.exe"
- name: Build Windows Installer
run: |
$TagVersion = "${{ github.ref_name }}".Substring(1)
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "/DMyAppVersion=$TagVersion" "win_installer.iss"
# 2. FIRMA DELL'INSTALLER GENERATO DA INNO SETUP
- name: Firma Installer
run: |
$Signtool = (Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe" | Sort-Object FullName -Descending | Select-Object -First 1).FullName
& $Signtool sign /f "C:\flux_privato.pfx" /p "${{ secrets.PFX_PASSWORD }}" /fd SHA256 "build\windows\installer\FluxInstaller.exe"
# Nel dubbio usiamo l'action per caricare l'asset
- name: Upload Windows Asset
uses: https://gitea.com/actions/release-action@main
with:
files: "build/windows/installer/FluxInstaller.exe"
api_key: ${{ secrets.MYRELEASE_TOKEN }}
- name: Aggiorna Link Windows su Supabase
run: |
$TagVersion = "${{ github.ref_name }}".TrimStart('v')
$headers = @{
"apikey" = "${{ secrets.SUPABASE_SERVICE_KEY }}"
"Authorization" = "Bearer ${{ secrets.SUPABASE_SERVICE_KEY }}"
"Content-Type" = "application/json"
}
$body = (@{
download_url = "https://gitea.catelli.it/brontomark/flux/releases/download/${{ github.ref_name }}/FluxInstaller.exe"
latest_version = $TagVersion
} | ConvertTo-Json)
Invoke-RestMethod -Uri "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.windows" -Method Patch -Headers $headers -Body $body -UserAgent "flux-runner"
- name: Pulisci Workspace Windows
if: always()
run: Remove-Item -Recurse -Force ./*
# -----------------------------------------------------------------
# JOB 3: WEB & CLOUDFLARE DEPLOY (Gira sul runner Fedora o Mac)
# -----------------------------------------------------------------
build-web:
runs-on: cross-runner
steps:
- name: Checkout del codice
uses: actions/checkout@v3
- name: Crea file .env
run: |
cat << 'EOF' > .env
${{ secrets.ENV_FILE_CONTENT }}
EOF
- name: Build Flutter Web
run: flutter build web --release
# Sfruttiamo npx (incluso in Node.js) per lanciare wrangler al volo senza installarlo globalmente
# Sto assumendo che usi Cloudflare Pages che è perfetto per Flutter Web statico
- name: Deploy su Cloudflare Pages
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
npx wrangler pages deploy build/web --project-name="flux" --branch="main"
- name: Aggiorna Versione Web su Supabase
run: |
TagVersion="${GITHUB_REF_NAME#v}"
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.web" \
-H "apikey: ${{ secrets.SUPABASE_SERVICE_KEY }}" \
-H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_KEY }}" \
-H "Content-Type: application/json" \
-d "{\"latest_version\": \"$TagVersion\"}"
# -----------------------------------------------------------------
# JOB 4: LINUX APPIMAGE (Gira sul tuo PC Fedora / Linux Runner)
# -----------------------------------------------------------------
build-linux:
runs-on: linux-runner # <--- Etichetta del tuo runner Linux / Fedora in ufficio
steps:
- name: Checkout del codice
uses: actions/checkout@v3
- name: Crea file .env
run: |
cat << 'EOF' > .env
${{ secrets.ENV_FILE_CONTENT }}
EOF
- name: Build Flutter Linux
run: flutter build linux --release
- name: Prepara AppDir per AppImage
run: |
mkdir -p build/Flux.AppDir
cp -r build/linux/x64/release/bundle/* build/Flux.AppDir/
cp assets/icon/icon.png build/Flux.AppDir/flux.png
cat << 'EOF' > build/Flux.AppDir/AppRun
#!/bin/sh
cd "$(dirname "$0")"
exec ./flux "$@"
EOF
chmod +x build/Flux.AppDir/AppRun
cat << 'EOF' > build/Flux.AppDir/Flux.desktop
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Name=Flux
Exec=flux %u
Icon=flux
Categories=Utility;
EOF
- name: Scarica appimagetool se non presente
run: |
if [ ! -f ./appimagetool-x86_64.AppImage ]; then
curl -L -o appimagetool-x86_64.AppImage https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage
fi
- name: Genera AppImage
run: |
ARCH=x86_64 ./appimagetool-x86_64.AppImage build/Flux.AppDir Flux-x86_64.AppImage
- name: Upload Linux AppImage Asset
uses: https://gitea.com/actions/release-action@main
with:
files: "Flux-x86_64.AppImage"
api_key: ${{ secrets.MYRELEASE_TOKEN }}
- name: Aggiorna Link Linux su Supabase
run: |
TagVersion="${GITHUB_REF_NAME#v}"
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.AppImage" \
-H "apikey: ${{ secrets.SUPABASE_SERVICE_KEY }}" \
-H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_KEY }}" \
-H "Content-Type: application/json" \
-d "{\"download_url\": \"https://gitea.catelli.it/brontomark/flux/releases/download/${{ github.ref_name }}/Flux-x86_64.AppImage\", \"latest_version\": \"$TagVersion\"}"
# -----------------------------------------------------------------
# JOB 5: MACOS (Gira sul tuo Mac / macos-runner)
# -----------------------------------------------------------------
build-macos:
runs-on: macos-runner
steps:
- name: Checkout del codice
uses: actions/checkout@v3
- name: Crea file .env
run: |
cat << 'EOF' > .env
${{ secrets.ENV_FILE_CONTENT }}
EOF
- name: Build Flutter macOS
run: flutter build macos --release
- name: Genera DMG e ZIP macOS
run: |
# Crea DMG dell'applicazione
hdiutil create -volname "Flux" -srcfolder "build/macos/Build/Products/Release/flux.app" -ov -format UDZO "Flux-macOS.dmg"
# Crea anche archivio ZIP di backup
cd build/macos/Build/Products/Release
zip -r -y ../../../../Flux-macOS.zip "flux.app"
cd -
- name: Upload macOS Assets
uses: https://gitea.com/actions/release-action@main
with:
files: |
Flux-macOS.dmg
Flux-macOS.zip
api_key: ${{ secrets.MYRELEASE_TOKEN }}
- name: Aggiorna Link macOS su Supabase
run: |
TagVersion="${GITHUB_REF_NAME#v}"
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.macos" \
-H "apikey: ${{ secrets.SUPABASE_SERVICE_KEY }}" \
-H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_KEY }}" \
-H "Content-Type: application/json" \
-d "{\"download_url\": \"https://gitea.catelli.it/brontomark/flux/releases/download/${{ github.ref_name }}/Flux-macOS.dmg\", \"latest_version\": \"$TagVersion\"}"
+5 -1
View File
@@ -6,7 +6,7 @@
*.env
.DS_Store
.atom/
.build/
.build/*
.buildlog/
.history
.svn/
@@ -46,3 +46,7 @@ app.*.map.json
/android/app/release
.env
appimagetool*
*.AppDir
*.AppImage
+3
View File
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
+4
View File
@@ -0,0 +1,4 @@
{
"account_id": "6badf20faeef39fa5c99283f46f07508",
"project_name": "flux"
}
+6
View File
@@ -0,0 +1,6 @@
{
"account": {
"id": "6badf20faeef39fa5c99283f46f07508",
"name": "Marco@catelli.it's Account"
}
}
+8
View File
@@ -7,6 +7,14 @@ analyzer:
- "lib/l10n/*.dart"
- "**/*.g.dart" # Già che ci siamo escludiamo tutti i file generati (tipo quelli di JsonSerializable)
- "**/*.freezed.dart"
- "build/**"
- "ios/**"
- "macos/**"
- ".dart_tool/**"
- android/**
- web/**
- windows/**
- linux/**
linter:
rules:
+24 -4
View File
@@ -1,3 +1,6 @@
import java.io.FileInputStream
import java.util.Properties
plugins {
id("com.android.application")
// START: FlutterFire Configuration
@@ -8,6 +11,13 @@ plugins {
id("dev.flutter.flutter-gradle-plugin")
}
// 2. CARICHIAMO IL KEYSTORE QUI FUORI IN MODO PULITO
val keystoreProperties = Properties()
val keystorePropertiesFile = rootProject.file("key.properties")
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
android {
namespace = "com.catellisrl.flux"
compileSdk = flutter.compileSdkVersion
@@ -23,7 +33,6 @@ android {
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.catellisrl.flux"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
@@ -33,11 +42,22 @@ android {
versionName = flutter.versionName
}
signingConfigs {
create("release") {
keyAlias = keystoreProperties["keyAlias"] as String?
keyPassword = keystoreProperties["keyPassword"] as String?
storeFile = keystoreProperties["storeFile"]?.let { file(it as String) }
storePassword = keystoreProperties["storePassword"] as String?
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
signingConfig = if (keystorePropertiesFile.exists()) {
signingConfigs.getByName("release")
} else {
signingConfigs.getByName("debug")
}
}
}
}
+5 -62
View File
@@ -1,70 +1,13 @@
{
"project_info": {
"project_number": "872447580790",
"project_id": "assistenza-catelli",
"storage_bucket": "assistenza-catelli.firebasestorage.app"
"project_number": "249756116297",
"project_id": "flux-87e49",
"storage_bucket": "flux-87e49.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:872447580790:android:193235afcc2920ce5d9d57",
"android_client_info": {
"package_name": "com.catelli.scans2"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBSxpdLDlPnN0xjejlX_5JL19BDeSzKOr8"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:872447580790:android:9c6172d77b1d2cae5d9d57",
"android_client_info": {
"package_name": "com.catellisrl.assistenza"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBSxpdLDlPnN0xjejlX_5JL19BDeSzKOr8"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:872447580790:android:425d21710d7682005d9d57",
"android_client_info": {
"package_name": "com.catellisrl.catelli_energy_comparator"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBSxpdLDlPnN0xjejlX_5JL19BDeSzKOr8"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:872447580790:android:a1d8d57960451f935d9d57",
"mobilesdk_app_id": "1:249756116297:android:a2c3d37323752069cf2698",
"android_client_info": {
"package_name": "com.catellisrl.flux"
}
@@ -72,7 +15,7 @@
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBSxpdLDlPnN0xjejlX_5JL19BDeSzKOr8"
"current_key": "AIzaSyA6-uX6504B3yofeo7YQwfQaS0cCDoZnvY"
}
],
"services": {
+3 -3
View File
@@ -2,7 +2,7 @@
<application
android:label="flux"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:exported="true"
@@ -24,11 +24,11 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:label="flux_deep_link">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="fluxapp" />
<data android:scheme="flux" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+4
View File
@@ -1,2 +1,6 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=false
# This newDsl flag was added automatically by Flutter migrator
android.newDsl=false
BIN
View File
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

-1
View File
@@ -1 +0,0 @@
{"meta":{"format":"JSON","version":"1.1.0","projectId":"assistenza-catelli","resourcePath":["schedeRiparazione"],"recursive":false,"creationTime":1778021386,"app":"firefoo"},"data":{"0bFEvYfMXvsYc6QKWkGQ":{"accessoriConsegnati":"S23 ULTRA + NOTE 8","costoTotaleCliente":0,"costoTotaleNostro":0,"daAvvisare":false,"daInviareCentroRiparazione":false,"daLavorare":false,"daRiconsegnare":false,"dataAperturaScheda":{"__time__":"2025-12-23T12:08:37.953Z"},"dataChiusuraScheda":{"__time__":"2025-12-23T14:15:22.278Z"},"dataDdtUscita":null,"dataRiconsegnaCliente":{"__time__":"2025-12-23T14:15:26.278Z"},"fornitoreRiparazione":"","fotoProdotto":[],"fsId":"0bFEvYfMXvsYc6QKWkGQ","guadagno":0,"guasto":"PASSAGGIO DATI EURO 25","idAddettoApertura":"yVTYzBCOf13xVCm7gkIR","idCliente":"4xYNgfgpIAr0nZ1PGj9x","idDdtUscita":"","idMarca":"2nSVvH1foZ1QHkMBaLhN","idModello":"rnUhh2nP1GnfUzvZ4LEq","idStatoScheda":"Qp6ykdP2jY5AKL9IfL3r","idTipoGaranzia":"","idTipologiaProdotto":"ci4bFArJ24iEys5w2bdi","idsDettagliRicambi":[],"marcaEModello":"Samsung S23 Ultra","nomeAddettoApertura":"Beppe","nomeCliente":"Bartoletti Patrizia","nomeMarca":"Samsung","nomeModello":"S23 Ultra","nomeStatoScheda":"Ritirato da cliente","nomeTipoGaranzia":"Fuori garanzia","nomeTipologiaProdotto":"Smartphone","note":"RECAPITO ALTERNATIVO: 3331568683 (ELENA)\nSBLOCCO: 7498\nPW: wallis.39","noteInterne":"","numeroDdtUscita":0,"numeroScheda":852,"operazioneEffettuata":"fatto tutto","posizione":"Non specificata","prefissoDdt":"","prestatoMuletto":false,"recapitoCliente":"3336674404","richiestaPreventivo":false,"riconsegnato":true,"risolto":true,"risultato":"OK","schedaAperta":false,"seriale":"","suffissoDdt":"","tipoLavorazioneAggiornamenti":false,"tipoLavorazioneAltro":false,"tipoLavorazioneConfigurazione":false,"tipoLavorazionePassaggioDati":true,"tipoLavorazioneRiparazione":false,"__collections__":{"tracciamento":{"9pr5mTy1RmM06I6x3VCd":{"commento":"Accettazione effettuata","data":{"__time__":"2025-12-23T12:08:38.024Z"},"fsId":"9pr5mTy1RmM06I6x3VCd","idAddetto":"yVTYzBCOf13xVCm7gkIR","idScheda":"0bFEvYfMXvsYc6QKWkGQ","nomeAddetto":"Beppe","note":"Commento automatico","__collections__":{}},"PwsczccVQhyw3qvrcNEE":{"commento":"Stato cambiato -> In lavorazione","data":{"__time__":"2025-12-23T14:15:15.551Z"},"fsId":"PwsczccVQhyw3qvrcNEE","idAddetto":"yVTYzBCOf13xVCm7gkIR","idScheda":"0bFEvYfMXvsYc6QKWkGQ","nomeAddetto":"Beppe","note":"Commento automatico","__collections__":{}},"frqTHElw2bK5nDveRUV0":{"commento":"Stato cambiato -> Chiusa e pronta per il ritiro","data":{"__time__":"2025-12-23T14:15:22.367Z"},"fsId":"frqTHElw2bK5nDveRUV0","idAddetto":"yVTYzBCOf13xVCm7gkIR","idScheda":"0bFEvYfMXvsYc6QKWkGQ","nomeAddetto":"Beppe","note":"Commento automatico","__collections__":{}},"nCryDVATQEzDO5iM6NoB":{"commento":"Stato cambiato -> Riconsegnato al cliente","data":{"__time__":"2025-12-23T14:15:26.278Z"},"fsId":"nCryDVATQEzDO5iM6NoB","idAddetto":"yVTYzBCOf13xVCm7gkIR","idScheda":"0bFEvYfMXvsYc6QKWkGQ","nomeAddetto":"Beppe","note":"Commento automatico","__collections__":{}}}}},"1WwKE6ZaLbsk8ng6i99V":{"accessoriConsegnati":"COVER","costoTotaleCliente":0,"costoTotaleNostro":0,"daAvvisare":false,"daInviareCentroRiparazione":false,"daLavorare":false,"daRiconsegnare":false,"dataAperturaScheda":{"__time__":"2026-02-03T09:56:03.197Z"},"dataChiusuraScheda":{"__time__":"2026-02-03T13:15:16.425Z"},"dataDdtUscita":null,"dataRiconsegnaCliente":{"__time__":"2026-02-03T13:15:23.417Z"},"fornitoreRiparazione":"","fotoProdotto":[],"fsId":"1WwKE6ZaLbsk8ng6i99V","guadagno":0,"guasto":"PROBABILE VIRUS","idAddettoApertura":"23jkkj23n3rboss2","idCliente":"JHAHDQwCtcxynMVWaBi7","idDdtUscita":"","idMarca":"lZhFskKDPf0AH548pbCP","idModello":"UwnwVF0sQs5EvQs0LtNX","idStatoScheda":"Qp6ykdP2jY5AKL9IfL3r","idTipoGaranzia":"","idTipologiaProdotto":"ci4bFArJ24iEys5w2bdi","idsDettagliRicambi":[],"marcaEModello":"Oppo Oppo Reno Pro 5g","nomeAddettoApertura":"Stefano","nomeCliente":"Pavignani Raffaella","nomeMarca":"Oppo","nomeModello":"Oppo Reno Pro 5g","nomeStatoScheda":"Ritirato da cliente","nomeTipoGaranzia":"Fuori garanzia","nomeTipologiaProdotto":"Smartphone","note":"SBLOCCO SCHERMO 140776\nPIN SIM 3787 (POI DA RIMUOVERE)","noteInterne":"","numeroDdtUscita":0,"numeroScheda":881,"operazioneEffettuata":"OK","posizione":"Non specificata","prefissoDdt":"","prestatoMuletto":false,"recapitoCliente":"3288616487","richiestaPreventivo":false,"riconsegnato":true,"risolto":true,"risultato":"OK","schedaAperta":false,"seriale":"","suffissoDdt":"","tipoLavorazioneAggiornamenti":false,"tipoLavorazioneAltro":true,"tipoLavorazioneConfigurazione":false,"tipoLavorazionePassaggioDati":false,"tipoLavorazioneRiparazione":false,"__collections__":{"tracciamento":{"KdxgHYR40GuFH9dvDLU4":{"commento":"Stato cambiato -> Chiusa e pronta per il ritiro","data":{"__time__":"2026-02-03T13:15:18.114Z"},"fsId":"KdxgHYR40GuFH9dvDLU4","idAddetto":"yVTYzBCOf13xVCm7gkIR","idScheda":"1WwKE6ZaLbsk8ng6i99V","nomeAddetto":"Beppe","note":"CommentoLine truncated
+1 -1
View File
@@ -1 +1 @@
{"flutter":{"platforms":{"android":{"default":{"projectId":"assistenza-catelli","appId":"1:872447580790:android:a1d8d57960451f935d9d57","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"assistenza-catelli","configurations":{"android":"1:872447580790:android:a1d8d57960451f935d9d57","ios":"1:872447580790:ios:a87d56c718aa61e05d9d57","macos":"1:872447580790:ios:a87d56c718aa61e05d9d57","web":"1:872447580790:web:10745e7f9afb447d5d9d57","windows":"1:872447580790:web:3b1623eda6abdac75d9d57"}}}}}}
{"flutter":{"platforms":{"android":{"default":{"projectId":"flux-87e49","appId":"1:249756116297:android:a2c3d37323752069cf2698","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"flux-87e49","appId":"1:249756116297:ios:fe9dadca7150da16cf2698","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"macos":{"default":{"projectId":"flux-87e49","appId":"1:249756116297:ios:fe9dadca7150da16cf2698","uploadDebugSymbols":false,"fileOutput":"macos/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"flux-87e49","configurations":{"android":"1:249756116297:android:a2c3d37323752069cf2698","ios":"1:249756116297:ios:fe9dadca7150da16cf2698","macos":"1:249756116297:ios:fe9dadca7150da16cf2698","web":"1:249756116297:web:7c652e51004414b7cf2698","windows":"1:249756116297:web:b094277c2fedb425cf2698"}}}}}}
+34
View File
@@ -0,0 +1,34 @@
# flutter pub run flutter_launcher_icons
flutter_launcher_icons:
image_path: "assets/icon/icon.png"
android: "launcher_icon"
image_path_android: "assets/icon/icon.png"
min_sdk_android: 21 # android min sdk min:16, default 21
# adaptive_icon_background: "assets/icon/background.png"
# adaptive_icon_foreground: "assets/icon/foreground.png"
# adaptive_icon_foreground_inset: 16
# adaptive_icon_monochrome: "assets/icon/monochrome.png"
ios: true
image_path_ios: "assets/icon/icon.png"
remove_alpha_ios: true
# image_path_ios_dark_transparent: "assets/icon/icon_dark.png"
# image_path_ios_tinted_grayscale: "assets/icon/icon_tinted.png"
# desaturate_tinted_to_grayscale_ios: true
background_color_ios: "#ffffff"
web:
generate: true
image_path: "assets/icon/icon.png"
background_color: "#FFFFFF"
theme_color: "#000000"
windows:
generate: true
image_path: "assets/icon/icon.png"
icon_size: 256 # min:48, max:256, default: 48
macos:
generate: true
image_path: "assets/icon/icon.png"
@@ -0,0 +1 @@
␍ .env ␍asset.envassets/icon/icon.png ␍assetassets/icon/icon.png assets/images/flux_logo_dark.png ␍asset assets/images/flux_logo_dark.png!assets/images/flux_logo_light.png ␍asset!assets/images/flux_logo_light.pngassets/svg/flux_logo_dark.svg ␍assetassets/svg/flux_logo_dark.svgassets/svg/flux_logo_light.svg ␍assetassets/svg/flux_logo_light.svgMpackages/font_awesome_flutter/lib/fonts/Font-Awesome-7-Brands-Regular-400.otf ␍assetMpackages/font_awesome_flutter/lib/fonts/Font-Awesome-7-Brands-Regular-400.otfKpackages/font_awesome_flutter/lib/fonts/Font-Awesome-7-Free-Regular-400.otf ␍assetKpackages/font_awesome_flutter/lib/fonts/Font-Awesome-7-Free-Regular-400.otfIpackages/font_awesome_flutter/lib/fonts/Font-Awesome-7-Free-Solid-900.otf ␍assetIpackages/font_awesome_flutter/lib/fonts/Font-Awesome-7-Free-Solid-900.otf
@@ -0,0 +1 @@
[{"family":"MaterialIcons","fonts":[{"asset":"fonts/MaterialIcons-Regular.otf"}]},{"family":"packages/font_awesome_flutter/FontAwesomeBrands","fonts":[{"weight":400,"asset":"packages/font_awesome_flutter/lib/fonts/Font-Awesome-7-Brands-Regular-400.otf"}]},{"family":"packages/font_awesome_flutter/FontAwesomeRegular","fonts":[{"weight":400,"asset":"packages/font_awesome_flutter/lib/fonts/Font-Awesome-7-Free-Regular-400.otf"}]},{"family":"packages/font_awesome_flutter/FontAwesomeSolid","fonts":[{"weight":900,"asset":"packages/font_awesome_flutter/lib/fonts/Font-Awesome-7-Free-Solid-900.otf"}]}]
Binary file not shown.
@@ -0,0 +1 @@
{"format-version":[1,0,0],"native-assets":{}}
Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="220mm"
height="70mm"
viewBox="0 0 220 70"
version="1.1"
id="svg1"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs1">
<linearGradient
id="linearGradient4">
<stop
style="stop-color:#0467a8;stop-opacity:1;"
offset="0.17659575"
id="stop6" />
<stop
style="stop-color:#09a8bd;stop-opacity:1;"
offset="1"
id="stop7" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient4"
id="linearGradient5"
x1="2.1388452"
y1="38.851192"
x2="70.730141"
y2="38.851192"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,-1.0583333)" />
</defs>
<metadata
id="metadata1">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<path
d="m 79.119202,16.272909 v 38.473103 h 5.331457 V 36.220011 H 101.87182 V 31.672485 H 84.450659 v -10.85205 h 20.275251 v -4.547526 z m 31.691608,0 v 38.473103 h 25.36434 V 50.198486 H 116.14226 V 16.272909 Z m 30.10359,0 v 23.02185 c 0,2.911107 0.31379,5.365736 0.94206,7.363892 0.64622,1.998156 1.69671,3.703477 3.15071,5.115967 1.27449,1.240234 2.84499,2.179539 4.71186,2.816882 1.86686,0.637342 4.05705,0.956014 6.57014,0.956014 2.45924,0 4.61323,-0.301962 6.46214,-0.904854 1.84891,-0.602892 3.46453,-1.558906 4.84673,-2.868042 1.454,-1.378039 2.49505,-3.100586 3.12332,-5.167644 0.64622,-2.084283 0.96894,-4.521687 0.96894,-7.312215 v -23.02185 h -5.33095 v 23.409423 c 0,1.877578 -0.15269,3.453709 -0.45785,4.728394 -0.28721,1.25746 -0.78097,2.377115 -1.48105,3.358968 -0.80777,1.136881 -1.88451,1.989542 -3.23081,2.557983 -1.3463,0.551216 -2.97976,0.826823 -4.90047,0.826823 -1.90277,0 -3.53675,-0.28422 -4.90099,-0.852661 -1.3463,-0.56844 -2.41411,-1.412489 -3.20394,-2.532145 -0.70008,-0.981853 -1.20276,-2.07567 -1.50792,-3.281453 -0.28721,-1.205784 -0.43098,-2.850817 -0.43098,-4.9351 V 16.272909 Z m 37.72327,0 13.65137,19.249471 -13.97486,19.223632 h 5.81618 l 11.20139,-15.838826 10.93163,15.838826 h 6.16603 L 198.6163,35.289836 212.45628,16.272909 h -5.84305 l -11.03964,15.63212 -10.79727,-15.63212 z"
style="font-size:54.019px;font-family:Roboto;-inkscape-font-specification:'Roboto, @wght=600';font-variation-settings:'wght' 600;stroke-width:0.270095"
id="path10" />
<path
d="m 18.746659,32.35048 v 35.012333 l 7.483265,0.01602 -0.0078,-15.15153 -0.444417,0.0088 -0.283187,-5.574853 0.724503,-0.09353 -0.0052,-10.30273 c -2.477109,-1.576343 -4.681183,-2.913234 -7.467245,-3.91449 z"
style="font-variation-settings:'wght' 600;fill:#0467a8;stroke-width:0.264583"
id="path4" />
<path
d="m 34.188094,44.204537 -2.362646,1.228349 -3.40186,0.850077 -2.92902,0.378272 0.283187,5.574853 4.819344,-0.09405 3.024105,-1.03973 2.362129,-1.417484 1.512053,-0.756027 z"
style="font-variation-settings:'wght' 600;fill:#0467a8;stroke-width:0.264583"
id="path3" />
<path
d="m 30.789852,3.3827393 c -2.718649,-0.031966 -5.436525,0.014505 -8.153508,0.092501 -1.657421,0.047579 -3.410165,1.1618896 -3.915523,2.4758178 -0.117943,1.3009842 -0.120443,2.6260493 -0.194303,3.9361939 -0.03417,4.6029962 0.05579,9.2082292 0.06976,13.8120772 l 8.031551,2.645316 V 15.482776 c -0.06845,-1.616367 -0.186384,-3.220801 5.17e-4,-4.823995 1.450909,-0.02681 2.901798,-0.0533 4.352706,-0.0801 0.05294,-7.58e-4 0.101815,-0.0019 0.146761,-0.0026 -0.133325,0.0041 -0.29154,0.0097 -0.465088,0.01705 5.402012,0.128802 10.810722,0.09637 16.214514,0.01395 1.312459,0.137599 2.534326,-0.34712 3.780648,-0.6609411 0.688414,-0.375834 1.230544,-1.0271554 1.861385,-1.5115356 0.530757,-0.2588779 0.43123,-0.8718681 0.550871,-1.361674 0.317571,-1.2121917 0.137814,-2.4561815 0.111104,-3.690214 z"
style="font-variation-settings:'wght' 600;fill:#0467a8;stroke-width:0.264583"
id="path2" />
<path
d="m 56.166081,18.073315 c -1.612095,0.517615 -3.326896,0.856005 -4.876705,1.482597 -1.672317,1.636751 -3.569999,3.080027 -4.731494,5.154724 -1.760645,2.382939 -3.026169,5.086524 -4.280876,7.757666 -0.891629,2.073315 -1.768619,4.152921 -2.589506,6.255433 l 4.441073,4.251936 c 1.398551,-3.4772 2.668634,-7.012956 4.53719,-10.275341 0.629987,-1.555517 1.666989,-2.831823 2.828251,-4.022494 1.022671,-1.037894 1.767254,-2.482454 3.326929,-2.735233 0.889424,-0.171791 1.852674,-1.15661 2.651001,-0.326079 1.091115,0.724393 2.380755,1.270451 3.353284,2.101164 0.773793,1.805199 1.727371,3.571064 2.391068,5.400187 -0.10305,3.050467 0.318141,6.150981 -0.478523,9.13536 -0.227898,1.392226 -0.44891,2.787081 -1.327568,3.939294 -0.639724,0.878207 -0.930155,2.134421 -1.788004,2.776575 -1.441269,0.609895 -2.847747,1.462494 -4.310848,1.920296 -1.617481,-0.300784 -3.315903,-0.407844 -4.88394,-0.826823 -2.069996,-1.549653 -4.248341,-2.976127 -5.912301,-4.986259 -2.758844,-2.90603 -5.507188,-5.823363 -8.591207,-8.391735 -3.338252,-2.881492 -6.432985,-6.060987 -10.113077,-8.519377 -1.00535,-0.833342 -2.074808,-1.535604 -3.393075,-1.725476 -2.128037,-0.523545 -4.194319,-1.47308 -6.429582,-1.257805 -2.170664,0.06994 -4.409538,-0.393106 -6.482808,0.438733 -0.9003416,0.331796 -2.1359215,0.232269 -2.4158733,1.361674 -1.9123575,3.173056 -3.6177926,6.486404 -4.6400268,10.062435 -0.4008915,1.586154 -0.4139892,3.222181 -0.038241,4.817794 l 0.1400432,0.924491 c 0.8820904,-2.491562 1.2764827,-5.195371 2.8018961,-7.407299 0.6237014,-1.09468 1.1172001,-2.309336 2.3424927,-2.850472 1.0032429,-0.704794 1.9546502,-1.540401 3.2581987,-1.487765 3.00294,-0.587415 6.099427,-0.06595 9.095052,0.498161 1.4899,0.270585 2.725854,0.959381 4.081922,1.606103 2.823588,1.93021 5.578022,3.981722 8.006229,6.392375 3.658406,4.382924 6.878979,9.116624 10.426754,13.577466 1.153639,1.018099 2.201592,2.226861 3.41943,3.129008 1.866433,0.375292 3.683112,1.179818 5.582605,1.267623 2.379016,-0.109475 4.813761,-0.01813 7.158736,-0.251148 2.193684,-1.301699 4.557492,-2.436561 6.645589,-3.841626 1.382677,-2.657284 2.904182,-5.268723 4.200261,-7.954553 0.355987,-2.855588 0.956499,-5.711351 1.159619,-8.566919 -0.441278,-2.56316 -0.629473,-5.204579 -1.227832,-7.718909 -1.026057,-1.96421 -1.887153,-4.070949 -3.014287,-5.947957 -1.857041,-1.18145 -3.561937,-2.667789 -5.518009,-3.65094 -1.601938,-0.471008 -3.198698,-1.192578 -4.803841,-1.506885 z"
style="fill:url(#linearGradient5);stroke-width:0.264583"
id="path1" />
</svg>

After

Width:  |  Height:  |  Size: 6.7 KiB

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="220mm"
height="70mm"
viewBox="0 0 220 70"
version="1.1"
id="svg1"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs1">
<linearGradient
id="linearGradient4">
<stop
style="stop-color:#0467a8;stop-opacity:1;"
offset="0.17659575"
id="stop6" />
<stop
style="stop-color:#09a8bd;stop-opacity:1;"
offset="1"
id="stop7" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient4"
id="linearGradient5"
x1="2.1388452"
y1="38.851192"
x2="70.730141"
y2="38.851192"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,-1.0583333)" />
</defs>
<metadata
id="metadata1">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<path
d="m 79.119202,16.272909 v 38.473103 h 5.331457 V 36.220011 H 101.87182 V 31.672485 H 84.450659 v -10.85205 h 20.275251 v -4.547526 z m 31.691608,0 v 38.473103 h 25.36434 V 50.198486 H 116.14226 V 16.272909 Z m 30.10359,0 v 23.02185 c 0,2.911107 0.31379,5.365736 0.94206,7.363892 0.64622,1.998156 1.69671,3.703477 3.15071,5.115967 1.27449,1.240234 2.84499,2.179539 4.71186,2.816882 1.86686,0.637342 4.05705,0.956014 6.57014,0.956014 2.45924,0 4.61323,-0.301962 6.46214,-0.904854 1.84891,-0.602892 3.46453,-1.558906 4.84673,-2.868042 1.454,-1.378039 2.49505,-3.100586 3.12332,-5.167644 0.64622,-2.084283 0.96894,-4.521687 0.96894,-7.312215 v -23.02185 h -5.33095 v 23.409423 c 0,1.877578 -0.15269,3.453709 -0.45785,4.728394 -0.28721,1.25746 -0.78097,2.377115 -1.48105,3.358968 -0.80777,1.136881 -1.88451,1.989542 -3.23081,2.557983 -1.3463,0.551216 -2.97976,0.826823 -4.90047,0.826823 -1.90277,0 -3.53675,-0.28422 -4.90099,-0.852661 -1.3463,-0.56844 -2.41411,-1.412489 -3.20394,-2.532145 -0.70008,-0.981853 -1.20276,-2.07567 -1.50792,-3.281453 -0.28721,-1.205784 -0.43098,-2.850817 -0.43098,-4.9351 V 16.272909 Z m 37.72327,0 13.65137,19.249471 -13.97486,19.223632 h 5.81618 l 11.20139,-15.838826 10.93163,15.838826 h 6.16603 L 198.6163,35.289836 212.45628,16.272909 h -5.84305 l -11.03964,15.63212 -10.79727,-15.63212 z"
style="font-size:54.019px;font-family:Roboto;-inkscape-font-specification:'Roboto, @wght=600';font-variation-settings:'wght' 600;stroke-width:0.270095;fill:#ffffff;fill-opacity:1"
id="path10" />
<path
d="m 18.746659,32.35048 v 35.012333 l 7.483265,0.01602 -0.0078,-15.15153 -0.444417,0.0088 -0.283187,-5.574853 0.724503,-0.09353 -0.0052,-10.30273 c -2.477109,-1.576343 -4.681183,-2.913234 -7.467245,-3.91449 z"
style="font-variation-settings:'wght' 600;fill:#0467a8;stroke-width:0.264583"
id="path4" />
<path
d="m 34.188094,44.204537 -2.362646,1.228349 -3.40186,0.850077 -2.92902,0.378272 0.283187,5.574853 4.819344,-0.09405 3.024105,-1.03973 2.362129,-1.417484 1.512053,-0.756027 z"
style="font-variation-settings:'wght' 600;fill:#0467a8;stroke-width:0.264583"
id="path3" />
<path
d="m 30.789852,3.3827393 c -2.718649,-0.031966 -5.436525,0.014505 -8.153508,0.092501 -1.657421,0.047579 -3.410165,1.1618896 -3.915523,2.4758178 -0.117943,1.3009842 -0.120443,2.6260493 -0.194303,3.9361939 -0.03417,4.6029962 0.05579,9.2082292 0.06976,13.8120772 l 8.031551,2.645316 V 15.482776 c -0.06845,-1.616367 -0.186384,-3.220801 5.17e-4,-4.823995 1.450909,-0.02681 2.901798,-0.0533 4.352706,-0.0801 0.05294,-7.58e-4 0.101815,-0.0019 0.146761,-0.0026 -0.133325,0.0041 -0.29154,0.0097 -0.465088,0.01705 5.402012,0.128802 10.810722,0.09637 16.214514,0.01395 1.312459,0.137599 2.534326,-0.34712 3.780648,-0.6609411 0.688414,-0.375834 1.230544,-1.0271554 1.861385,-1.5115356 0.530757,-0.2588779 0.43123,-0.8718681 0.550871,-1.361674 0.317571,-1.2121917 0.137814,-2.4561815 0.111104,-3.690214 z"
style="font-variation-settings:'wght' 600;fill:#0467a8;stroke-width:0.264583"
id="path2" />
<path
d="m 56.166081,18.073315 c -1.612095,0.517615 -3.326896,0.856005 -4.876705,1.482597 -1.672317,1.636751 -3.569999,3.080027 -4.731494,5.154724 -1.760645,2.382939 -3.026169,5.086524 -4.280876,7.757666 -0.891629,2.073315 -1.768619,4.152921 -2.589506,6.255433 l 4.441073,4.251936 c 1.398551,-3.4772 2.668634,-7.012956 4.53719,-10.275341 0.629987,-1.555517 1.666989,-2.831823 2.828251,-4.022494 1.022671,-1.037894 1.767254,-2.482454 3.326929,-2.735233 0.889424,-0.171791 1.852674,-1.15661 2.651001,-0.326079 1.091115,0.724393 2.380755,1.270451 3.353284,2.101164 0.773793,1.805199 1.727371,3.571064 2.391068,5.400187 -0.10305,3.050467 0.318141,6.150981 -0.478523,9.13536 -0.227898,1.392226 -0.44891,2.787081 -1.327568,3.939294 -0.639724,0.878207 -0.930155,2.134421 -1.788004,2.776575 -1.441269,0.609895 -2.847747,1.462494 -4.310848,1.920296 -1.617481,-0.300784 -3.315903,-0.407844 -4.88394,-0.826823 -2.069996,-1.549653 -4.248341,-2.976127 -5.912301,-4.986259 -2.758844,-2.90603 -5.507188,-5.823363 -8.591207,-8.391735 -3.338252,-2.881492 -6.432985,-6.060987 -10.113077,-8.519377 -1.00535,-0.833342 -2.074808,-1.535604 -3.393075,-1.725476 -2.128037,-0.523545 -4.194319,-1.47308 -6.429582,-1.257805 -2.170664,0.06994 -4.409538,-0.393106 -6.482808,0.438733 -0.9003416,0.331796 -2.1359215,0.232269 -2.4158733,1.361674 -1.9123575,3.173056 -3.6177926,6.486404 -4.6400268,10.062435 -0.4008915,1.586154 -0.4139892,3.222181 -0.038241,4.817794 l 0.1400432,0.924491 c 0.8820904,-2.491562 1.2764827,-5.195371 2.8018961,-7.407299 0.6237014,-1.09468 1.1172001,-2.309336 2.3424927,-2.850472 1.0032429,-0.704794 1.9546502,-1.540401 3.2581987,-1.487765 3.00294,-0.587415 6.099427,-0.06595 9.095052,0.498161 1.4899,0.270585 2.725854,0.959381 4.081922,1.606103 2.823588,1.93021 5.578022,3.981722 8.006229,6.392375 3.658406,4.382924 6.878979,9.116624 10.426754,13.577466 1.153639,1.018099 2.201592,2.226861 3.41943,3.129008 1.866433,0.375292 3.683112,1.179818 5.582605,1.267623 2.379016,-0.109475 4.813761,-0.01813 7.158736,-0.251148 2.193684,-1.301699 4.557492,-2.436561 6.645589,-3.841626 1.382677,-2.657284 2.904182,-5.268723 4.200261,-7.954553 0.355987,-2.855588 0.956499,-5.711351 1.159619,-8.566919 -0.441278,-2.56316 -0.629473,-5.204579 -1.227832,-7.718909 -1.026057,-1.96421 -1.887153,-4.070949 -3.014287,-5.947957 -1.857041,-1.18145 -3.561937,-2.667789 -5.518009,-3.65094 -1.601938,-0.471008 -3.198698,-1.192578 -4.803841,-1.506885 z"
style="fill:url(#linearGradient5);stroke-width:0.264583"
id="path1" />
</svg>

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.
@@ -0,0 +1 @@
{"app_name":"flux","version":"1.3.1","build_number":"47","package_name":"flux"}
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6 -2
View File
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
101B9A4BF8F30D998DDC11D4 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = D4B70082D3146D8C2B7AFA02 /* GoogleService-Info.plist */; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
@@ -67,6 +68,7 @@
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB44F93458B7D70EE383A3A9 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
BDDDA09E437D9C0E7B65B3B1 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
D4B70082D3146D8C2B7AFA02 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -126,6 +128,7 @@
331C8082294A63A400263BE5 /* RunnerTests */,
F5D002C3092D87755D552D32 /* Pods */,
6A991A28CCED9666CA172E00 /* Frameworks */,
D4B70082D3146D8C2B7AFA02 /* GoogleService-Info.plist */,
);
sourceTree = "<group>";
};
@@ -267,6 +270,7 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
101B9A4BF8F30D998DDC11D4 /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -543,7 +547,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
@@ -600,7 +604,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
@@ -1,122 +1 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
{"images":[{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@3x.png","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@1x.png","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@3x.png","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@1x.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@1x.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@1x.png","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@2x.png","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@1x.png","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@1x.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"Icon-App-83.5x83.5@2x.png","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"Icon-App-1024x1024@1x.png","scale":"1x"}],"info":{"version":1,"author":"xcode"}}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 B

After

Width:  |  Height:  |  Size: 839 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 B

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 762 B

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyAllwaoNyqHsZtqfMMo9DxVS6-q7yBwWow</string>
<key>GCM_SENDER_ID</key>
<string>249756116297</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.catellisrl.flux</string>
<key>PROJECT_ID</key>
<string>flux-87e49</string>
<key>STORAGE_BUCKET</key>
<string>flux-87e49.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:249756116297:ios:fe9dadca7150da16cf2698</string>
</dict>
</plist>
+180 -84
View File
@@ -1,9 +1,15 @@
import 'dart:async';
import 'dart:io';
import 'package:equatable/equatable.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/data/core_repository.dart';
import 'package:flux/features/company/models/company_model.dart';
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
import 'package:flux/features/master_data/store/models/store_model.dart';
import 'package:get_it/get_it.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:collection/collection.dart'; // Per firstWhereOrNull
@@ -39,110 +45,187 @@ class SessionCubit extends Cubit<SessionState> {
}
try {
// 1. CHI È QUESTO UTENTE? (Vediamo se ha un profilo staff, che sia Invitato o Admin)
StaffMemberModel? staff = await _repository.getStaffMemberByUserId(
user.id,
);
CompanyModel? company;
if (staff != null) {
// --- LA MAGIA DEL SENSORE ---
if (staff.hasJoined == false) {
// È la primissima volta che entra! Aggiorniamo il DB.
await _repository.updateStaffMember(staff.id!, {'has_joined': true});
// Aggiorniamo anche il nostro modello in memoria per questa sessione
staff = staff.copyWith(hasJoined: true);
// Riportiamo lo stato su initial per far girare lo spinner se stiamo riprovando
emit(state.copyWith(status: SessionStatus.initial, errorMessage: null));
// WRAP DELLA LOGICA IN UN BLOCCO PROTETTO DA TIMEOUT (10 Secondi)
await Future(() async {
StaffMemberModel? staff = await _repository.getStaffMemberByUserId(
user.id,
);
CompanyModel? company;
if (staff != null) {
if (staff.hasJoined == false) {
await _repository.updateStaffMember(staff.id!, {
'has_joined': true,
});
staff = staff.copyWith(hasJoined: true);
}
company = await _repository.getCompanyById(staff.companyId);
} else {
company = await _repository.getCompanyByOwnerId(user.id);
}
company = await _repository.getCompanyById(staff.companyId);
} else {
// È l'Admin in onboarding
company = await _repository.getCompanyByOwnerId(user.id);
}
// 1. Controllo Azienda
if (company == null) {
return emit(
state.copyWith(
status: SessionStatus.onboardingRequired,
user: user,
onboardingStep: OnboardingStep.company,
),
);
} else {
emit(state.copyWith(company: company));
}
if (staff != null) {
// L'utente esiste già nel sistema! Carichiamo l'azienda per cui lavora
company = await _repository.getCompanyById(staff.companyId);
} else {
// L'utente non ha profilo. Probabilmente è l'Admin che ha appena
// fatto Sign Up e sta iniziando l'Onboarding
company = await _repository.getCompanyByOwnerId(user.id);
}
if (company == null) {
return emit(
state.copyWith(
status: SessionStatus.onboardingRequired,
user: user,
onboardingStep: OnboardingStep.company,
),
);
} else {
emit(state.copyWith(company: company));
}
final stores = await _repository.getStoresByCompanyId(company.id!);
if (stores.isEmpty) {
return emit(
state.copyWith(
status: SessionStatus.onboardingRequired,
user: user,
company: company,
onboardingStep: OnboardingStep.store,
),
);
} else {
emit(state.copyWith(currentStore: stores.first));
}
// 2. Controllo Negozi
final stores = await _repository.getStoresByCompanyId(company.id!);
if (stores.isEmpty) {
return emit(
if (staff == null) {
return emit(
state.copyWith(
status: SessionStatus.onboardingRequired,
user: user,
company: company,
onboardingStep: OnboardingStep.staff,
),
);
}
final lastStoreId = _prefs.getString(_lastStoreKey);
final activeStore =
stores.firstWhereOrNull((s) => s.id == lastStoreId) ?? stores.first;
if (lastStoreId != activeStore.id && activeStore.id != null) {
await _prefs.setString(_lastStoreKey, activeStore.id!);
}
setIsSingleUserMode(_prefs.getBool('isSingleUserMode') ?? false);
emit(
state.copyWith(
status: SessionStatus.onboardingRequired,
status: SessionStatus.authenticated,
user: user,
company: company,
onboardingStep: OnboardingStep.store,
currentStore: activeStore,
currentStaffMember: staff,
onboardingStep: OnboardingStep.none,
),
);
} else {
emit(state.copyWith(currentStore: stores.first));
}
// 3. Controllo Staff (Paziente Zero)
if (staff == null) {
return emit(
state.copyWith(
status: SessionStatus.onboardingRequired,
user: user,
company: company,
onboardingStep: OnboardingStep.staff,
),
);
}
// --- TUTTO COMPLETATO: LOGICA DEL NEGOZIO DI DEFAULT ---
// Leggiamo l'ultimo negozio dalle SharedPreferences
final lastStoreId = _prefs.getString(_lastStoreKey);
// Cerchiamo quel negozio nella lista. Se non c'è (magari è stato eliminato), prendiamo il primo.
final activeStore =
stores.firstWhereOrNull((s) => s.id == lastStoreId) ?? stores.first;
// Se non avevamo il lastStoreId salvato, salviamolo ora
if (lastStoreId != activeStore.id && activeStore.id != null) {
await _prefs.setString(_lastStoreKey, activeStore.id!);
}
// 4. BENVENUTO A BORDO
// FCM è fuori dall'await principale, quindi va bene così
_registerFcmToken(companyId: company.id!, staffId: staff.id!);
}).timeout(
const Duration(seconds: 10), // Tempo massimo concesso al server
onTimeout: () {
throw TimeoutException(
'Il server di FLUX non risponde. Controlla la connessione.',
);
},
);
} on TimeoutException catch (e) {
// 🎯 BINGO! IL TIMEOUT È SCATTATO
debugPrint("Timeout Inizializzazione: ${e.message}");
emit(
state.copyWith(
status: SessionStatus.authenticated,
user: user,
company: company,
currentStore: activeStore,
currentStaffMember: staff,
onboardingStep: OnboardingStep.none, // Svuotiamo l'onboarding
),
state.copyWith(status: SessionStatus.error, errorMessage: e.message),
);
} catch (e) {
// Se esplode il database, non lasciamo l'app freezata in 'initial'
// Altri errori generici del DB o di rete
debugPrint("Errore Inizializzazione: $e");
emit(
state.copyWith(
status: SessionStatus
.unauthenticated, // O un nuovo stato SessionStatus.error
status: SessionStatus.error,
errorMessage: "Si è verificato un errore di connessione imprevisto.",
),
);
}
}
Future<void> _registerFcmToken({
required String companyId,
required String staffId,
}) async {
// Scudo anti-crash per lo sviluppo su Linux / Windows
if (!kIsWeb &&
!Platform.isAndroid &&
!Platform.isIOS &&
!Platform.isMacOS) {
return;
}
try {
final messaging = FirebaseMessaging.instance;
// 1. Richiesta permessi di notifica
final settings = await messaging.requestPermission(
alert: true,
badge: true,
sound: true,
);
if (settings.authorizationStatus == AuthorizationStatus.authorized) {
String? fcmToken;
if (kIsWeb) {
fcmToken = await messaging.getToken(
vapidKey:
'BLMUr7crlRghEW6iWtRZ7Y0a74OPAMG9Oh37ewhVP3_5YD9e5RHUeO79sDys6P-7KjOz6I6HiaPqNndmatQlu3g',
);
} else {
fcmToken = await messaging.getToken();
}
if (fcmToken != null) {
final supabase = GetIt.I.get<SupabaseClient>();
// Determiniamo la piattaforma in modo sicuro per Linux
String osPlatform = 'web';
if (!kIsWeb) {
if (Platform.isAndroid) osPlatform = 'android';
if (Platform.isIOS) osPlatform = 'ios';
if (Platform.isMacOS) osPlatform = 'macos';
}
// 3. UPSERT su Supabase condizionato dal vincolo 'fcm_token'
await supabase.from('staff_devices').upsert(
{
'company_id': companyId,
'staff_id': staffId,
'fcm_token': fcmToken,
'os_platform': osPlatform,
'updated_at': DateTime.now().toIso8601String(),
},
onConflict:
'fcm_token', // Se il token esiste già, aggiorna questa riga!
);
debugPrint(
'Dispositivo registrato con successo su FLUX Cloud. Platform: $osPlatform',
);
}
} else {
debugPrint('Permesso push negato dall\'utente.');
}
} catch (e) {
debugPrint('Errore durante la registrazione del dispositivo: $e');
}
}
void updateCurrentCompany(CompanyModel newCompany) {
emit(state.copyWith(company: newCompany));
}
// --- FUNZIONE EXTRA: CAMBIO NEGOZIO DALLA DASHBOARD ---
Future<void> changeStore(StoreModel newStore) async {
if (newStore.id != null) {
@@ -160,4 +243,17 @@ class SessionCubit extends Cubit<SessionState> {
void setIsMobileDevice(bool isMobile) {
emit(state.copyWith(isMobileDevice: isMobile));
}
void setIsSingleUserMode(bool isSingleUser) {
emit(state.copyWith(isSingleUserMode: isSingleUser));
}
void updateCurrentStoreLocally(StoreModel updatedStore) {
// Verifichiamo che l'utente stia effettivamente lavorando nel negozio appena modificato
if (state.currentStore != null &&
state.currentStore!.id == updatedStore.id) {
// Emettiamo il nuovo stato sovrascrivendo solo il negozio corrente
emit(state.copyWith(currentStore: updatedStore));
}
}
}
+11
View File
@@ -6,6 +6,7 @@ enum SessionStatus {
unauthenticated,
onboardingRequired,
authenticated,
error,
}
/// Definisce lo step esatto dell'onboarding (Paranoia Mode)
@@ -25,6 +26,8 @@ class SessionState extends Equatable {
final StaffMemberModel? currentStaffMember;
final OnboardingStep onboardingStep;
final bool isMobileDevice;
final bool isSingleUserMode;
final String? errorMessage;
const SessionState({
this.status = SessionStatus.initial,
@@ -34,6 +37,8 @@ class SessionState extends Equatable {
this.currentStaffMember,
this.onboardingStep = OnboardingStep.none,
this.isMobileDevice = false,
this.isSingleUserMode = false,
this.errorMessage,
});
/// Metodo per creare una copia dello stato modificando solo i campi necessari
@@ -45,6 +50,8 @@ class SessionState extends Equatable {
StaffMemberModel? currentStaffMember,
OnboardingStep? onboardingStep,
bool? isMobileDevice,
bool? isSingleUserMode,
String? errorMessage,
}) {
return SessionState(
status: status ?? this.status,
@@ -54,6 +61,8 @@ class SessionState extends Equatable {
currentStaffMember: currentStaffMember ?? this.currentStaffMember,
onboardingStep: onboardingStep ?? this.onboardingStep,
isMobileDevice: isMobileDevice ?? this.isMobileDevice,
isSingleUserMode: isSingleUserMode ?? this.isSingleUserMode,
errorMessage: errorMessage ?? this.errorMessage,
);
}
@@ -66,6 +75,8 @@ class SessionState extends Equatable {
currentStaffMember,
onboardingStep,
isMobileDevice,
isSingleUserMode,
errorMessage,
];
// Helper rapidi per la UI
-2
View File
@@ -1,2 +0,0 @@
const String resetPasswordUrl =
'https://flux-web-invite.marco-6ba.workers.dev/';
+11 -10
View File
@@ -1,5 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flux/core/blocs/session/session_cubit.dart';
import 'package:flux/core/enums_and_consts/consts.dart';
import 'package:flux/features/company/models/company_model.dart';
import 'package:flux/features/master_data/store/models/store_model.dart';
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
@@ -15,7 +16,7 @@ class CoreRepository {
Future<CompanyModel?> getCompanyByOwnerId(String userId) async {
try {
final response = await _supabase
.from('company')
.from(Tables.companies)
.select()
.eq('user_id', userId) // <-- Assicurati di avere questo campo nel DB!
.maybeSingle();
@@ -31,7 +32,7 @@ class CoreRepository {
Future<CompanyModel?> getCompanyById(String companyId) async {
try {
final response = await _supabase
.from('company')
.from(Tables.companies)
.select()
.eq('id', companyId)
.maybeSingle();
@@ -46,7 +47,7 @@ class CoreRepository {
Future<List<StoreModel>> getStoresByCompanyId(String companyId) async {
try {
final response = await _supabase
.from('store')
.from(Tables.stores)
.select()
.eq('company_id', companyId)
.eq('is_active', true) // Buona pratica
@@ -62,7 +63,7 @@ class CoreRepository {
Future<StaffMemberModel?> getStaffMemberByUserId(String userId) async {
try {
final response = await _supabase
.from('staff_member')
.from(Tables.staffMembers)
.select()
.eq('user_id', userId)
.maybeSingle();
@@ -80,7 +81,7 @@ class CoreRepository {
Future<CompanyModel> createCompany(CompanyModel company) async {
try {
final response = await _supabase
.from('company')
.from(Tables.companies)
.insert(company.toMap())
.select()
.single();
@@ -94,7 +95,7 @@ class CoreRepository {
Future<StoreModel> createStore(StoreModel store) async {
try {
final response = await _supabase
.from('store')
.from(Tables.stores)
.insert(store.toMap())
.select()
.single();
@@ -108,12 +109,12 @@ class CoreRepository {
Future<StaffMemberModel> createStaffMember(StaffMemberModel staff) async {
try {
final response = await _supabase
.from('staff_member')
.from(Tables.staffMembers)
.insert(staff.toMap())
.select()
.single();
final StaffMemberModel staffMember = StaffMemberModel.fromMap(response);
await _supabase.from('staff_in_stores').insert({
await _supabase.from(Tables.staffInStores).insert({
'staff_member_id': staffMember.id,
'store_id': GetIt.I.get<SessionCubit>().state.currentStore!.id,
});
@@ -126,7 +127,7 @@ class CoreRepository {
// Assegna un membro a un negozio
Future<void> assignStaffToStore(String staffId, String storeId) async {
await _supabase.from('staff_in_stores').insert({
await _supabase.from(Tables.staffInStores).insert({
'staff_member_id': staffId,
'store_id': storeId,
});
@@ -136,6 +137,6 @@ class CoreRepository {
String staffId,
Map<String, dynamic> data,
) async {
await _supabase.from('staff_member').update(data).eq('id', staffId);
await _supabase.from(Tables.staffMembers).update(data).eq('id', staffId);
}
}
+31
View File
@@ -0,0 +1,31 @@
class Tables {
static const String appConfig = 'app_config';
static const String attachments = 'attachments';
static const String brands = 'brands';
static const String campaigns = 'campaigns';
static const String companies = 'companies';
static const String customers = 'customers';
static const String documentSequences = 'document_sequences';
static const String models = 'models';
static const String notes = 'notes';
static const String noteCollaborators = 'note_collaborators';
static const String operations = 'operations';
static const String operationDetails = 'operation_details';
static const String providerLocations = 'provider_locations';
static const String providers = 'providers';
static const String providersInStores = 'providers_in_stores';
static const String shippingDocuments = 'shipping_documents';
static const String staffInStores = 'staff_in_stores';
static const String staffMembers = 'staff_members';
static const String stores = 'stores';
static const String targets = 'targets';
static const String individualTargets = 'individual_targets';
static const String tasks = 'tasks';
static const String taskAssignments = 'task_assignments';
static const String taskReminders = 'task_reminders';
static const String tickets = 'tickets';
static const String trackings = 'trackings';
}
const String resetPasswordUrl =
'https://flux-web-invite.marco-6ba.workers.dev/';
File renamed without changes.
+386 -74
View File
@@ -1,97 +1,409 @@
import 'package:flutter/material.dart';
import 'package:flux/core/routes/routes.dart';
import 'package:flux/core/utils/extensions.dart';
import 'package:go_router/go_router.dart';
// ==========================================
// 1. IL GUSCIO (QUELLO CHE PASSI AL ROUTER)
// ==========================================
class AppShell extends StatelessWidget {
final Widget child;
const AppShell({super.key, required this.child});
// Calcoliamo l'indice attivo in base all'URL corrente!
int _calculateSelectedIndex(BuildContext context) {
final String location = GoRouterState.of(context).uri.path;
if (location.startsWith('/master-data')) return 1;
if (location.startsWith('/settings')) return 2;
return 0; // Default: Dashboard
}
void _onItemTapped(int index, BuildContext context) {
switch (index) {
case 0:
context.go('/');
break;
case 1:
context.go('/master-data');
break;
case 2:
context.go('/settings');
break;
}
}
@override
Widget build(BuildContext context) {
final currentIndex = _calculateSelectedIndex(context);
// Breakpoint: se lo schermo è più largo di 600px, usiamo la Rail laterale
final isDesktop = MediaQuery.sizeOf(context).width >= 600;
// Breakpoint a 900px: sotto è Mobile/Tablet (Drawer), sopra è Desktop (Sidebar)
final isDesktop = MediaQuery.sizeOf(context).width >= 900;
final currentPath = GoRouterState.of(context).uri.path;
return Scaffold(
// Su mobile usiamo un'AppBar minimale per avere il bottone "Hamburger" nativo
appBar: isDesktop
? null
: AppBar(
title: const Text(
"FLUX",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
elevation: 0,
backgroundColor: Theme.of(context).colorScheme.surface,
surfaceTintColor: Colors.transparent,
),
drawer: isDesktop
? null
: Drawer(
// Su mobile inietta il menu qui!
child: AppMenu(currentPath: currentPath, isDrawer: true),
),
body: isDesktop
? Row(
children: [
NavigationRail(
selectedIndex: currentIndex,
onDestinationSelected: (index) =>
_onItemTapped(index, context),
labelType: NavigationRailLabelType.all,
destinations: [
NavigationRailDestination(
icon: Icon(Icons.dashboard_outlined),
selectedIcon: Icon(Icons.dashboard),
label: Text(context.l10n.commonDashboard),
),
NavigationRailDestination(
icon: Icon(Icons.folder_special_outlined),
selectedIcon: Icon(Icons.folder_special),
label: Text(context.l10n.commonMasterData),
),
NavigationRailDestination(
icon: Icon(Icons.settings_outlined),
selectedIcon: Icon(Icons.settings),
label: Text(context.l10n.commonSettings),
),
],
),
// Su desktop inietta il menu a sinistra!
AppMenu(currentPath: currentPath, isDrawer: false),
const VerticalDivider(thickness: 1, width: 1),
// Il contenuto della pagina
Expanded(child: child),
],
)
: child, // Su mobile il contenuto prende tutto lo schermo...
// ... e mettiamo la barra in basso!
bottomNavigationBar: isDesktop
? null
: NavigationBar(
selectedIndex: currentIndex,
onDestinationSelected: (index) => _onItemTapped(index, context),
destinations: [
NavigationDestination(
icon: Icon(Icons.dashboard_outlined),
selectedIcon: Icon(Icons.dashboard),
label: context.l10n.commonDashboard,
),
NavigationDestination(
icon: Icon(Icons.folder_special_outlined),
selectedIcon: Icon(Icons.folder_special),
label: context.l10n.commonMasterData,
),
NavigationDestination(
icon: Icon(Icons.settings_outlined),
selectedIcon: Icon(Icons.settings),
label: context.l10n.commonSettings,
),
],
),
: child, // Su mobile il child prende tutto lo schermo sotto l'AppBar
);
}
}
class AppMenu extends StatefulWidget {
final String currentPath; // Lo usiamo ancora per capire cosa accendere
final bool isDrawer;
const AppMenu({super.key, required this.currentPath, required this.isDrawer});
@override
State<AppMenu> createState() => _AppMenuState();
}
class _AppMenuState extends State<AppMenu> {
bool _isCollapsed = false;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final bool effectivelyCollapsed = _isCollapsed && !widget.isDrawer;
return AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
width: effectivelyCollapsed ? 72 : 260,
child: SafeArea(
child: Column(
children: [
// --- HEADER ---
Container(
height: 80,
padding: const EdgeInsets.symmetric(horizontal: 20.0),
alignment: effectivelyCollapsed
? Alignment.center
: Alignment.centerLeft,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.bolt, color: theme.colorScheme.primary, size: 32),
if (!effectivelyCollapsed) ...[
const SizedBox(width: 12),
TextButton(
onPressed: () {
if (widget.isDrawer) Navigator.pop(context);
context.goNamed(Routes.home);
},
child: Text(
"FLUX",
style: theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
),
),
],
],
),
),
// --- VOCI DI MENU ---
Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
physics: const NeverScrollableScrollPhysics(),
child: SizedBox(
width: effectivelyCollapsed ? 72 : 260,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
children: [
_buildRouteItem(
title: 'Dashboard',
icon: Icons.dashboard_outlined,
routeName: Routes.home,
pathToCheck:
'/', // Il path da controllare per colorarlo
isCollapsed: effectivelyCollapsed,
),
const SizedBox(height: 8),
// --- SEZIONE OPERATIVA ---
_buildHierarchicalItem(
title: 'Operatività',
icon: Icons.work_outline,
basePathToCheck: '/',
isCollapsed: effectivelyCollapsed,
subItems: [
_SubMenuItem(
'Operazioni',
Routes.operations,
'/operations',
),
_SubMenuItem(
'Assistenza',
Routes.tickets,
'/tickets',
),
_SubMenuItem('Tasks', Routes.tasks, '/tasks'),
_SubMenuItem('Sticky Notes', Routes.notes, '/notes'),
],
),
const SizedBox(height: 8),
_buildRouteItem(
title: 'Obiettivi',
icon: Icons.track_changes_outlined,
routeName: Routes.targets,
pathToCheck: '/targets',
isCollapsed: effectivelyCollapsed,
),
const SizedBox(height: 8),
// --- IL MENU GERARCHICO (ANAGRAFICHE) ---
_buildHierarchicalItem(
title: context.l10n.commonMasterData,
icon: Icons.folder_special_outlined,
basePathToCheck:
'/master-data', // Se il path inizia così, espandi
isCollapsed: effectivelyCollapsed,
subItems: [
_SubMenuItem(
"Clienti",
Routes.customers,
'/master-data/customers',
),
_SubMenuItem(
"Fornitori",
Routes.providers,
'/master-data/providers',
),
_SubMenuItem(
"Prodotti",
Routes.products,
'/master-data/products',
),
],
),
const SizedBox(height: 8),
_buildRouteItem(
title: context.l10n.commonSettings,
icon: Icons.settings_outlined,
routeName: Routes.settings,
pathToCheck: '/settings',
isCollapsed: effectivelyCollapsed,
),
],
),
),
),
),
// --- PULSANTE TOGGLE (Solo Desktop) ---
if (!widget.isDrawer)
Padding(
padding: const EdgeInsets.all(8.0),
child: IconButton(
tooltip: _isCollapsed ? 'Espandi Menu' : 'Riduci Menu',
icon: Icon(
_isCollapsed
? Icons.keyboard_double_arrow_right
: Icons.keyboard_double_arrow_left,
color: theme.iconTheme.color?.withValues(alpha: 0.5),
),
onPressed: () {
setState(() {
_isCollapsed = !_isCollapsed;
});
},
),
),
],
),
),
);
}
// ==========================================
// WIDGET HELPER AGGIORNATI
// ==========================================
Widget _buildRouteItem({
required String title,
required IconData icon,
required String routeName,
required String pathToCheck,
required bool isCollapsed,
}) {
final isSelected = widget.currentPath == pathToCheck;
final theme = Theme.of(context);
if (isCollapsed) {
return Tooltip(
message: title,
preferBelow: false,
child: InkWell(
onTap: () {
if (widget.isDrawer) Navigator.pop(context);
context.goNamed(routeName); // <--- goNamed!
},
borderRadius: BorderRadius.circular(8),
child: Container(
height: 48,
alignment: Alignment.center,
decoration: BoxDecoration(
color: isSelected
? theme.colorScheme.primaryContainer.withValues(alpha: 0.4)
: Colors.transparent,
borderRadius: BorderRadius.circular(8),
),
child: Icon(
icon,
color: isSelected ? theme.colorScheme.primary : null,
),
),
),
);
}
return ListTile(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
selectedTileColor: theme.colorScheme.primaryContainer.withValues(
alpha: 0.4,
),
selected: isSelected,
leading: Icon(icon, color: isSelected ? theme.colorScheme.primary : null),
title: Text(
title,
style: TextStyle(
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
maxLines: 1,
overflow: TextOverflow.clip,
),
onTap: () {
if (widget.isDrawer) Navigator.pop(context);
context.goNamed(routeName); // <--- goNamed!
},
);
}
Widget _buildHierarchicalItem({
required String title,
required IconData icon,
required String basePathToCheck,
required bool isCollapsed,
required List<_SubMenuItem> subItems,
}) {
final isSelected = subItems.any(
(item) => widget.currentPath.startsWith(item.pathToCheck),
);
final theme = Theme.of(context);
if (isCollapsed) {
return PopupMenuButton<String>(
tooltip: title,
offset: const Offset(60, 0),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
onSelected: (routeName) {
// Il routeName arriva dal value del menu
if (widget.isDrawer) Navigator.pop(context);
context.goNamed(routeName); // <--- goNamed!
},
itemBuilder: (context) => subItems
.map(
(item) => PopupMenuItem(
value: item
.routeName, // Passiamo il nome della rotta (Routes.customers)
child: Text(
item.title,
style: TextStyle(
fontWeight: widget.currentPath == item.pathToCheck
? FontWeight.bold
: FontWeight.normal,
color: widget.currentPath == item.pathToCheck
? theme.colorScheme.primary
: null,
),
),
),
)
.toList(),
child: Container(
height: 48,
alignment: Alignment.center,
decoration: BoxDecoration(
color: isSelected
? theme.colorScheme.primaryContainer.withValues(alpha: 0.4)
: Colors.transparent,
borderRadius: BorderRadius.circular(8),
),
child: Icon(
icon,
color: isSelected ? theme.colorScheme.primary : null,
),
),
);
}
return Theme(
data: theme.copyWith(dividerColor: Colors.transparent),
child: ExpansionTile(
initiallyExpanded: isSelected,
maintainState: true,
tilePadding: const EdgeInsets.symmetric(horizontal: 16),
leading: Icon(
icon,
color: isSelected ? theme.colorScheme.primary : null,
),
title: Text(
title,
style: TextStyle(
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
maxLines: 1,
overflow: TextOverflow.clip,
),
children: subItems.map((item) {
final isSubSelected = widget.currentPath == item.pathToCheck;
return Padding(
padding: const EdgeInsets.only(left: 32.0, bottom: 4.0),
child: ListTile(
dense: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
selectedTileColor: theme.colorScheme.primaryContainer.withValues(
alpha: 0.2,
),
selected: isSubSelected,
title: Text(
item.title,
style: TextStyle(
fontWeight: isSubSelected
? FontWeight.bold
: FontWeight.normal,
color: isSubSelected
? theme.colorScheme.primary
: theme.textTheme.bodyMedium?.color,
),
maxLines: 1,
overflow: TextOverflow.clip,
),
onTap: () {
if (widget.isDrawer) Navigator.pop(context);
context.goNamed(item.routeName); // <--- goNamed!
},
),
);
}).toList(),
),
);
}
}
// Struttura dati per le voci dei sottomenu aggiornata
class _SubMenuItem {
final String title;
final String routeName; // Es: Routes.customers
final String pathToCheck; // Es: '/master-data/customers'
_SubMenuItem(this.title, this.routeName, this.pathToCheck);
}
+530 -89
View File
@@ -4,62 +4,125 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/blocs/session/session_cubit.dart';
import 'package:flux/core/data/core_repository.dart';
import 'package:flux/core/layout/app_shell.dart';
import 'package:flux/core/utils/extensions.dart';
import 'package:flux/core/widgets/set_password_screen.dart';
import 'package:flux/core/routes/routes.dart';
import 'package:flux/core/widgets/image_upload/blocs/image_upload_cubit.dart';
import 'package:flux/core/widgets/image_upload/ui/image_upload_screen.dart';
import 'package:flux/core/widgets/image_upload/ui/upload_success_screen.dart';
import 'package:flux/features/auth/ui/auth_screen.dart';
import 'package:flux/features/customers/blocs/customer_files_bloc.dart';
import 'package:flux/features/customers/blocs/customers_cubit.dart';
import 'package:flux/features/auth/ui/set_password_screen.dart';
import 'package:flux/features/company/bloc/company_settings_cubit.dart';
import 'package:flux/features/company/ui/company_settings_screen.dart';
import 'package:flux/features/customers/blocs/customer_form_cubit.dart';
import 'package:flux/features/customers/blocs/customers_list_cubit.dart';
import 'package:flux/features/customers/models/customer_model.dart';
import 'package:flux/features/customers/ui/customer_detail_screen.dart';
import 'package:flux/features/customers/ui/customer_mobile_upload_screen.dart';
import 'package:flux/features/customers/ui/customers_content.dart';
import 'package:flux/features/customers/ui/customer_form_screen.dart';
import 'package:flux/features/customers/ui/customers_list_screen.dart';
import 'package:flux/features/home/dashboard_note_list/blocs/dashboard_note_list_cubit.dart';
import 'package:flux/features/home/dashboard_store_operation_list/bloc/dashboard_store_operation_list_cubit.dart';
import 'package:flux/features/home/dashboard_store_ticket_list/blocs/dashboard_store_ticket_list_cubit.dart';
import 'package:flux/features/home/dashboard_target_progress/blocs/dashboard_target_progress_cubit.dart';
import 'package:flux/features/home/dashboard_task_list/blocs/dashboard_task_list_cubit.dart';
import 'package:flux/features/home/ui/home_screen.dart';
import 'package:flux/features/master_data/master_data_hub_content.dart';
import 'package:flux/features/master_data/products/blocs/product_cubit.dart';
import 'package:flux/features/master_data/products/ui/products_screen.dart';
import 'package:flux/features/master_data/providers/blocs/provider_cubit.dart';
import 'package:flux/features/master_data/providers/ui/providers_master_data_screen.dart';
import 'package:flux/features/master_data/providers/blocs/provider_form_cubit.dart';
import 'package:flux/features/master_data/providers/blocs/provider_list_cubit.dart';
import 'package:flux/features/master_data/providers/models/provider_model.dart';
import 'package:flux/features/master_data/providers/ui/provider_form_screen.dart';
import 'package:flux/features/master_data/providers/ui/provider_list_screen.dart';
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
import 'package:flux/features/master_data/staff/ui/staff_screen.dart';
import 'package:flux/features/master_data/store/bloc/store_cubit.dart';
import 'package:flux/features/master_data/store/ui/stores_screen.dart';
import 'package:flux/features/notes/models/note_model.dart';
import 'package:flux/features/notes/ui/notes_form_screen.dart';
import 'package:flux/features/notes/ui/notes_list_screen.dart';
import 'package:flux/features/onboarding/blocs/onboarding_cubit.dart';
import 'package:flux/features/onboarding/ui/onboarding_screen.dart';
import 'package:flux/features/operations/blocs/operation_files_bloc.dart';
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
import 'package:flux/features/operations/blocs/operation_details_list_cubit.dart';
import 'package:flux/features/operations/blocs/operation_form_cubit.dart';
import 'package:flux/features/operations/models/operation_model.dart';
import 'package:flux/features/operations/ui/operation_form_screen.dart';
import 'package:flux/features/operations/ui/operation_mobile_upload_screen.dart';
import 'package:flux/features/operations/ui/operations_screen.dart';
import 'package:flux/features/operations/ui/operation_list_screen.dart';
import 'package:flux/features/settings/blocs/reminder_defaults_cubit.dart';
import 'package:flux/features/settings/ui/reminder_settings_screen.dart';
import 'package:flux/features/settings/ui/settings_screen.dart';
import 'package:flux/features/settings/ui/theme_settings_view.dart';
import 'package:flux/features/tasks/blocs/task_form_cubit.dart';
import 'package:flux/features/tasks/blocs/task_list_cubit.dart';
import 'package:flux/features/tasks/models/task_model.dart';
import 'package:flux/features/tasks/ui/task_form_screen.dart';
import 'package:flux/features/tasks/ui/task_list_screen.dart';
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
import 'package:flux/features/tickets/models/ticket_model.dart';
import 'package:flux/features/tickets/ui/ticket_form_screen.dart';
import 'package:flux/features/tickets/ui/ticket_list_screen.dart';
import 'package:flux/features/tickets/ui/ticket_workspace/ticket_workspace_screen.dart';
import 'package:flux/features/targets/blocs/target_form_cubit.dart';
import 'package:flux/features/targets/blocs/target_list_cubit.dart';
import 'package:flux/features/targets/data/targets_repository.dart';
import 'package:flux/features/targets/models/target_model.dart';
import 'package:flux/features/targets/blocs/target_detail_cubit.dart';
import 'package:flux/features/targets/ui/target_detail_screen.dart';
import 'package:flux/features/targets/ui/target_form_screen.dart';
import 'package:flux/features/targets/ui/target_list_screen.dart';
import 'package:flux/features/master_data/staff/data/staff_repository.dart';
import 'package:flux/features/tracking/blocs/tracking_cubit.dart';
import 'package:flux/features/tracking/models/tracking_model.dart';
import 'package:flux/service_locator.dart';
import 'package:get_it/get_it.dart';
import 'package:go_router/go_router.dart';
// Nota: Dovrai creare questi placeholder o file per non avere errori di compilazione
// import 'package:flux/features/master_data/master_data_hub_screen.dart';
// import 'package:flux/features/master_data/staff/ui/staff_screen.dart';
// import 'package:flux/features/master_data/store/ui/stores_screen.dart';
class AppRouter {
// 1. CREIAMO LA CHIAVE GLOBALE DEL NAVIGATORE
static final GlobalKey<NavigatorState> rootNavigatorKey =
GlobalKey<NavigatorState>();
static String? pendingRoute;
static GoRouter createRouter(SessionCubit sessionCubit) {
return GoRouter(
navigatorKey: rootNavigatorKey,
initialLocation: '/',
refreshListenable: GoRouterRefreshStream(sessionCubit.stream),
redirect: (context, state) {
final sessionState = sessionCubit.state;
final isGoingToLogin = state.matchedLocation == '/login';
final isGoingToOnboarding = state.matchedLocation == '/onboarding';
final isGoingToSetPassword = state.matchedLocation == '/set-password';
// 1. LA PASSATOIA VIP (DEVE ESSERE IN CIMA)
// Usiamo state.uri.path perché state.matchedLocation a volte fa i capricci coi deep link iniziali
final isPublicRoute = state.uri.path.startsWith('/upload');
if (isPublicRoute) {
// Ritorna null esplicitamente per dire al router "Rimani qui e non fare altri controlli"
return null;
}
// 2. CONTROLLO INIZIALE
// Se la sessione sta ancora caricando la primissima volta (es. splash screen logico)
if (sessionState.status == SessionStatus.initial) return null;
// 3. UTENTE NON LOGGATO (Ma ci arriva solo se non è su /upload)
if (sessionState.status == SessionStatus.unauthenticated) {
// Se sta già andando alle uniche altre pagine pubbliche, lascialo andare
if (isGoingToLogin || isGoingToSetPassword) return null;
// Altrimenti bloccalo e mandalo al login
return '/login';
}
// 4. UTENTE LOGGATO MA DEVE COMPLETARE L'ONBOARDING
if (sessionState.status == SessionStatus.onboardingRequired) {
return isGoingToOnboarding ? null : '/onboarding';
}
// 5. UTENTE PERFETTAMENTE LOGGATO E OPERATIVO
if (sessionState.status == SessionStatus.authenticated) {
// Se per sbaglio cerca di tornare al login o all'onboarding, ributtalo in dashboard
if (isGoingToLogin || isGoingToOnboarding) return '/';
return null;
}
@@ -70,14 +133,17 @@ class AppRouter {
// --- ROTTE DI SERVIZIO (FUORI DALLA SHELL) ---
GoRoute(
path: '/login',
name: Routes.login,
builder: (context, state) => const AuthScreen(),
),
GoRoute(
path: '/set-password',
name: Routes.setPassword,
builder: (context, state) => const SetPasswordScreen(),
),
GoRoute(
path: '/onboarding',
name: Routes.onboarding,
builder: (context, state) => BlocProvider(
create: (context) => OnboardingCubit(
GetIt.I.get<SessionCubit>(),
@@ -91,146 +157,521 @@ class AppRouter {
ShellRoute(
builder: (context, state, child) => AppShell(child: child),
routes: [
// ==========================================
// 1. DASHBOARD
GoRoute(path: '/', builder: (context, state) => const HomeScreen()),
// ==========================================
GoRoute(
path: '/',
name: Routes.home,
builder: (context, state) {
return MultiBlocProvider(
providers: [
BlocProvider<DashboardStoreOperationListCubit>(
create: (context) => DashboardStoreOperationListCubit(
companyId: sessionCubit.state.company?.id,
storeId: sessionCubit.state.currentStore?.id,
),
),
BlocProvider<DashboardTaskListCubit>(
create: (context) => DashboardTaskListCubit(
companyId: sessionCubit.state.company?.id,
staffId: sessionCubit.state.currentStaffMember?.id,
),
),
BlocProvider<DashboardStoreTicketListCubit>(
create: (context) => DashboardStoreTicketListCubit(
companyId: sessionCubit.state.company?.id,
storeId: sessionCubit.state.currentStore?.id,
),
),
BlocProvider<DashboardNoteListCubit>(
create: (context) => DashboardNoteListCubit(
companyId: sessionCubit.state.company?.id,
staffId: sessionCubit.state.currentStaffMember?.id,
),
),
BlocProvider<DashboardTargetProgressCubit>(
create: (context) => DashboardTargetProgressCubit(
companyId: sessionCubit.state.company?.id,
storeId: sessionCubit.state.currentStore?.id,
staffId: sessionCubit.state.currentStaffMember?.id,
),
),
],
child: const HomeScreen(),
);
},
),
// ==========================================
// 2. HUB ANAGRAFICHE E SOTTO-ROTTE
// ==========================================
GoRoute(
path: '/master-data',
name: Routes.masterData,
builder: (context, state) => const MasterDataHubScreen(),
routes: [
GoRoute(
path: 'products', // Diventa /master-data/products
path:
'customers', // Niente slash iniziale per le sottorotte! -> /master-data/customers
name: Routes.customers,
builder: (context, state) => const CustomersListScreen(),
),
GoRoute(
path: 'providers', // -> /master-data/providers
name: Routes.providers,
builder: (context, state) => const ProviderListScreen(),
),
GoRoute(
path: 'products', // -> /master-data/products
name: Routes.products,
builder: (context, state) {
context.read<ProductsCubit>().refreshCubit();
return const ProductsScreen();
},
),
GoRoute(
path: 'staff', // Diventa /master-data/staff
path: 'staff', // -> /master-data/staff
name: Routes.staff,
builder: (context, state) => const StaffScreen(),
),
GoRoute(
path: 'stores', // Diventa /master-data/stores
builder: (context, state) => const StoresScreen(),
path:
'stores', // Sistemata l'inversione path/name -> /master-data/stores
name: Routes.stores,
builder: (context, state) {
context.read<ProviderListCubit>().loadAllProviders();
context.read<StoreCubit>().loadStores();
return const StoresScreen();
},
),
GoRoute(
path: 'providers', // Diventa /master-data/providers
builder: (context, state) =>
const ProvidersMasterDataScreen(),
path: 'company-settings', // -> /master-data/company-settings
name: Routes.companySettings,
builder: (context, state) => BlocProvider(
create: (context) => CompanySettingsCubit(),
child: const CompanySettingsScreen(),
),
),
],
),
// ==========================================
// 3. IMPOSTAZIONI
// ==========================================
GoRoute(
path: '/settings',
builder: (context, state) => Scaffold(
appBar: AppBar(title: Text(context.l10n.commonSettings)),
body: Center(
child: ElevatedButton.icon(
onPressed: () => context.read<SessionCubit>().signOut(),
icon: const Icon(Icons.logout),
label: const Text("Esci da FLUX"),
),
name: Routes.settings,
builder: (context, state) => const SettingsScreen(),
routes: [
GoRoute(
path: 'themeSettings', // -> /settings/themeSettings
name: Routes.themeSettings,
builder: (context, state) => const ThemeSettingsView(),
),
),
GoRoute(
path: 'reminderSettings',
name: Routes.reminderSettings,
builder: (context, state) =>
BlocProvider<ReminderDefaultsCubit>(
create: (context) => ReminderDefaultsCubit(),
child: const ReminderSettingsScreen(),
),
),
],
),
// ==========================================
// 4. SCHERMATE PRINCIPALI EXTRA NELLA SHELL
// (Accessibili ad es. dalla dashboard, mantengono la sidebar)
// ==========================================
GoRoute(
path: '/operations',
builder: (context, state) => const OperationsScreen(),
name: Routes.operations,
builder: (context, state) => const OperationListScreen(),
),
GoRoute(
path: '/customers',
builder: (context, state) =>
const CustomersContent(), // O come si chiama il tuo widget della lista!
path: '/tickets',
name: Routes.tickets,
builder: (context, state) => const TicketListScreen(),
),
GoRoute(
path: '/notes',
name: Routes.notes,
builder: (context, state) => const NotesListScreen(),
),
GoRoute(
path: '/tasks',
name: Routes.tasks,
builder: (context, state) {
// 1. Recuperiamo lo stato della sessione per le dipendenze
final sessionState = context.read<SessionCubit>().state;
// Sicurezza: Se per qualche motivo non abbiamo l'azienda,
// qui potresti reindirizzare o gestire l'errore
final companyId = sessionState.company?.id;
if (companyId == null) {
return const Scaffold(
body: Center(child: Text("Errore: Azienda non trovata")),
);
}
// 2. Iniettiamo il Cubit con tutto ciò che gli serve
return BlocProvider(
create: (context) => TaskListCubit(
currentCompanyId: companyId,
currentStoreId: sessionState
.currentStore
?.id, // Opzionale: filtra per negozio se l'utente è "dentro" uno store
),
child: const TaskListScreen(),
);
},
),
GoRoute(
path: '/targets',
name: Routes.targets,
builder: (context, state) => BlocProvider(
create: (_) => sl<TargetListCubit>(),
child: const TargetListScreen(),
),
),
],
),
// --- DETTAGLI E OPERATIVITÀ (FUORI DALLA SHELL - TUTTO SCHERMO) ---
GoRoute(
path: '/customer/:id',
path: '/targets/form',
name: Routes.targetForm,
builder: (context, state) {
final existingTarget = state.extra as TargetModel?;
final session = context.read<SessionCubit>().state;
final companyId = session.company?.id ?? '';
final defaultStoreId = session.currentStore?.id ?? '';
return BlocProvider<TargetFormCubit>(
create: (context) => TargetFormCubit(
targetsRepository: sl<TargetsRepository>(),
staffRepository: sl<StaffRepository>(),
staffCubit: context.read<StaffCubit>(),
)..init(
initialTarget: existingTarget,
companyId: companyId,
defaultStoreId: defaultStoreId,
),
child: const TargetFormScreen(),
);
},
),
GoRoute(
path: '/targets/detail',
name: Routes.targetDetail,
builder: (context, state) {
final target = state.extra as TargetModel;
return BlocProvider<TargetDetailCubit>(
create: (context) => TargetDetailCubit(target: target)..init(),
child: TargetDetailScreen(target: target),
);
},
),
GoRoute(
path: '/providers/form',
name: Routes.providerForm,
builder: (context, state) {
// Estraiamo il fornitore (se stiamo modificando e non creando)
final existingProvider = state.extra as ProviderModel?;
return BlocProvider<ProviderFormCubit>(
// Inizializziamo un Cubit NUOVO ogni volta che apriamo il form
create: (context) => ProviderFormCubit(),
child: ProviderFormScreen(existingProvider: existingProvider),
);
},
),
GoRoute(
// Il path sarà es. /tickets/form/123 oppure /tickets/form/new
path: '/tickets/form/:id',
name: Routes.ticketForm,
builder: (context, state) {
// 1. Leggiamo l'ID dall'URL
final String pathId = state.pathParameters['id'] ?? 'new';
// 2. CAST DA NINJA (Aggiungi i punti interrogativi!)
final record =
state.extra
as ({StaffMemberModel? createdBy, TicketModel? ticket})?;
// 3. LOGICA SOBRIA
final String? realTicketId;
if (pathId == 'new') {
realTicketId = null;
} else if (record?.ticket?.id != null) {
// <-- Parentesi TONDE per la condizione, GRAFFE per il blocco!
realTicketId = record!.ticket!.id;
} else {
realTicketId = pathId;
}
if (realTicketId != null) {
context.read<TrackingCubit>().loadTrackings(
realTicketId,
TrackingParentType.ticket,
);
}
context.read<CustomersListCubit>().loadCustomers();
context.read<ProductsCubit>().loadModels();
context.read<ProductsCubit>().loadBrands();
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => AttachmentsBloc(
parentType: AttachmentParentType.ticket,
parentId: realTicketId,
),
),
BlocProvider(
create: (context) => TicketFormCubit(
// Passiamo il creatore e l'eventuale ticket esistente presi dal Record!
createdBy: record?.createdBy,
existingTicket: record?.ticket,
),
),
],
child: TicketFormScreen(
ticketId: realTicketId,
existingTicket: record?.ticket,
),
);
},
),
GoRoute(
path: '/tickets/workspace/:id',
name: Routes.ticketWorkspace,
builder: (context, state) {
// 1. Recuperiamo il Cubit vivo dall'extra
final formCubit = state.extra as TicketFormCubit?;
// 2. Controllo di sicurezza (fondamentale per Flutter Web)
if (formCubit != null) {
return BlocProvider.value(
value: formCubit,
child: const TicketWorkspaceScreen(),
);
} else {
// SCENARIO REFRESH WEB:
// Se l'utente preme F5 del browser mentre è nel banco da lavoro,
// l'extra viene distrutto e diventa null.
// In questo caso, gli diciamo elegantemente che la sessione è persa
// e lo invitiamo a tornare indietro, oppure restituisci direttamente
// un blocco di redirect!
return const Scaffold(
body: Center(
child: Text(
'Sessione di lavoro scaduta. Torna alla lista e riapri il ticket.',
),
),
);
}
},
),
GoRoute(
path: '/upload-success',
name: Routes.uploadSuccess,
builder: (context, state) => const UploadSuccessScreen(),
),
GoRoute(
path: '/customer/details/:id',
name: Routes.customerDetails,
builder: (context, state) {
final customer = state.extra as CustomerModel;
return BlocProvider(
create: (context) => CustomerFilesBloc(customer.id!),
create: (context) => AttachmentsBloc(
parentType: AttachmentParentType.customer,
parentId: customer.id,
),
child: CustomerDetailScreen(customer: customer),
);
},
),
GoRoute(
path: '/customer/:id/upload',
path: '/customer/form/:id',
name: Routes.customerForm,
builder: (context, state) {
final customerId = state.pathParameters['id']!;
final customerName = state.uri.queryParameters['name'] ?? 'Cliente';
return BlocProvider(
create: (context) => CustomerFilesBloc(customerId),
child: CustomerMobileUploadScreen(
customerId: customerId,
customerName: customerName,
),
);
},
),
GoRoute(
path: '/operation-form',
name: 'operation-form',
builder: (context, state) {
final existingOperation = state.extra as OperationModel?;
final operationId = state.uri.queryParameters['operationId'];
final currentStoreId = GetIt.I
.get<SessionCubit>()
.state
.currentStore!
.id!;
context.read<CustomersCubit>().loadCustomers();
context.read<ProvidersCubit>().loadActiveProvidersForStore(
currentStoreId,
);
context.read<ProductsCubit>().loadModels();
context.read<ProductsCubit>().loadBrands();
context.read<StaffCubit>().loadStaffForStore(currentStoreId);
final String pathId = state.pathParameters['id'] ?? 'new';
final String? realCustomerId;
if (pathId == 'new') {
realCustomerId = null;
} else {
realCustomerId = pathId;
}
final customer = state.extra as CustomerModel?;
return BlocProvider(
create: (context) => OperationFilesBloc(
operationId: operationId ?? existingOperation?.id,
create: (context) => CustomerFormCubit(
existingCustomer: customer,
customerId: realCustomerId,
),
child: OperationFormScreen(
operationId: operationId ?? existingOperation?.id,
existingOperation: existingOperation,
child: CustomerFormScreen(
customer: customer,
customerId: realCustomerId,
),
);
},
),
GoRoute(
path: '/operation/:id/upload',
path: '/operations/form/:id',
name: Routes.operationForm,
builder: (context, state) {
final operationId = state.pathParameters['id']!;
final operationName =
state.uri.queryParameters['name'] ?? 'Pratica';
final String pathId = state.pathParameters['id'] ?? 'new';
final record =
state.extra
as ({
StaffMemberModel? createdBy,
OperationModel? operation,
})?;
final String? realOperationId;
if (pathId == 'new') {
realOperationId = null;
} else if (record?.operation?.id != null) {
realOperationId = record!.operation!.id;
} else {
realOperationId = pathId;
}
final currentStoreId = GetIt.I
.get<SessionCubit>()
.state
.currentStore!
.id!;
context.read<CustomersCubit>().loadCustomers();
context.read<ProvidersCubit>().loadActiveProvidersForStore(
currentStoreId,
);
context.read<CustomersListCubit>().loadCustomers();
context.read<ProviderListCubit>().loadProviders(currentStoreId);
context.read<ProductsCubit>().loadModels();
context.read<ProductsCubit>().loadBrands();
context.read<StaffCubit>().loadStaffForStore(currentStoreId);
return BlocProvider(
create: (context) => OperationFilesBloc(operationId: operationId),
child: OperationMobileUploadScreen(
operationId: operationId,
operationName: operationName,
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => AttachmentsBloc(
parentId: realOperationId,
parentType: AttachmentParentType.operation,
),
),
BlocProvider(
create: (context) => OperationFormCubit(
createdBy: record?.createdBy,
existingOperation: record?.operation,
),
),
BlocProvider(
create: (context) => OperationDetailsListCubit(
details: record?.operation?.details ?? [],
),
),
],
child: OperationFormScreen(
operationId: realOperationId,
operation: record?.operation,
),
);
},
),
GoRoute(
path: '/upload/:type/:id',
name: Routes.upload,
builder: (context, state) {
final typeString = state.pathParameters['type']!;
final id = state.pathParameters['id']!;
final companyId = state.uri.queryParameters['companyId']!;
// Trasformiamo la stringa dell'URL nel nostro amato Enum!
final parentType = AttachmentParentType.values.firstWhere(
(e) => e.name == typeString,
orElse: () =>
AttachmentParentType.ticket, // Fallback di sicurezza
);
// Creiamo il BLoC "al volo" solo per questa schermata
return MultiBlocProvider(
providers: [
BlocProvider<AttachmentsBloc>(
create: (context) =>
AttachmentsBloc(parentId: id, parentType: parentType),
),
BlocProvider(create: (context) => ImageUploadCubit()),
],
child: ImageUploadScreen(
title: 'Caricamento Rapido',
companyId: companyId,
),
);
},
),
GoRoute(
path: '/notes/edit/:id',
name: Routes.noteForm,
builder: (context, state) {
final id = state.pathParameters['id']!;
final NoteModel note = state.extra as NoteModel;
// Creiamo il BLoC "al volo" solo per questa schermata
return MultiBlocProvider(
providers: [
BlocProvider<AttachmentsBloc>(
create: (context) => AttachmentsBloc(
parentId: id,
parentType: AttachmentParentType.note,
),
),
],
child: NoteFormScreen(note: note),
);
},
),
GoRoute(
path: '/tasks/form/:id',
name: Routes.taskForm,
builder: (context, state) {
final String pathId = state.pathParameters['id'] ?? 'new';
final TaskModel? task = state.extra as TaskModel?;
final String? realTaskId;
if (pathId == 'new') {
realTaskId = null;
} else if (task?.id != null) {
realTaskId = task!.id;
} else {
realTaskId = pathId;
}
List<StaffMemberModel>? preloadedStaff;
try {
preloadedStaff = context.read<StaffCubit>().state.allStaff;
} catch (_) {
preloadedStaff = null; // Fallback se la rotta è isolata
}
// Creiamo il BLoC "al volo" solo per questa schermata
return MultiBlocProvider(
providers: [
BlocProvider<TaskFormCubit>(
create: (context) => TaskFormCubit(
existingTask: task,
initialTaskId: realTaskId,
allStaff: preloadedStaff,
),
),
],
child: TaskFormScreen(),
);
},
),
],
);
}
+33
View File
@@ -0,0 +1,33 @@
class Routes {
static const String login = 'login';
static const String setPassword = 'set-password';
static const String onboarding = 'onboarding';
static const String home = 'home';
static const String masterData = 'master-data';
static const String products = 'products';
static const String companySettings = 'company-settings';
static const String staff = 'staff';
static const String stores = 'stores';
static const String providers = 'providers';
static const String providerForm = 'provider-form';
static const String settings = 'settings';
static const String themeSettings = 'themeSettings';
static const String operations = 'operations';
static const String customers = 'customers';
static const String tickets = 'tickets';
static const String ticketForm = 'ticket-form';
static const String operationForm = 'operation-form';
static const String uploadSuccess = 'upload-success';
static const String customerForm = 'customer-form';
static const String customerDetails = 'customer-details';
static const String upload = 'upload';
static const String ticketWorkspace = 'ticket-workspace';
static const String noteForm = 'note-form';
static const String notes = 'notes';
static const String tasks = 'tasks';
static const String taskForm = 'task-form';
static const String reminderSettings = 'reminder-settings';
static const String targets = 'targets';
static const String targetForm = 'target-form';
static const String targetDetail = 'target-detail';
}
@@ -0,0 +1,36 @@
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flux/core/routes/app_router.dart';
import 'package:go_router/go_router.dart';
// Chiamala dopo l'autenticazione o nel main()
Future<void> setupInteractedMessage() async {
// CASO A: L'app era completamente CHIUSA e viene aperta tappando la notifica
RemoteMessage? initialMessage = await FirebaseMessaging.instance
.getInitialMessage();
if (initialMessage != null) {
_handleNotificationTap(initialMessage);
}
// CASO B: L'app era in BACKGROUND (minimizzata) e l'utente tappa la notifica
FirebaseMessaging.onMessageOpenedApp.listen(_handleNotificationTap);
}
void _handleNotificationTap(RemoteMessage message) {
final eventType = message.data['eventType'];
final referenceId = message.data['referenceId'];
if (eventType == 'task_assigned' && referenceId != null) {
final routePath = '/tasks/form/$referenceId';
final context = AppRouter.rootNavigatorKey.currentContext;
if (context != null) {
// Scenario A: App già aperta, naviga all'istante
context.push(routePath);
} else {
// Scenario B: App chiusa. Il contesto non c'è ancora, congeliamo la rotta!
debugPrint("App in fase di avvio. Congelo la rotta: $routePath");
AppRouter.pendingRoute = routePath;
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flux/core/enums/enums.dart';
import 'package:flux/core/enums_and_consts/enums.dart';
import 'package:get_it/get_it.dart';
import 'package:shared_preferences/shared_preferences.dart';
+164
View File
@@ -0,0 +1,164 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
class AutoUpdateService {
/// Verifica se la piattaforma corrente supporta l'aggiornamento automatico trasparente
static bool get isAutoUpdateSupported {
if (kIsWeb) return false;
if (Platform.isWindows) return true;
if (Platform.isLinux && Platform.environment['APPIMAGE'] != null) {
return true;
}
return false;
}
/// Scarica l'aggiornamento e lo applica in modo silenzioso
static Future<void> downloadAndApplyUpdate({
required String downloadUrl,
required void Function(double progress, String status) onProgress,
}) async {
if (kIsWeb) {
throw UnsupportedError("L'auto-update non è supportato su Web.");
}
if (Platform.isWindows) {
await _updateWindows(downloadUrl, onProgress);
} else if (Platform.isLinux) {
await _updateLinux(downloadUrl, onProgress);
} else {
throw UnsupportedError("Piattaforma non supportata per l'auto-update.");
}
}
/// Gestione aggiornamento Windows
static Future<void> _updateWindows(
String downloadUrl,
void Function(double progress, String status) onProgress,
) async {
final tempDir = Directory.systemTemp;
final installerFile = File('${tempDir.path}\\FluxInstaller_Update.exe');
if (installerFile.existsSync()) {
try {
installerFile.deleteSync();
} catch (_) {}
}
onProgress(0.0, "Download aggiornamento in corso...");
await _downloadFile(downloadUrl, installerFile, onProgress);
onProgress(1.0, "Installazione e riavvio in corso...");
await Future.delayed(const Duration(milliseconds: 500));
// Lancia l'installer in modalità silenziosa per utente singolo
// /VERYSILENT: nessuna interfaccia
// /SUPPRESSMSGBOXES: nessun popup
// /NORESTART: non riavvia il PC
await Process.start(
installerFile.path,
['/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART'],
mode: ProcessStartMode.detached,
);
// Chiude l'applicazione per consentire la sostituzione dei file
exit(0);
}
/// Gestione aggiornamento Linux (AppImage in-place)
static Future<void> _updateLinux(
String downloadUrl,
void Function(double progress, String status) onProgress,
) async {
final currentAppImagePath = Platform.environment['APPIMAGE'];
if (currentAppImagePath == null) {
throw StateError(
"L'applicazione non è in esecuzione come AppImage.",
);
}
final newAppImageFile = File('$currentAppImagePath.new');
if (newAppImageFile.existsSync()) {
try {
newAppImageFile.deleteSync();
} catch (_) {}
}
onProgress(0.0, "Download nuova versione in corso...");
await _downloadFile(downloadUrl, newAppImageFile, onProgress);
onProgress(1.0, "Finalizzazione e riavvio...");
await Future.delayed(const Duration(milliseconds: 300));
// Assegna il permesso di esecuzione
await Process.run('chmod', ['+x', newAppImageFile.path]);
// Sostituzione atomica del vecchio file AppImage con il nuovo
newAppImageFile.renameSync(currentAppImagePath);
// Rilancia la nuova versione
await Process.start(
currentAppImagePath,
[],
mode: ProcessStartMode.detached,
);
// Termina il processo attuale
exit(0);
}
/// Download in streaming con tracciamento del progresso
static Future<void> _downloadFile(
String url,
File destinationFile,
void Function(double progress, String status) onProgress,
) async {
final client = HttpClient();
client.autoUncompress = true;
try {
final uri = Uri.parse(url);
final request = await client.getUrl(uri);
final response = await request.close();
if (response.statusCode < 200 || response.statusCode >= 300) {
throw HttpException(
'Download fallito con codice di stato ${response.statusCode}',
uri: uri,
);
}
final contentLength = response.contentLength;
int downloadedBytes = 0;
final sink = destinationFile.openWrite();
await for (final chunk in response) {
sink.add(chunk);
downloadedBytes += chunk.length;
if (contentLength > 0) {
final progress = (downloadedBytes / contentLength).clamp(0.0, 1.0);
final percent = (progress * 100).toStringAsFixed(0);
final downloadedMb =
(downloadedBytes / (1024 * 1024)).toStringAsFixed(1);
final totalMb = (contentLength / (1024 * 1024)).toStringAsFixed(1);
onProgress(
progress,
'Scaricamento: $percent% ($downloadedMb MB di $totalMb MB)',
);
} else {
final downloadedMb =
(downloadedBytes / (1024 * 1024)).toStringAsFixed(1);
onProgress(0.5, 'Scaricamento in corso ($downloadedMb MB)...');
}
}
await sink.flush();
await sink.close();
} finally {
client.close();
}
}
}
+18
View File
@@ -0,0 +1,18 @@
import 'dart:async';
import 'package:flutter/material.dart';
class Debouncer {
final int milliseconds;
Timer? _timer;
Debouncer({required this.milliseconds});
void run(VoidCallback action) {
_timer?.cancel();
_timer = Timer(Duration(milliseconds: milliseconds), action);
}
void dispose() {
_timer?.cancel();
}
}
+139
View File
@@ -0,0 +1,139 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
enum UpdateType {
none,
optional,
mandatory,
}
class UpdateInfo {
final UpdateType type;
final String latestVersion;
final String minVersion;
final String downloadUrl;
const UpdateInfo({
required this.type,
required this.latestVersion,
required this.minVersion,
required this.downloadUrl,
});
bool get isMandatory => type == UpdateType.mandatory;
bool get isOptional => type == UpdateType.optional;
bool get hasUpdate => type != UpdateType.none;
}
class VersionCheckService {
Future<UpdateInfo?> checkUpdate() async {
try {
final platformAliases = _getPlatformAliases();
final dbResponse = await Supabase.instance.client
.from('app_config')
.select('platform, min_version, latest_version, download_url');
if (dbResponse.isEmpty) {
return null;
}
final rows = List<Map<String, dynamic>>.from(dbResponse);
final config = rows.firstWhere(
(r) {
final p = (r['platform'] as String?)?.toLowerCase().trim() ?? '';
return platformAliases.any((alias) => alias.toLowerCase() == p);
},
orElse: () => {},
);
if (config.isEmpty) {
return null;
}
final minVersionRaw = (config['min_version'] as String?) ?? '0.0.0';
final latestVersionRaw =
(config['latest_version'] as String?) ?? minVersionRaw;
final downloadUrl = (config['download_url'] as String?) ?? '';
final packageInfo = await PackageInfo.fromPlatform();
final localVersionRaw = packageInfo.version;
final cleanLocal = _cleanVersion(localVersionRaw);
final cleanMin = _cleanVersion(minVersionRaw);
final cleanLatest = _cleanVersion(latestVersionRaw);
// Se la versione locale è inferiore alla minima ammessa -> obbligatorio
if (_isVersionLower(current: cleanLocal, target: cleanMin)) {
return UpdateInfo(
type: UpdateType.mandatory,
latestVersion: latestVersionRaw,
minVersion: minVersionRaw,
downloadUrl: downloadUrl,
);
}
// Se è >= della minima ma inferiore all'ultima disponibile -> facoltativo
if (_isVersionLower(current: cleanLocal, target: cleanLatest)) {
return UpdateInfo(
type: UpdateType.optional,
latestVersion: latestVersionRaw,
minVersion: minVersionRaw,
downloadUrl: downloadUrl,
);
}
return null;
} catch (e) {
debugPrint("Errore durante il check versione: $e");
return null;
}
}
Future<String?> checkForceUpdate() async {
final info = await checkUpdate();
return info?.isMandatory == true ? info?.downloadUrl : null;
}
String _cleanVersion(String raw) {
return raw.split('+').first.replaceAll('v', '').trim();
}
List<String> _getPlatformAliases() {
if (kIsWeb) return const ['web'];
if (Platform.isAndroid) return const ['android'];
if (Platform.isIOS) return const ['ios'];
if (Platform.isWindows) return const ['windows'];
if (Platform.isMacOS) return const ['macos'];
if (Platform.isLinux) return const ['AppImage', 'linux'];
return const ['unknown'];
}
bool _isVersionLower({required String current, required String target}) {
if (current == target) return false;
final currentParts = current
.split('.')
.map((e) => int.tryParse(e) ?? 0)
.toList();
final targetParts = target
.split('.')
.map((e) => int.tryParse(e) ?? 0)
.toList();
final maxLength = currentParts.length > targetParts.length
? currentParts.length
: targetParts.length;
for (int i = 0; i < maxLength; i++) {
final c = i < currentParts.length ? currentParts[i] : 0;
final t = i < targetParts.length ? targetParts[i] : 0;
if (c != t) {
return c < t;
}
}
return false;
}
}
+134
View File
@@ -0,0 +1,134 @@
/// Enum con le festività nazionali italiane
enum ItalianHoliday {
capodanno(day: 1, month: 1, label: 'Capodanno'),
epifania(day: 6, month: 1, label: 'Epifania'),
liberazione(day: 25, month: 4, label: 'Festa della Liberazione'),
lavoro(day: 1, month: 5, label: 'Festa dei Lavoratori'),
repubblica(day: 2, month: 6, label: 'Festa della Repubblica'),
ferragosto(day: 15, month: 8, label: 'Ferragosto'),
ognissanti(day: 1, month: 11, label: 'Tutti i Santi'),
immacolata(day: 8, month: 12, label: 'Immacolata Concezione'),
natale(day: 25, month: 12, label: 'Natale'),
santoStefano(day: 26, month: 12, label: 'Santo Stefano');
final int day;
final int month;
final String label;
const ItalianHoliday({
required this.day,
required this.month,
required this.label,
});
/// Verifica se una determinata data corrisponde alla festività fissa
bool matches(DateTime date) => date.day == day && date.month == month;
}
/// Helper per determinare se un giorno è lavorativo ed effettuare il conteggio dei giorni
class WorkingDaysHelper {
WorkingDaysHelper._();
/// Verifica se la data è domenica o festività nazionale italiana (fissa o Pasquetta)
static bool isWorkingDay(DateTime date) {
// 1. Domenica esclusa
if (date.weekday == DateTime.sunday) {
return false;
}
// 2. Festività fisse
for (final holiday in ItalianHoliday.values) {
if (holiday.matches(date)) {
return false;
}
}
// 3. Pasquetta (Lunedì dell'Angelo)
final easterMonday = calculateEasterMonday(date.year);
if (date.year == easterMonday.year &&
date.month == easterMonday.month &&
date.day == easterMonday.day) {
return false;
}
return true;
}
/// Calcola la data del Lunedì dell'Angelo (Pasquetta) tramite l'algoritmo di Meeus/Jones/Butcher
static DateTime calculateEasterMonday(int year) {
final a = year % 19;
final b = year ~/ 100;
final c = year % 100;
final d = b ~/ 4;
final e = b % 4;
final f = (b + 8) ~/ 25;
final g = (b - f + 1) ~/ 3;
final h = (19 * a + b - d - g + 15) % 30;
final i = c ~/ 4;
final k = c % 4;
final l = (32 + 2 * e + 2 * i - h - k) % 7;
final m = (a + 11 * h + 22 * l) ~/ 451;
final month = (h + l - 7 * m + 114) ~/ 31;
final day = ((h + l - 7 * m + 114) % 31) + 1;
final easterSunday = DateTime(year, month, day);
// Pasquetta è il giorno successivo a Pasqua
return easterSunday.add(const Duration(days: 1));
}
/// Conta i giorni lavorativi compresi tra [start] e [end] (inclusi)
static int countWorkingDays(DateTime start, DateTime end) {
if (start.isAfter(end)) return 0;
int count = 0;
DateTime current = DateTime(start.year, start.month, start.day);
final targetEnd = DateTime(end.year, end.month, end.day);
while (!current.isAfter(targetEnd)) {
if (isWorkingDay(current)) {
count++;
}
current = current.add(const Duration(days: 1));
}
return count;
}
/// Calcola la ripartizione dei giorni lavorativi per un periodo target:
/// - [total]: giorni lavorativi totali del periodo
/// - [elapsed]: giorni lavorativi trascorsi fino ad oggi (minimo 1 se il periodo è iniziato)
/// - [remaining]: giorni lavorativi rimanenti da oggi (incluso oggi se è giorno lavorativo) a fine periodo
static ({int total, int elapsed, int remaining}) calculateWorkingDaysPeriod({
required DateTime start,
required DateTime end,
DateTime? now,
}) {
final today = now ?? DateTime.now();
final cleanToday = DateTime(today.year, today.month, today.day);
final cleanStart = DateTime(start.year, start.month, start.day);
final cleanEnd = DateTime(end.year, end.month, end.day);
final total = countWorkingDays(cleanStart, cleanEnd);
// Se siamo prima dell'inizio del periodo
if (cleanToday.isBefore(cleanStart)) {
return (total: total, elapsed: 0, remaining: total);
}
// Se siamo oltre la fine del periodo
if (cleanToday.isAfter(cleanEnd)) {
return (total: total, elapsed: total, remaining: 0);
}
// Siamo all'interno del periodo
// Giorni trascorsi: dall'inizio fino a oggi
final elapsedDays = countWorkingDays(cleanStart, cleanToday);
final remainingDays = countWorkingDays(cleanToday, cleanEnd);
return (
total: total > 0 ? total : 1,
elapsed: elapsedDays > 0 ? elapsedDays : 1,
remaining: remainingDays > 0 ? remainingDays : 1,
);
}
}
+3
View File
@@ -21,6 +21,7 @@ class FluxTextField extends StatefulWidget {
final TextCapitalization? textCapitalization;
final bool? autocorrect;
final bool? enabled;
final Iterable<String>? autofillHints;
const FluxTextField({
super.key, // Usiamo super.key per Flutter moderno
@@ -41,6 +42,7 @@ class FluxTextField extends StatefulWidget {
this.textCapitalization,
this.autocorrect,
this.enabled = true,
this.autofillHints,
});
@override
@@ -118,6 +120,7 @@ class _FluxTextFieldState extends State<FluxTextField> {
textCapitalization: widget.textCapitalization ?? TextCapitalization.none,
enabled: widget.enabled,
autofillHints: widget.autofillHints,
);
}
}
@@ -0,0 +1,60 @@
import 'package:equatable/equatable.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:image_picker/image_picker.dart';
part 'image_upload_state.dart';
class ImageUploadCubit extends Cubit<ImageUploadState> {
ImageUploadCubit() : super(const ImageUploadState());
void setStatus(ImageUploadStatus status) {
emit(state.copyWith(status: status));
}
void setError(String? message) {
emit(
state.copyWith(status: ImageUploadStatus.failure, errorMessage: message),
);
}
void addFiles(List<PlatformFile> files) {
List<PlatformFile> newFiles = List.from(state.stagedFiles);
newFiles.addAll(files);
emit(
state.copyWith(status: ImageUploadStatus.success, stagedFiles: newFiles),
);
}
void removeFile(PlatformFile file) {
List<PlatformFile> newFiles = List.from(state.stagedFiles);
newFiles.remove(file);
emit(
state.copyWith(status: ImageUploadStatus.success, stagedFiles: newFiles),
);
}
Future<void> addPhoto(XFile photo) async {
final List<PlatformFile> files = List.from(state.stagedFiles);
files.add(PlatformFile(name: photo.name, size: 0));
emit(
state.copyWith(
status: ImageUploadStatus.addingPicture,
stagedFiles: files,
),
);
final List<PlatformFile> newFiles = List.from(files);
newFiles.removeLast();
final PlatformFile loadedFile = PlatformFile(
name: photo.name,
size: await photo.length(),
bytes: await photo.readAsBytes(),
path: photo.path,
);
newFiles.add(loadedFile);
emit(
state.copyWith(status: ImageUploadStatus.success, stagedFiles: newFiles),
);
}
}
@@ -0,0 +1,29 @@
part of 'image_upload_cubit.dart';
enum ImageUploadStatus { initial, addingPicture, uploading, success, failure }
class ImageUploadState extends Equatable {
final ImageUploadStatus status;
final String? errorMessage;
final List<PlatformFile> stagedFiles;
const ImageUploadState({
this.status = ImageUploadStatus.initial,
this.errorMessage,
this.stagedFiles = const [],
});
ImageUploadState copyWith({
ImageUploadStatus? status,
String? errorMessage,
List<PlatformFile>? stagedFiles,
}) {
return ImageUploadState(
status: status ?? this.status,
errorMessage: errorMessage,
stagedFiles: stagedFiles ?? this.stagedFiles,
);
}
@override
List<Object?> get props => [status, errorMessage, stagedFiles];
}
@@ -0,0 +1,306 @@
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/utils/extensions.dart';
import 'package:flux/core/widgets/image_upload/blocs/image_upload_cubit.dart';
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
class ImageUploadScreen extends StatelessWidget {
final String title;
final String companyId;
const ImageUploadScreen({
super.key,
required this.title,
required this.companyId,
});
bool _isImage(String path) {
return ['jpg', 'jpeg', 'png', 'webp'].contains(path.fileExtension());
}
@override
Widget build(BuildContext context) {
return BlocBuilder<ImageUploadCubit, ImageUploadState>(
builder: (context, state) {
return BlocListener<AttachmentsBloc, AttachmentsState>(
listener: (context, attachmentState) {
if (attachmentState.status == AttachmentsStatus.success &&
state.status == ImageUploadStatus.uploading) {
if (Navigator.of(context).canPop()) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("File caricati con successo! ✅"),
),
);
Navigator.of(context).pop();
} else {
context.go('/upload-success');
}
}
if (attachmentState.status == AttachmentsStatus.failure) {
context.read<ImageUploadCubit>().setError(attachmentState.error);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Errore: ${state.errorMessage}")),
);
}
},
child: Scaffold(
appBar: AppBar(
title: Text('Upload: $title'),
automaticallyImplyLeading:
state.status != ImageUploadStatus.uploading,
),
body: Stack(
children: [
Column(
children: [
// --- SEZIONE PULSANTI (Fotocamera / Galleria) ---
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Expanded(
child: ElevatedButton.icon(
onPressed:
state.status == ImageUploadStatus.uploading
? null
: () => _handleCamera(context),
icon: const Icon(Icons.camera_alt),
label: const Text('SCATTA'),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
vertical: 16,
),
),
),
),
Expanded(
child: OutlinedButton.icon(
onPressed:
state.status == ImageUploadStatus.uploading
? null
: () => _handleFilePicker(context),
icon: const Icon(Icons.folder),
label: const Text("GALLERIA"),
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(
vertical: 16,
),
),
),
),
],
),
),
const Divider(),
// --- SEZIONE ANTEPRIME (La GridView Magica) ---
Expanded(
child: state.stagedFiles.isEmpty
? const Center(
child: Text(
"Nessun file selezionato.\nScatta una foto o scegli dalla galleria.",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey),
),
)
: GridView.builder(
padding: const EdgeInsets.all(16),
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:
3, // 3 colonne stile galleria
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
itemCount: state.stagedFiles.length,
itemBuilder: (context, index) {
final file = state.stagedFiles[index];
final isImg = _isImage(file.name);
if (file.bytes == null) {
return Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
color: Colors.grey.shade200,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey.shade300,
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: const Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
),
),
);
}
return Stack(
clipBehavior: Clip.none,
children: [
// L'ANTEPRIMA
Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
color: Colors.grey.shade200,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey.shade300,
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: isImg
? (file.bytes != null
// Se abbiamo i bytes (es. scatto da fotocamera) usiamo quelli (a prova di Web!)
? Image.memory(
file.bytes!,
fit: BoxFit.cover,
)
// Altrimenti andiamo di file fisico
: const Center(
child:
CircularProgressIndicator(
color: Colors.blue,
),
))
: const Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Icon(
Icons.picture_as_pdf,
color: Colors.red,
size: 36,
),
SizedBox(height: 4),
Text(
"PDF",
style: TextStyle(
fontSize: 10,
fontWeight:
FontWeight.bold,
),
),
],
),
),
),
// IL PULSANTE CESTINO (In alto a destra)
Positioned(
top: -8,
right: -8,
child: GestureDetector(
onTap: () => context
.read<ImageUploadCubit>()
.removeFile(file),
child: Container(
padding: const EdgeInsets.all(4),
decoration: const BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
child: const Icon(
Icons.close,
color: Colors.white,
size: 16,
),
),
),
),
],
);
},
),
),
// --- SEZIONE INVIA E CHIUDI ---
SafeArea(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: SizedBox(
width: double.infinity,
height: 56,
child: ElevatedButton.icon(
// Il pulsante si accende SOLO se ci sono file nel carrello
onPressed:
state.stagedFiles.isEmpty ||
state.status == ImageUploadStatus.uploading
? null
: () => _submitAllFiles(context),
icon: const Icon(Icons.cloud_upload),
label: Text(
"INVIA ${state.stagedFiles.length} FILE E CHIUDI",
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(
context,
).colorScheme.primary,
foregroundColor: Theme.of(
context,
).colorScheme.onPrimary,
),
),
),
),
),
],
),
],
),
),
);
},
);
}
// --- LOGICA FOTOCAMERA E LIBRERIA ---
Future<void> _handleCamera(BuildContext context) async {
final ImageUploadCubit imageUploadCubit = context.read<ImageUploadCubit>();
final picker = ImagePicker();
final photo = await picker.pickImage(source: ImageSource.camera);
if (photo != null) {
imageUploadCubit.addPhoto(photo);
}
}
Future<void> _handleFilePicker(BuildContext context) async {
final ImageUploadCubit imageUploadCubit = context.read<ImageUploadCubit>();
final result = await FilePicker.pickFiles(
allowMultiple: true,
withData: true,
);
if (result != null) {
imageUploadCubit.addFiles(result.files);
}
}
// --- LOGICA DI INVIO AL BLoC ---
void _submitAllFiles(BuildContext context) {
final ImageUploadCubit imageUploadCubit = context.read<ImageUploadCubit>();
imageUploadCubit.setStatus(ImageUploadStatus.uploading);
// Lanciamo l'evento del nostro nuovo AttachmentsBloc Agnostico!
context.read<AttachmentsBloc>().add(
UploadAttachmentsEvent(
pickedFiles: imageUploadCubit.state.stagedFiles,
companyId: companyId,
),
);
}
}
@@ -1,32 +1,32 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flux/features/customers/blocs/customer_files_bloc.dart';
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
class CustomerMobileUploadScreen extends StatefulWidget {
final String customerId;
final String customerName;
class OldSharedUploadScreen extends StatefulWidget {
final String title;
final String companyId;
const CustomerMobileUploadScreen({
const OldSharedUploadScreen({
super.key,
required this.customerId,
required this.customerName,
required this.title,
required this.companyId,
});
@override
State<CustomerMobileUploadScreen> createState() =>
_CustomerMobileUploadScreenState();
State<OldSharedUploadScreen> createState() => _OldSharedUploadScreenState();
}
class _CustomerMobileUploadScreenState
extends State<CustomerMobileUploadScreen> {
class _OldSharedUploadScreenState extends State<OldSharedUploadScreen> {
// 1. LA NOSTRA STAGING AREA (Il "Carrello")
final List<PlatformFile> _stagedFiles = [];
// 2. STATO DI CARICAMENTO GLOBALE
bool _isUploading = false;
bool _isProcessingLocal = false;
// Funzione magica per capire se è un'immagine o un PDF dall'estensione
bool _isImage(String path) {
@@ -36,18 +36,25 @@ class _CustomerMobileUploadScreenState
@override
Widget build(BuildContext context) {
return BlocListener<CustomerFilesBloc, CustomerFilesState>(
return BlocListener<AttachmentsBloc, AttachmentsState>(
listener: (context, state) {
// Quando il BLoC ci dice che ha finito l'upload (Success), chiudiamo la pagina!
if (state.status == CustomerFilesStatus.success && _isUploading) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Tutti i file caricati con successo! ✅"),
),
);
Navigator.of(context).pop();
if (state.status == AttachmentsStatus.success && _isUploading) {
// CONTROLLO MAGICO: C'è una pagina dietro di noi?
if (Navigator.of(context).canPop()) {
// Modalità "App Nativa": siamo entrati dal tasto "Aggiungi"
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("File caricati con successo! ✅")),
);
Navigator.of(context).pop();
} else {
// Modalità "Web/QR Code": Navighiamo alla pagina di successo!
// Assicurati di aver importato go_router in questo file
context.go('/upload-success');
}
}
if (state.status == CustomerFilesStatus.failure) {
if (state.status == AttachmentsStatus.failure) {
setState(() => _isUploading = false);
ScaffoldMessenger.of(
context,
@@ -56,8 +63,8 @@ class _CustomerMobileUploadScreenState
},
child: Scaffold(
appBar: AppBar(
title: Text("Upload: ${widget.customerName}"),
// Togliamo la freccia indietro se stiamo caricando per evitare disastri
title: Text("Upload: ${widget.title}"),
// Togliamo la freccia indietro se stiamo caricando per evitare macelli
automaticallyImplyLeading: !_isUploading,
),
body: Stack(
@@ -110,8 +117,7 @@ class _CustomerMobileUploadScreenState
padding: const EdgeInsets.all(16),
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:
3, // 3 colonne come la galleria dell'iPhone
crossAxisCount: 3, // 3 colonne stile galleria
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
@@ -137,10 +143,17 @@ class _CustomerMobileUploadScreenState
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: isImg
? Image.file(
File(file.path!),
fit: BoxFit.cover,
)
? (file.bytes != null
// Se abbiamo i bytes (es. scatto da fotocamera) usiamo quelli (a prova di Web!)
? Image.memory(
file.bytes!,
fit: BoxFit.cover,
)
// Altrimenti andiamo di file fisico
: Image.file(
File(file.path!),
fit: BoxFit.cover,
))
: const Column(
mainAxisAlignment:
MainAxisAlignment.center,
@@ -228,11 +241,11 @@ class _CustomerMobileUploadScreenState
],
),
// --- OVERLAY DI CARICAMENTO (Impedisce tap multipli) ---
if (_isUploading)
// --- OVERLAY DI CARICAMENTO ---
if (_isUploading || _isProcessingLocal)
Container(
color: Colors.black.withValues(alpha: 0.5),
child: const Center(
child: Center(
child: Card(
child: Padding(
padding: EdgeInsets.all(24.0),
@@ -242,7 +255,9 @@ class _CustomerMobileUploadScreenState
CircularProgressIndicator(),
SizedBox(height: 16),
Text(
"Caricamento in corso...",
_isUploading
? "Invio in corso..."
: "Elaborazione foto...",
style: TextStyle(fontWeight: FontWeight.bold),
),
],
@@ -259,30 +274,38 @@ class _CustomerMobileUploadScreenState
// --- LOGICA FOTOCAMERA E LIBRERIA ---
Future<void> _handleCamera() async {
final picker = ImagePicker();
final photo = await picker.pickImage(
source: ImageSource.camera,
imageQuality: 80,
);
if (photo != null) {
final photoBytes = await photo.readAsBytes(); // Sicuro anche per Web!
final photoSize = await photo.length();
setState(() => _isProcessingLocal = true);
await Future.delayed(const Duration(milliseconds: 100));
final platformFile = PlatformFile(
name: photo.name,
size: photoSize,
path: photo.path,
bytes: photoBytes, // I bytes ci salvano la vita su Supabase!
);
setState(() {
_stagedFiles.add(platformFile); // Unifichiamo tutto in un dart:io File
});
try {
final picker = ImagePicker();
final photo = await picker.pickImage(source: ImageSource.camera);
if (photo != null) {
final photoBytes = await photo.readAsBytes();
final photoSize = await photo.length();
final platformFile = PlatformFile(
name: photo.name,
size: photoSize,
path: photo.path,
bytes: photoBytes,
);
setState(() {
_stagedFiles.add(platformFile);
});
}
} finally {
setState(() => _isProcessingLocal = false);
}
}
Future<void> _handleFilePicker() async {
// allowMultiple: true permette di pescare 5 foto dalla galleria in un colpo solo!
final result = await FilePicker.pickFiles(allowMultiple: true);
final result = await FilePicker.pickFiles(
allowMultiple: true,
withData: true,
);
if (result != null) {
setState(() {
_stagedFiles.addAll(result.files);
@@ -294,11 +317,12 @@ class _CustomerMobileUploadScreenState
void _submitAllFiles() {
setState(() => _isUploading = true);
// Diciamo al BLoC di caricare tutti i file.
// Usiamo il tuo evento esistente per ogni file (il BLoC li metterà in coda)
final bloc = context.read<CustomerFilesBloc>();
bloc.add(UploadMultipleCustomerFilesEvent(_stagedFiles));
// N.B: Il Navigator.pop() viene chiamato dal BlocListener in alto quando lo stato diventa "success"!
// Lanciamo l'evento del nostro nuovo AttachmentsBloc Agnostico!
context.read<AttachmentsBloc>().add(
UploadAttachmentsEvent(
pickedFiles: _stagedFiles,
companyId: widget.companyId,
),
);
}
}
@@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
class UploadSuccessScreen extends StatelessWidget {
const UploadSuccessScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.green.shade50,
body: Center(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.green,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.green.withValues(alpha: 0.3),
blurRadius: 20,
spreadRadius: 5,
),
],
),
child: const Icon(Icons.check, size: 80, color: Colors.white),
),
const SizedBox(height: 32),
const Text(
"Upload Completato!",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.green,
),
),
const SizedBox(height: 16),
const Text(
"I file sono stati caricati con successo sulla pratica.\nPuoi chiudere questa pagina o finestra del browser.",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16, color: Colors.black54),
),
],
),
),
),
);
}
}
+106 -63
View File
@@ -1,5 +1,7 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flux/core/utils/extensions.dart';
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
import 'package:qr_flutter/qr_flutter.dart';
class QrUploadDialog extends StatelessWidget {
@@ -17,78 +19,119 @@ class QrUploadDialog extends StatelessWidget {
// Usiamo i colori del tema per renderlo coerente col tuo design
final theme = Theme.of(context);
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
backgroundColor: theme.colorScheme.surface,
title: Column(
children: [
Icon(
Icons.qr_code_scanner,
size: 48,
color: theme.colorScheme.primary,
return BlocConsumer<AttachmentsBloc, AttachmentsState>(
listenWhen: (previous, current) =>
previous.allFiles.length < current.allFiles.length,
listener: (context, state) {
final newCount = state.allFiles.length;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'File caricato con successo via QR Code! 📄 ($newCount allegati in totale)',
),
duration: const Duration(seconds: 2),
backgroundColor: Colors.green.shade700,
),
const SizedBox(height: 16),
Text(
title,
textAlign: TextAlign.center,
style: const TextStyle(fontWeight: FontWeight.bold),
);
},
builder: (context, state) {
final fileCount = state.allFiles.length;
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
],
),
content: SizedBox(
height: 400,
width: 350,
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min, // Fondamentale per i dialog
backgroundColor: theme.colorScheme.surface,
title: Column(
children: [
const Text(
"Inquadra questo codice con la fotocamera del tuo telefono per scattare e caricare i documenti direttamente qui.",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.grey),
),
const SizedBox(height: 24),
// IL CUORE DELLA MAGIA
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors
.white, // Lo sfondo bianco salva la vita sui temi scuri
borderRadius: BorderRadius.circular(16),
),
child: QrImageView(
data: deepLinkUrl,
version: QrVersions.auto,
size: 200.0,
//Opzionale: puoi metterci il logo di FLUX in mezzo!
embeddedImage: const AssetImage('assets/images/logo.png'),
embeddedImageStyle: const QrEmbeddedImageStyle(
size: Size(40, 40),
),
),
Icon(
Icons.qr_code_scanner,
size: 48,
color: theme.colorScheme.primary,
),
const SizedBox(height: 16),
Text(
"In attesa di file...",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: theme.colorScheme.primary,
),
title,
textAlign: TextAlign.center,
style: const TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
const LinearProgressIndicator(), // Per far capire che è "in ascolto"
],
),
),
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(context.l10n.commonClose),
),
],
actionsAlignment: MainAxisAlignment.center,
content: SizedBox(
height: 400,
width: 350,
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min, // Fondamentale per i dialog
children: [
const Text(
"Inquadra questo codice con la fotocamera del tuo telefono per scattare e caricare i documenti direttamente qui.",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.grey),
),
const SizedBox(height: 24),
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors
.white, // Lo sfondo bianco salva la vita sui temi scuri
borderRadius: BorderRadius.circular(16),
),
child: QrImageView(
data: deepLinkUrl,
version: QrVersions.auto,
size: 200.0,
embeddedImage: const AssetImage(
'assets/images/logo.png',
),
embeddedImageStyle: const QrEmbeddedImageStyle(
size: Size(40, 40),
),
),
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
fileCount > 0
? Icons.check_circle_outline
: Icons.hourglass_empty,
size: 18,
color: fileCount > 0
? Colors.green
: theme.colorScheme.primary,
),
const SizedBox(width: 8),
Text(
fileCount > 0
? "$fileCount file ricevuti! (In ascolto...)"
: "In attesa di file...",
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
color: fileCount > 0
? Colors.green
: theme.colorScheme.primary,
),
),
],
),
const SizedBox(height: 8),
const LinearProgressIndicator(), // Per far capire che è "in ascolto"
],
),
),
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(context.l10n.commonClose),
),
],
actionsAlignment: MainAxisAlignment.center,
);
},
);
}
}
-120
View File
@@ -1,120 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flux/core/utils/extensions.dart';
import 'package:flux/core/widgets/flux_text_field.dart';
import 'package:get_it/get_it.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:go_router/go_router.dart';
class SetPasswordScreen extends StatefulWidget {
const SetPasswordScreen({super.key});
@override
State<SetPasswordScreen> createState() => _SetPasswordScreenState();
}
class _SetPasswordScreenState extends State<SetPasswordScreen> {
final _passwordCtrl = TextEditingController();
bool _isLoading = false;
@override
void dispose() {
_passwordCtrl.dispose();
super.dispose();
}
Future<void> _savePassword() async {
final newPassword = _passwordCtrl.text.trim();
if (newPassword.length < 6) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(context.l10n.setPasswordScreenAtLeast6Chars)),
);
return;
}
setState(() => _isLoading = true);
try {
// 1. Aggiorniamo la password dell'utente (che Supabase ha già loggato grazie al link della mail)
await GetIt.I.get<SupabaseClient>().auth.updateUser(
UserAttributes(password: newPassword),
);
// 2. Finito! Lo mandiamo alla home o facciamo ricaricare la sessione al SessionCubit
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(context.l10n.setPasswordScreenPasswordSetWelcome),
),
);
context.go('/'); // Rimandiamo al router principale
}
} on AuthException catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(context.l10n.authError(e.message))),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(context.l10n.commonError(e.toString()))),
);
}
} finally {
if (mounted) setState(() => _isLoading = false);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(context.l10n.setPasswordScreenWelcomeInFlux),
automaticallyImplyLeading:
false, // Non può tornare indietro, deve mettere la password!
),
body: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Icon(Icons.lock_reset, size: 80, color: Colors.blueAccent),
const SizedBox(height: 24),
Text(
context.l10n.setPasswordScreenSetPassword,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
Text(
context.l10n.setPasswordInviteAcceptedChoosePassword,
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey),
),
const SizedBox(height: 32),
FluxTextField(
controller: _passwordCtrl,
label: context.l10n.commonNewPassword,
icon: Icons.lock,
isPassword: true,
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: _isLoading ? null : _savePassword,
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
),
child: _isLoading
? const CircularProgressIndicator(color: Colors.white)
: Text(
context.l10n.setPasswordScreenSaveAndStart,
style: TextStyle(fontSize: 16),
),
),
],
),
),
);
}
}
@@ -4,16 +4,16 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flux/core/blocs/session/session_cubit.dart';
import 'package:flux/core/widgets/qr_upload_dialog.dart';
import 'package:flux/features/attachments/data/attachments_repository.dart';
import 'package:flux/features/attachments/ui/attachment_viewer_screen.dart';
import 'package:flux/features/attachments/ui/quick_rename_dialog.dart';
import 'package:flux/features/operations/blocs/operation_files_bloc.dart';
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
import 'package:get_it/get_it.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flux/features/operations/models/operation_model.dart';
import 'package:flux/features/attachments/models/attachment_model.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:pdf/pdf.dart' as p; // Se ti serve formattazione core
import 'package:pdfx/pdfx.dart' as px; // Isoliamo pdfx
class _ExportItem {
@@ -30,22 +30,50 @@ class _ExportItem {
});
}
class OperationFilesSection extends StatefulWidget {
final OperationModel currentOp;
class SharedAttachmentsSection extends StatefulWidget {
final String? parentId;
final String titleForUpload;
final AttachmentParentType parentType;
final Future<String?> Function()? onEnsureEntitySaved;
const OperationFilesSection({super.key, required this.currentOp});
const SharedAttachmentsSection({
super.key,
this.parentId,
this.titleForUpload = 'Cliente_sconosciuto',
required this.parentType,
this.onEnsureEntitySaved,
});
@override
State<OperationFilesSection> createState() => _OperationFilesSectionState();
State<SharedAttachmentsSection> createState() =>
_SharedAttachmentsSectionState();
}
class _OperationFilesSectionState extends State<OperationFilesSection> {
class _SharedAttachmentsSectionState extends State<SharedAttachmentsSection> {
String? _exportDirectory;
@override
void initState() {
super.initState();
_loadExportDirectory();
_syncParentIdIfNeeded();
}
@override
void didUpdateWidget(covariant SharedAttachmentsSection oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.parentId != oldWidget.parentId) {
_syncParentIdIfNeeded();
}
}
void _syncParentIdIfNeeded() {
if (widget.parentId != null && widget.parentId!.isNotEmpty) {
final attachmentsBloc = context.read<AttachmentsBloc>();
if (attachmentsBloc.state.parentId != widget.parentId) {
attachmentsBloc.add(ParentEntitySavedEvent(widget.parentId!));
}
}
}
// --- GESTIONE CARTELLA CITRIX (SOLO DESKTOP) ---
@@ -59,7 +87,7 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
Future<void> _selectExportDirectory() async {
final String? selectedDirectory = await FilePicker.getDirectoryPath(
dialogTitle: 'Seleziona la cartella di esportazione per TIM/Citrix',
dialogTitle: 'Seleziona la cartella di esportazione',
);
if (selectedDirectory != null) {
@@ -80,6 +108,29 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
// --- SELEZIONE FILE DAL PC/TELEFONO ---
Future<void> _pickFiles() async {
final attachmentsBloc = context.read<AttachmentsBloc>();
String? targetId = attachmentsBloc.state.parentId ?? widget.parentId;
// 🥷 SE L'ID NON C'È (Nuova Operazione), PROVIAMO IL SALVATAGGIO PREVENTIVO
if (targetId == null || targetId.isEmpty) {
if (widget.onEnsureEntitySaved != null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Salvataggio rapido scheda per allegati... ⏳'),
duration: Duration(seconds: 1),
),
);
targetId = await widget.onEnsureEntitySaved!();
}
}
if (targetId != null &&
targetId.isNotEmpty &&
attachmentsBloc.state.parentId != targetId) {
attachmentsBloc.add(ParentEntitySavedEvent(targetId));
}
final result = await FilePicker.pickFiles(
allowMultiple: true,
type: FileType.custom,
@@ -87,31 +138,180 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
withData: true,
);
if (result != null && mounted) {
// MAGIA: Passiamo direttamente la lista di PlatformFile al tuo BLoC!
context.read<OperationFilesBloc>().add(
AddOperationFilesEvent(result.files),
if (result == null || result.files.isEmpty || !mounted) return;
final List<PlatformFile> processedFiles = [];
for (int i = 0; i < result.files.length; i++) {
final file = result.files[i];
Widget previewWidget;
final ext = file.extension?.toLowerCase() ?? '';
if ((ext == 'jpg' || ext == 'jpeg' || ext == 'png') &&
file.bytes != null) {
previewWidget = Image.memory(file.bytes!, fit: BoxFit.contain);
} else if (ext == 'pdf') {
previewWidget = const Center(
child: Icon(Icons.picture_as_pdf, size: 80, color: Colors.red),
);
} else {
previewWidget = const Center(
child: Icon(Icons.insert_drive_file, size: 80, color: Colors.blue),
);
}
final rawOriginalName =
file.name.contains('.')
? file.name.substring(0, file.name.lastIndexOf('.'))
: file.name;
final defaultSuggested =
result.files.length == 1
? widget.titleForUpload
: '${widget.titleForUpload}_${i + 1}';
final finalName = await showDialog<String>(
context: context,
barrierDismissible: false,
builder:
(_) => QuickRenameDialog(
title:
result.files.length == 1
? 'Nome Allegato'
: 'Nome Allegato (${i + 1}/${result.files.length})',
suggestedName:
defaultSuggested.isNotEmpty
? defaultSuggested
: rawOriginalName,
suffixText: ext.isNotEmpty ? '.$ext' : null,
confirmButtonText: 'Importa (Invio)',
previewWidget: previewWidget,
),
);
if (finalName != null && finalName.trim().isNotEmpty) {
final cleanName = finalName.trim();
final extString = ext.isNotEmpty ? '.$ext' : '';
final fullNewName =
cleanName.endsWith(extString) ? cleanName : '$cleanName$extString';
final updatedFile = PlatformFile(
name: fullNewName,
size: file.size,
path: file.path,
bytes: file.bytes,
readStream: file.readStream,
);
processedFiles.add(updatedFile);
} else {
processedFiles.add(file);
}
}
if (processedFiles.isEmpty || !mounted) return;
// 1. Aggiungiamo i file rinominati al BLoC
attachmentsBloc.add(AddAttachmentsEvent(processedFiles));
// 2. Chiediamo se cancellare i file fisici dal computer
if (!kIsWeb) {
final filesOnDisk =
processedFiles
.where((f) => f.path != null && File(f.path!).existsSync())
.toList();
if (filesOnDisk.isNotEmpty && mounted) {
final shouldDelete = await showDialog<bool>(
context: context,
builder:
(dialogContext) => AlertDialog(
title: const Row(
children: [
Icon(Icons.delete_forever, color: Colors.red),
SizedBox(width: 8),
Text('Eliminare file dal computer?'),
],
),
content: Text(
'I file (${filesOnDisk.length}) sono stati importati in Flux.\n\nVuoi cancellare i file originali dal tuo computer per liberare spazio?',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialogContext, false),
child: const Text('No, mantieni sul PC'),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
),
onPressed: () => Navigator.pop(dialogContext, true),
child: const Text('Sì, elimina dal PC'),
),
],
),
);
if (shouldDelete == true) {
int deletedCount = 0;
for (var f in filesOnDisk) {
try {
final fileObj = File(f.path!);
if (fileObj.existsSync()) {
await fileObj.delete();
deletedCount++;
}
} catch (e) {
debugPrint('Errore durante l\'eliminazione del file locale: $e');
}
}
if (mounted && deletedCount > 0) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'$deletedCount file fisici eliminati dal computer.',
),
backgroundColor: Colors.orange.shade800,
),
);
}
}
}
}
}
// --- APERTURA VIEWER ---
void _openFile(AttachmentModel file) {
void _openFile(
AttachmentModel file, {
List<AttachmentModel>? files,
int? initialIndex,
}) {
// 1. Catturiamo il BLoC dalla pagina corrente prima di navigare
final operationFilesBloc = context.read<OperationFilesBloc>();
final operationFilesBloc = context.read<AttachmentsBloc>();
final allFilesList = files ?? operationFilesBloc.state.allFiles;
final index = initialIndex ??
(allFilesList.isNotEmpty ? allFilesList.indexOf(file) : 0);
Navigator.push(
context,
MaterialPageRoute(
builder: (viewerContext) => BlocProvider.value(
value: operationFilesBloc,
child: AttachmentViewerScreen(
attachment: file,
onRename: (newName) {
attachments: allFilesList.isNotEmpty ? allFilesList : [file],
initialIndex: index >= 0 ? index : 0,
onRenameAttachment: (targetFile, newName) {
// Spara l'evento al BLoC e lui farà il resto!
operationFilesBloc.add(RenameOperationFileEvent(file, newName));
operationFilesBloc.add(
RenameAttachmentEvent(targetFile, newName),
);
},
onDelete: () {
operationFilesBloc.add(DeleteSpecificOperationFileEvent(file));
onDeleteAttachment: (targetFile) {
operationFilesBloc.add(
DeleteSpecificAttachmentEvent(targetFile),
);
},
),
),
@@ -145,7 +345,8 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
fileBytes = file.localBytes;
} else if (file.storagePath != null && file.storagePath!.isNotEmpty) {
fileBytes = await repository.downloadAttachmentBytes(
file.storagePath!,
storagePath: file.storagePath!,
bucket: Bucket.documents,
);
}
@@ -184,7 +385,8 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
suggestedName = selectedFiles.first.name;
} else {
// Se sono più file uniti
suggestedName = '${widget.currentOp.customerDisplayName}_Unito';
suggestedName = '${widget.titleForUpload}_Unito';
}
if (!mounted) return;
@@ -274,14 +476,15 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
fileBytes = file.localBytes;
} else if (file.storagePath != null && file.storagePath!.isNotEmpty) {
fileBytes = await repository.downloadAttachmentBytes(
file.storagePath!,
storagePath: file.storagePath!,
bucket: Bucket.documents,
);
}
if (fileBytes == null) continue;
// Recuperiamo il nome che l'utente ha (magari) già impostato
final baseName = file.name ?? 'Documento';
final baseName = file.name;
if (file.extension == 'pdf') {
final document = await px.PdfDocument.openData(fileBytes);
@@ -392,8 +595,7 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
Widget build(BuildContext context) {
final theme = Theme.of(context);
// USIAMO IL TUO BLOC!
return BlocBuilder<OperationFilesBloc, OperationFilesState>(
return BlocBuilder<AttachmentsBloc, AttachmentsState>(
builder: (context, state) {
final allFiles = state.allFiles;
final selectedFiles = state.selectedFiles;
@@ -416,7 +618,7 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
color: theme.colorScheme.primary,
),
title: const Text(
'Cartella Export (Es. Citrix TIM)',
'Cartella Export PDF',
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(
@@ -443,9 +645,92 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
ElevatedButton.icon(
icon: const Icon(Icons.add_photo_alternate),
label: const Text('Aggiungi File'),
onPressed: state.status == OperationFilesStatus.uploading
onPressed: state.status == AttachmentsStatus.uploading
? null
: _pickFiles,
/* : () {
final bloc = context.read<AttachmentsBloc>();
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => BlocProvider.value(
value: bloc,
child: SharedMobileUploadScreen(
title: widget.titleForUpload,
),
),
),
);
}, */
),
const SizedBox(width: 8),
Tooltip(
message: 'Carica foto con lo smartphone',
child: IconButton(
icon: const Icon(Icons.qr_code_scanner),
color: theme.colorScheme.primary, // Sempre colorato!
onPressed: () async {
String? targetId = state.parentId ?? widget.parentId;
// SE L'ID NON C'È, CHIAMIAMO IL SALVATAGGIO IN BACKGROUND!
if (targetId == null || targetId.isEmpty) {
if (widget.onEnsureEntitySaved != null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Salvataggio rapido scheda in corso... ⏳',
),
duration: Duration(seconds: 1),
),
);
targetId = await widget.onEnsureEntitySaved!();
}
}
if (targetId == null || targetId.isEmpty) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Salva la scheda prima di generare il QR Code per gli allegati.',
),
backgroundColor: Colors.orange,
),
);
}
return;
}
if (!context.mounted) return;
final attachmentBloc = context.read<AttachmentsBloc>();
if (attachmentBloc.state.parentId != targetId) {
attachmentBloc.add(ParentEntitySavedEvent(targetId));
}
// GENERAZIONE DEL DEEP LINK AGNOSTICO
final companyId = GetIt.I
.get<SessionCubit>()
.state
.company!
.id!;
final deepLink =
'https://flux.catelli.it/upload/${state.parentType.name}/$targetId?companyId=$companyId';
if (context.mounted) {
showDialog(
context: context,
builder: (_) => BlocProvider.value(
value: attachmentBloc,
child: QrUploadDialog(
deepLinkUrl: deepLink,
title: 'Carica File: ${widget.titleForUpload}',
),
),
);
}
},
),
),
const SizedBox(width: 12),
@@ -464,12 +749,12 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
),
onPressed: () {
if (selectedFiles.length == allFiles.length) {
context.read<OperationFilesBloc>().add(
ClearOperationFileSelectionEvent(),
context.read<AttachmentsBloc>().add(
ClearAttachmentSelectionEvent(),
);
} else {
context.read<OperationFilesBloc>().add(
SelectAllOperationFilesEvent(),
context.read<AttachmentsBloc>().add(
SelectAllAttachmentsEvent(),
);
}
},
@@ -478,15 +763,13 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
const SizedBox(width: 12),
// Loader di upload
if (state.status == OperationFilesStatus.uploading)
if (state.status == AttachmentsStatus.uploading)
const SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(strokeWidth: 2),
),
const Spacer(),
// Azioni visibili SOLO se c'è una selezione!
if (hasSelection) ...[
// Bottone Elimina
@@ -494,21 +777,21 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
icon: const Icon(Icons.delete, color: Colors.red),
tooltip: 'Elimina selezionati',
onPressed: () {
context.read<OperationFilesBloc>().add(
DeleteOperationFilesEvent(),
context.read<AttachmentsBloc>().add(
DeleteAttachmentsEvent(),
);
},
),
// Bottone Associa a Cliente
if (widget.currentOp.customerId != null &&
widget.currentOp.customerId!.isNotEmpty)
if (widget.parentId != null && widget.parentId != '')
IconButton(
icon: const Icon(Icons.person_add, color: Colors.blue),
tooltip: 'Copia nei documenti del Cliente',
onPressed: () {
context.read<OperationFilesBloc>().add(
LinkFilesToCustomerEvent(
customerId: widget.currentOp.customerId!,
context.read<AttachmentsBloc>().add(
LinkAttachmentsToEntityEvent(
targetId: widget.parentId!,
targetType: AttachmentParentType.customer,
),
);
ScaffoldMessenger.of(context).showSnackBar(
@@ -585,6 +868,7 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
borderRadius: BorderRadius.circular(8),
),
child: const Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.upload_file, size: 48, color: Colors.grey),
SizedBox(height: 8),
@@ -619,11 +903,15 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
children: [
// CARD DEL FILE
InkWell(
onTap: () => _openFile(file),
onTap: () => _openFile(
file,
files: allFiles,
initialIndex: index,
),
onLongPress: () {
// Selezione rapida con long press!
context.read<OperationFilesBloc>().add(
ToggleOperationFileSelectionEvent(file),
context.read<AttachmentsBloc>().add(
ToggleAttachmentSelectionEvent(file),
);
},
borderRadius: BorderRadius.circular(8),
@@ -697,8 +985,8 @@ class _OperationFilesSectionState extends State<OperationFilesSection> {
right: 4,
child: InkWell(
onTap: () {
context.read<OperationFilesBloc>().add(
ToggleOperationFileSelectionEvent(file),
context.read<AttachmentsBloc>().add(
ToggleAttachmentSelectionEvent(file),
);
},
child: Container(
@@ -0,0 +1,412 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/routes/routes.dart';
import 'package:flux/features/customers/blocs/customer_form_cubit.dart';
import 'package:flux/features/customers/blocs/customers_list_cubit.dart';
import 'package:flux/features/customers/models/customer_model.dart';
import 'package:flux/features/customers/ui/quick_customer_dialog.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:go_router/go_router.dart';
import 'package:url_launcher/url_launcher.dart';
class SharedCustomerSection extends StatelessWidget {
final CustomerModel? customer;
final ValueChanged<CustomerModel> onCustomerSelected;
const SharedCustomerSection({
super.key,
this.customer,
required this.onCustomerSelected,
});
@override
Widget build(BuildContext context) {
final hasCustomer = customer != null && customer!.id!.isNotEmpty;
final theme = Theme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: Text(
'Cliente',
style: theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
),
),
InkWell(
onTap: () => _showCustomerModal(context), // Passiamo il context!
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
border: Border.all(color: theme.colorScheme.primary),
borderRadius: BorderRadius.circular(8),
color: theme.colorScheme.primaryContainer.withValues(alpha: 0.2),
),
child: Row(
children: [
const Icon(Icons.person),
const SizedBox(width: 12),
Expanded(
child: Text(
hasCustomer ? customer!.name : 'Seleziona Cliente *',
style: TextStyle(
fontWeight: hasCustomer
? FontWeight.bold
: FontWeight.normal,
color: hasCustomer ? null : Colors.grey,
),
),
),
const Icon(Icons.search),
if (hasCustomer) ...[
const SizedBox(width: 12),
IconButton(
onPressed: () async {
final updatedCustomer = await context.pushNamed(
Routes.customerForm,
pathParameters: {'id': customer!.id!},
extra: customer,
);
if (updatedCustomer != null &&
updatedCustomer is CustomerModel) {
onCustomerSelected(updatedCustomer);
}
},
icon: const Icon(Icons.edit),
),
],
],
),
),
),
if (hasCustomer &&
(customer!.phoneNumber.isNotEmpty ||
customer!.email.isNotEmpty)) ...[
const SizedBox(height: 12), // Un po' più di respiro dal box sopra
// Mettiamo i contatti in un Container con un po' di stile per farli sembrare una "Contact Card" integrata
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
color: Colors.grey.withValues(alpha: 0.05), // Sfondo leggerissimo
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.grey.withValues(alpha: 0.2)),
),
child: Column(
children: [
// --- RIGA TELEFONO ---
if (customer!.phoneNumber.isNotEmpty)
Row(
children: [
// Usiamo i pulsanti "Small" per non occupare troppo spazio verticale
IconButton(
visualDensity: VisualDensity.compact,
onPressed: () => launchUrl(
Uri.parse('https://wa.me/39${customer!.phoneNumber}'),
),
icon: const FaIcon(
FontAwesomeIcons.whatsapp,
color: Colors.green,
size: 20,
),
tooltip: 'Invia WhatsApp',
),
const SizedBox(width: 8),
Expanded(
// Expanded evita l'overflow se il numero è assurdamente lungo
child: SelectableText(
customer!.phoneNumber,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
IconButton(
visualDensity: VisualDensity.compact,
onPressed: () {
Clipboard.setData(
ClipboardData(text: customer!.phoneNumber),
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Telefono copiato!'),
duration: Duration(seconds: 2),
),
);
},
icon: const Icon(
Icons.copy,
size: 18,
color: Colors.grey,
),
tooltip: 'Copia',
),
],
),
// Sezione divisoria se ci sono entrambi
if (customer!.phoneNumber.isNotEmpty &&
customer!.email.isNotEmpty)
const Divider(height: 8, thickness: 0.5),
// --- RIGA EMAIL ---
if (customer!.email.isNotEmpty)
Row(
children: [
IconButton(
visualDensity: VisualDensity.compact,
onPressed: () => launchUrl(
Uri.parse('mailto:${customer!.email}'),
), // Rimosso il // dopo mailto:, è più sicuro
icon: const FaIcon(
FontAwesomeIcons.envelope,
color: Colors.blue,
size: 20,
),
tooltip: 'Invia Email',
),
const SizedBox(width: 8),
Expanded(
// L'Expanded è vitale per le email che possono essere lunghissime
child: SelectableText(
customer!.email,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
IconButton(
visualDensity: VisualDensity.compact,
onPressed: () {
Clipboard.setData(
ClipboardData(text: customer!.email),
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Email copiata!'),
duration: Duration(seconds: 2),
),
);
},
icon: const Icon(
Icons.copy,
size: 18,
color: Colors.grey,
),
tooltip: 'Copia',
),
],
),
// --- RIGA CODICE FISCALE ---
if (customer!.fiscalCode != null &&
customer!.fiscalCode!.isNotEmpty) ...[
const Divider(height: 8, thickness: 0.5),
Row(
children: [
IconButton(
visualDensity: VisualDensity.compact,
onPressed:
null, // Rimosso il // dopo mailto:, è più sicuro
icon: const Icon(
Icons.person_outline,
color: Colors.green,
size: 20,
),
tooltip: 'Codice Fiscale',
),
const SizedBox(width: 8),
Expanded(
// L'Expanded è vitale per le email che possono essere lunghissime
child: SelectableText(
customer!.fiscalCode!,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
IconButton(
visualDensity: VisualDensity.compact,
onPressed: () {
Clipboard.setData(
ClipboardData(text: customer!.fiscalCode!),
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Codice Fiscale copiato!'),
duration: Duration(seconds: 2),
),
);
},
icon: const Icon(
Icons.copy,
size: 18,
color: Colors.grey,
),
tooltip: 'Copia',
),
],
),
],
],
),
),
],
],
);
}
// --- MODALE SELEZIONE CLIENTE ---
void _showCustomerModal(BuildContext context) {
String currentSearchQuery = '';
showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (modalContext) {
return DraggableScrollableSheet(
initialChildSize: 0.8,
minChildSize: 0.5,
maxChildSize: 0.95,
expand: false,
builder: (_, scrollController) {
return Column(
children: [
// Header
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Seleziona Cliente',
style: Theme.of(context).textTheme.titleLarge,
),
IconButton(
icon: const Icon(Icons.close),
onPressed: () => Navigator.pop(modalContext),
),
],
),
),
// Barra di Ricerca
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: TextField(
autofocus: true,
decoration: InputDecoration(
hintText: 'Cerca per nome, telefono o email...',
prefixIcon: const Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
onChanged: (query) {
currentSearchQuery = query;
context.read<CustomersListCubit>().searchCustomers(query);
},
),
),
// Pulsante Nuovo Cliente
Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(48),
),
icon: const Icon(Icons.person_add),
label: const Text('Crea Nuovo Cliente'),
onPressed: () async {
// APRIAMO LA DIALOG RAPIDA CON LA MAGIA DEL BLOC PROVIDER
final newCustomer = await showDialog(
context: context,
builder: (dialogContext) {
return BlocProvider.value(
value: context.read<CustomersListCubit>(),
child: BlocProvider<CustomerFormCubit>(
create: (context) => CustomerFormCubit(),
child: QuickCustomerDialog(
initialQuery:
currentSearchQuery, // <-- Passiamo quello che ha digitato!
),
),
);
},
);
// Se l'ha creato davvero (e non ha premuto annulla)...
if (newCustomer != null) {
// 1. Aggiorniamo il form delle operazioni
onCustomerSelected(newCustomer);
// 2. Chiudiamo la BottomSheet dei clienti per tornare alla form!
if (context.mounted) {
Navigator.pop(modalContext);
}
}
},
),
),
const Divider(),
// Lista Clienti dal Bloc
Expanded(
child: BlocBuilder<CustomersListCubit, CustomersListState>(
builder: (context, state) {
if (state.status == CustomersListStatus.loading) {
return const Center(child: CircularProgressIndicator());
}
if (state.customers.isEmpty) {
return const Center(
child: Text(
'Nessun cliente trovato.',
style: TextStyle(color: Colors.grey),
),
);
}
return ListView.builder(
controller: scrollController,
itemCount: state.customers.length,
itemBuilder: (context, index) {
final customer = state.customers[index];
return ListTile(
leading: CircleAvatar(
child: Text(
customer.name.substring(0, 1).toUpperCase(),
),
),
title: Text(
customer.name,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
'${customer.phoneNumber} • ${customer.email}',
),
onTap: () {
onCustomerSelected(customer);
Navigator.pop(modalContext);
},
);
},
);
},
),
),
],
);
},
);
},
);
}
}
@@ -0,0 +1,172 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/features/master_data/products/blocs/product_cubit.dart';
import 'package:flux/features/master_data/products/ui/quick_product_dialog.dart';
class SharedModelSection extends StatelessWidget {
final String? modelId;
final String? modelName;
final String label;
final Color? backgroundColor;
final Color? borderColor;
// Usiamo una callback che passa direttamente ID e Nome
// così non dobbiamo preoccuparci di importare la classe esatta del modello ovunque
final void Function(String id, String name) onModelSelected;
const SharedModelSection({
super.key,
required this.modelId,
required this.modelName,
required this.onModelSelected,
this.label = 'Seleziona Modello',
this.backgroundColor,
this.borderColor,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final hasModel = modelId != null && modelId!.isNotEmpty;
return ListTile(
tileColor: backgroundColor,
title: Text(label),
subtitle: Text(
hasModel ? modelName! : 'Nessun modello selezionato',
style: TextStyle(
color: hasModel ? null : Colors.grey,
fontWeight: hasModel ? FontWeight.bold : FontWeight.normal,
),
),
trailing: const Icon(Icons.arrow_drop_down),
shape: RoundedRectangleBorder(
side: BorderSide(color: borderColor ?? theme.dividerColor),
borderRadius: BorderRadius.circular(8),
),
onTap: () => _showModelModal(context),
);
}
void _showModelModal(BuildContext context) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (modalContext) {
return DraggableScrollableSheet(
initialChildSize: 0.6,
minChildSize: 0.4,
maxChildSize: 0.9,
expand: false,
builder: (_, scrollController) {
return Column(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Seleziona Modello',
style: Theme.of(context).textTheme.titleLarge,
),
IconButton(
icon: const Icon(Icons.close),
onPressed: () => Navigator.pop(modalContext),
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: TextField(
autofocus: true,
textInputAction: TextInputAction.search,
decoration: InputDecoration(
hintText: 'Cerca modello (es. iPhone 15...)',
prefixIcon: const Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
onChanged: (query) =>
context.read<ProductsCubit>().searchModels(query),
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(48),
),
icon: const Icon(Icons.add),
label: const Text('Aggiungi Modello al Volo'),
onPressed: () async {
// Leggiamo i brand dal Cubit per passarli alla dialog
final existingBrands = context
.read<ProductsCubit>()
.state
.brands;
final newModel = await showDialog(
context: context,
builder: (dialogContext) {
return BlocProvider.value(
value: context.read<ProductsCubit>(),
child: QuickProductDialog(
existingBrands: existingBrands,
),
);
},
);
if (newModel != null) {
// CHIAMIAMO LA CALLBACK!
onModelSelected(newModel.id, newModel.nameWithBrand);
if (context.mounted) Navigator.pop(modalContext);
}
},
),
),
const Divider(),
Expanded(
child: BlocBuilder<ProductsCubit, ProductState>(
builder: (context, state) {
return ListView.builder(
controller: scrollController,
itemCount: state.models.length,
itemBuilder: (context, index) {
final deviceModel = state.models[index];
return ListTile(
leading: const Icon(Icons.devices),
title: Text(
deviceModel.nameWithBrand,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
onTap: () {
// CHIAMIAMO LA CALLBACK!
onModelSelected(
deviceModel.id!,
deviceModel.nameWithBrand,
);
Navigator.pop(modalContext);
},
);
},
);
},
),
),
],
);
},
);
},
);
}
}
@@ -0,0 +1,251 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/blocs/session/session_cubit.dart';
import 'package:flux/core/widgets/image_upload/blocs/image_upload_cubit.dart';
import 'package:flux/core/widgets/image_upload/ui/image_upload_screen.dart';
import 'package:flux/core/widgets/qr_upload_dialog.dart';
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
import 'package:get_it/get_it.dart';
class SharedFilesSection extends StatelessWidget {
final String titleNameForUpload;
// LA NOSTRA CALLBACK MAGICA
final Future<String?> Function()? onGenerateIdForQr;
const SharedFilesSection({
super.key,
required this.titleNameForUpload,
this.onGenerateIdForQr,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Allegati e Foto',
style: TextStyle(fontWeight: FontWeight.bold),
),
BlocBuilder<AttachmentsBloc, AttachmentsState>(
builder: (context, state) {
return Row(
children: [
// --- IL TASTO QR CODE (Ora sempre attivo!) ---
Tooltip(
message: 'Carica foto con lo smartphone',
child: IconButton(
icon: const Icon(Icons.qr_code_scanner),
color: theme.colorScheme.primary, // Sempre colorato!
onPressed: () async {
String? targetId = state.parentId;
// SE L'ID NON C'È, CHIAMIAMO IL SALVATAGGIO IN BACKGROUND!
if (targetId == null) {
if (onGenerateIdForQr != null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Salvataggio rapido scheda in corso... ⏳',
),
duration: Duration(seconds: 1),
),
);
// Aspettiamo che il TicketFormCubit faccia il suo lavoro
targetId = await onGenerateIdForQr!();
}
// Se fallisce (es. validazione form non passata), ci fermiamo
if (targetId == null) return;
}
// GENERAZIONE DEL DEEP LINK AGNOSTICO
final companyId = GetIt.I
.get<SessionCubit>()
.state
.company!
.id!;
final deepLink =
'https://flux.catelli.it/upload/${state.parentType.name}/$targetId?companyId=$companyId';
if (context.mounted) {
final attachmentBloc =
context.read<AttachmentsBloc>();
showDialog(
context: context,
builder: (_) => BlocProvider.value(
value: attachmentBloc,
child: QrUploadDialog(
deepLinkUrl: deepLink,
title: 'Carica File: $titleNameForUpload',
),
),
);
}
},
),
),
const SizedBox(width: 8),
// --- IL TASTO AGGIUNGI CLASSICO (da PC) ---
TextButton.icon(
icon: const Icon(Icons.add_a_photo),
label: const Text('Aggiungi'),
onPressed: () {
final bloc = context.read<AttachmentsBloc>();
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => BlocProvider.value(
value: bloc,
child: BlocProvider<ImageUploadCubit>(
create: (context) => ImageUploadCubit(),
child: ImageUploadScreen(
title: titleNameForUpload,
companyId: GetIt.I
.get<SessionCubit>()
.state
.company!
.id!,
),
),
),
),
);
},
),
],
);
},
),
],
),
const SizedBox(height: 8),
// --- LA VETRINA DEI FILE (Identica a prima) ---
BlocBuilder<AttachmentsBloc, AttachmentsState>(
builder: (context, state) {
final files = state.allFiles;
if (state.status == AttachmentsStatus.loading) {
return const Center(child: CircularProgressIndicator());
}
if (files.isEmpty) {
return Container(
width: double.infinity,
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: theme.colorScheme.surface,
border: Border.all(
color: theme.dividerColor,
style: BorderStyle.solid,
),
borderRadius: BorderRadius.circular(12),
),
child: const Column(
children: [
Icon(
Icons.image_not_supported_outlined,
color: Colors.grey,
size: 32,
),
SizedBox(height: 8),
Text(
'Nessun file allegato',
style: TextStyle(color: Colors.grey),
),
],
),
);
}
return Wrap(
spacing: 12,
runSpacing: 12,
children: files.map((file) {
final isImage = [
'jpg',
'jpeg',
'png',
'webp',
].contains(file.extension.toLowerCase());
return Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: theme.dividerColor),
),
child: Stack(
children: [
Center(
child: isImage
? const Icon(
Icons.image,
color: Colors.blue,
size: 40,
)
: const Icon(
Icons.picture_as_pdf,
color: Colors.red,
size: 40,
),
),
if (file.id == null)
Positioned(
bottom: 4,
left: 4,
right: 4,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 2),
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(4),
),
child: const Text(
'Da salvare',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 8,
fontWeight: FontWeight.bold,
),
),
),
),
Positioned(
top: -8,
right: -8,
child: IconButton(
icon: const Icon(
Icons.cancel,
color: Colors.redAccent,
size: 20,
),
onPressed: () {
context.read<AttachmentsBloc>().add(
DeleteSpecificAttachmentEvent(file),
);
},
),
),
],
),
);
}).toList(),
);
},
),
],
);
}
}
@@ -2,23 +2,29 @@ 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/master_data/staff/blocs/staff_cubit.dart';
import 'package:flux/features/operations/blocs/operations_cubit.dart';
import 'package:flux/features/operations/models/operation_model.dart';
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
import 'package:get_it/get_it.dart';
// IMPORTA IL TUO CUBIT DELLO STAFF
// import 'package:flux/features/staff/blocs/staff_cubit.dart';
class StaffSection extends StatelessWidget {
final OperationModel? currentOp;
final String? label;
final String? staffId;
final String? staffName;
final ValueChanged<StaffMemberModel> onStaffSelected;
const StaffSection({super.key, required this.currentOp});
const StaffSection({
super.key,
required this.onStaffSelected,
this.label,
this.staffId,
this.staffName,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
// Se staffId è nullo, proviamo a preselezionare l'utente loggato
final selectedStaffId =
currentOp?.staffId ??
GetIt.I.get<SessionCubit>().state.currentStaffMember?.id;
staffId ?? GetIt.I.get<SessionCubit>().state.currentStaffMember?.id;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -26,7 +32,8 @@ class StaffSection extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: Text(
'Operatore',
label ??
'Operatore', // <-- FIX: Ora usa l'etichetta passata dal form!
style: theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
@@ -34,8 +41,28 @@ class StaffSection extends StatelessWidget {
),
BlocBuilder<StaffCubit, StaffState>(
builder: (context, state) {
// Dati finti per farti vedere la UI, piallali quando attacchi il BlocBuilder!
// FIX: Aggiunto un controllo se sta caricando
if (state.status == StaffStatus.loading) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(strokeWidth: 2),
),
);
}
final staffMembers = state.storeStaff;
// FIX: Feedback visivo se la lista è vuota
if (staffMembers.isEmpty) {
return const Text(
'Nessun operatore caricato. Controlla il Cubit!',
style: TextStyle(color: Colors.red),
);
}
final currentLoggedStaffMember = GetIt.I
.get<SessionCubit>()
.state
@@ -49,11 +76,7 @@ class StaffSection extends StatelessWidget {
return GestureDetector(
onTap: () {
// Aggiorniamo la form con un solo tap!
context.read<OperationsCubit>().updateOperationFields(
staffId: staff.id,
staffDisplayName: staff.name,
);
onStaffSelected(staff);
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
+147
View File
@@ -0,0 +1,147 @@
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/master_data/staff/blocs/staff_cubit.dart';
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
// import 'package:flutter_bloc/flutter_bloc.dart';
// Importa il tuo StaffModel
/// Funzione helper globale per lanciare la modale ovunque ti trovi con 1 riga di codice
Future<dynamic> showStaffSelectorModal(BuildContext context) async {
return showModalBottomSheet(
context: context,
isScrollControlled:
true, // Permette alla modale di essere più alta se serve
backgroundColor: Colors.transparent,
builder: (context) => const StaffSelectorModal(),
);
}
class StaffSelectorModal extends StatelessWidget {
const StaffSelectorModal({super.key});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
),
padding: const EdgeInsets.all(24),
child: SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min, // Occupa solo lo spazio necessario
children: [
// --- Maniglietta superiore (UX standard dei BottomSheet) ---
Container(
width: 40,
height: 4,
margin: const EdgeInsets.only(bottom: 24),
decoration: BoxDecoration(
color: theme.dividerColor,
borderRadius: BorderRadius.circular(2),
),
),
// --- Titolo ---
const Text(
'Chi sei?',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
Text(
'Seleziona il tuo profilo per continuare',
style: TextStyle(color: Colors.grey.shade600),
),
const SizedBox(height: 32),
BlocBuilder<StaffCubit, StaffState>(
builder: (context, state) {
if (state.status == StaffStatus.loading) {
return const CircularProgressIndicator();
}
final staffList = state.storeStaff;
return _buildStaffGrid(context, staffList);
},
),
const SizedBox(height: 16),
// --- Tasto Annulla ---
TextButton(
onPressed: () => Navigator.of(context).pop(), // Restituisce null
child: const Text('Annulla'),
),
],
),
),
);
}
Widget _buildStaffGrid(
BuildContext context,
List<StaffMemberModel> staffList,
) {
return Wrap(
spacing: 16,
runSpacing: 16,
alignment: WrapAlignment.center,
children: staffList.map((staff) {
return InkWell(
borderRadius: BorderRadius.circular(16),
onTap: () {
// Quando l'utente tappa il suo nome, la modale si chiude
// e restituisce il modello (o l'ID) alla schermata precedente!
Navigator.of(context).pop(staff);
},
child: Container(
width: 100, // Pulsanti larghi e comodi
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.surfaceContainerHighest.withValues(alpha: 0.3),
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Theme.of(context).dividerColor),
),
child: Column(
children: [
CircleAvatar(
radius: 30,
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Theme.of(context).colorScheme.onPrimary,
child: Text(
staff.name.substring(0, 1).toUpperCase(),
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 12),
Text(
staff.name,
style: const TextStyle(fontWeight: FontWeight.bold),
overflow: TextOverflow.ellipsis,
),
],
),
),
);
}).toList(),
);
}
}
Future<StaffMemberModel?> getStaffMember(BuildContext context) async {
final sessionState = context.read<SessionCubit>().state;
if (sessionState.isSingleUserMode) {
// Dispositivo personale: non rompiamo le palle. Usiamo l'utente loggato.
return sessionState.currentStaffMember;
} else {
// Dispositivo Condiviso (Kiosk Mode): Chiediamo chi è!
return await showStaffSelectorModal(context);
}
}
Loaded 100 of 329 files, more files were not shown because too many files have changed in this diff. Show more