Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab64bf0621 | ||
|
|
dcb19cf839 | ||
|
|
bc9e0769cd | ||
|
|
7dd8a3ac71 | ||
|
|
70db03066b | ||
|
|
addb06a61a | ||
|
|
5e505d96b3 | ||
|
|
66c7094ada | ||
|
|
bd496ad37f | ||
|
|
771f1f921b | ||
|
|
2c02dfcf8b | ||
|
|
89e5d4014d | ||
|
|
8e396a7885 | ||
|
|
9b7b4beaa8 | ||
|
|
531b3ba3f2 | ||
|
|
d0036b729d | ||
|
|
4d791d2213 | ||
|
|
19fc90b830 | ||
|
|
4f0fe7bab5 | ||
|
|
7323f68e62 | ||
|
|
a33b08a0c3 | ||
|
|
c8fdd29cf4 | ||
|
|
00615b92a0 | ||
|
|
832be3d797 | ||
|
|
72f9d88f96 | ||
|
|
d4a6b142c5 | ||
|
|
8da4dc9d75 | ||
|
|
6ad0aa3e23 | ||
|
|
11c5352555 | ||
|
|
a0bdb9a535 | ||
|
|
37d69e3ddc | ||
|
|
524da71a45 | ||
|
|
3949d6d13c | ||
|
|
d5591b2c91 | ||
|
|
97d19f1d17 | ||
|
|
282a959f88 | ||
|
|
aaa6cdf704 | ||
|
|
bc1614c71b | ||
|
|
b71656d0a6 | ||
|
|
9374f4ab46 | ||
|
|
3b3e65bd1c | ||
|
|
ce035e2204 | ||
|
|
70c0c25521 | ||
|
|
8cd55f53f7 | ||
|
|
6e01729bf5 | ||
|
|
4b4d0c5cb6 | ||
|
|
ff27727f10 | ||
|
|
8f0ad23c0b | ||
|
|
729c893463 | ||
|
|
eb31ad7173 | ||
|
|
a652232b25 | ||
|
|
b8f752d246 | ||
|
|
b837a5fa1e | ||
|
|
9154a16fe1 | ||
|
|
48f6f92f9c | ||
|
|
c6e3594850 | ||
|
|
c6a1b203ce | ||
|
|
1c96ff9516 | ||
|
|
409c064902 | ||
|
|
66667fb440 | ||
|
|
c41fcd37b3 | ||
|
|
9cd0b98a16 | ||
|
|
8951bff083 | ||
|
|
a514bba8b2 | ||
|
|
f8504d466a | ||
|
|
22bb86f052 | ||
|
|
fc850795c9 | ||
|
|
b60ce96dd7 | ||
|
|
6582da60d4 | ||
|
|
d42cc5af1d | ||
|
|
7ea0e2ac10 | ||
|
|
5ce0110197 | ||
|
|
4efc3ce182 | ||
|
|
01515910b6 | ||
|
|
f27ede7625 | ||
|
|
99ab7abf6e | ||
|
|
a7fd37a894 | ||
|
|
8ad2b7cf7e | ||
|
|
3210b4fcfa | ||
|
|
a51ac8fe7f | ||
|
|
7fad6ee02b | ||
|
|
6a6e792cd9 | ||
|
|
3c33c8765a | ||
|
|
27a5bc16bc | ||
|
|
808de7b354 | ||
|
|
618cbc0396 | ||
|
|
67a56f2954 | ||
|
|
88b1a618bd | ||
|
|
d989b14967 | ||
|
|
d4ff2b9a7e | ||
|
|
06ee11521d | ||
|
|
55d6429dc5 | ||
|
|
44c85766fc | ||
|
|
b69308e1ef | ||
|
|
6394e5a2cd | ||
|
|
f31ff19a74 | ||
|
|
064179a753 | ||
|
|
727eaac3d9 | ||
|
|
bd81173559 | ||
|
|
9bace01b93 | ||
|
|
5ad3e12b1f | ||
|
|
6211cc6729 | ||
|
|
f15a2aa6e6 | ||
|
|
aed841dc0b | ||
|
|
221260aca3 | ||
|
|
83988597d5 | ||
|
|
b298509178 | ||
|
|
b6e5f9acbe | ||
|
|
f6ecb33729 | ||
|
|
9d796d6e41 | ||
|
|
45455a16c4 | ||
|
|
2afe97c6db | ||
|
|
4101b736e6 | ||
|
|
b67354610d | ||
|
|
b19c91a7dd | ||
|
|
9b5d19b926 | ||
|
|
aad9a991c2 | ||
|
|
7f0d18eed1 | ||
|
|
879c848d77 | ||
|
|
123c006a1e | ||
|
|
415811f592 | ||
|
|
31066a4d8f | ||
|
|
b700c2de8d | ||
|
|
fda5b8fe2e | ||
|
|
b7a525056a | ||
|
|
7a11e829b3 | ||
|
|
361b61a694 | ||
|
|
0cb060c89c | ||
|
|
4b9cbf65f9 | ||
|
|
813fc9dd38 | ||
|
|
f574d6197b | ||
|
|
2fac3117a4 | ||
|
|
7b072a219d | ||
|
|
23d3356e6b | ||
|
|
5b2702daed | ||
|
|
b9c3eb7091 | ||
|
|
6fbc5d947c | ||
|
|
f520a02226 | ||
|
|
3a43b2672a | ||
|
|
61959a5a2e | ||
|
|
5f16ee2b38 | ||
|
|
a8ebb1dada | ||
|
|
862719b8b0 | ||
|
|
d1ee6d8a10 | ||
|
|
c3268012a5 | ||
|
|
da24b6a5ed | ||
|
|
8b8dd0a427 | ||
|
|
979ab5e86d | ||
|
|
9703cb5ce8 | ||
|
|
c85f4b086e | ||
|
|
f190ad9353 | ||
|
|
659963beb0 | ||
|
|
d3b1e52d88 | ||
|
|
3c0880f527 | ||
|
|
8a1b582f4e | ||
|
|
364474471c | ||
|
|
3ecf617998 | ||
|
|
3f2f55d6c2 | ||
|
|
4e03d52a5d | ||
|
|
2bdba523ad | ||
|
|
716de36bfa | ||
|
|
00d5890a37 | ||
|
|
ecb161bc07 | ||
|
|
1ee4a3bf45 | ||
|
|
5e99324201 | ||
|
|
b06a655bc3 | ||
|
|
906265a0e3 | ||
|
|
1a21b44bc8 | ||
|
|
a8c9e0f253 | ||
|
|
491a857f61 | ||
|
|
b3f463b688 | ||
|
|
9a5d0e33bd | ||
|
|
a166992b04 | ||
|
|
b5ccb0428d | ||
|
|
f4a8314978 | ||
|
|
f19f19a279 | ||
|
|
ad35f641b3 | ||
|
|
6c892bf580 | ||
|
|
89099c2cfd | ||
|
|
0f9616f19a | ||
|
|
3b3cfb5e43 | ||
|
|
24004a99da | ||
|
|
ab7601a74e | ||
|
|
f09606e1f7 | ||
|
|
c610d68b9c | ||
|
|
efb82b0d4a | ||
|
|
216fd85888 | ||
|
|
2aab70aec5 | ||
|
|
57061da20d | ||
|
|
cbc5387097 | ||
|
|
e52dbee835 | ||
|
|
1dee51a7cd | ||
|
|
a76180497e | ||
|
|
5c86483563 | ||
|
|
385c3da0a5 | ||
|
|
5f39d5b1ad | ||
|
|
1081609530 | ||
|
|
901f63841f | ||
|
|
27a262b54a | ||
|
|
a81515e4d8 | ||
|
|
73c5751677 | ||
|
|
0171ee6141 | ||
|
|
1ee2758756 | ||
|
|
fbb21dd8a4 | ||
|
|
45d49b38f7 | ||
|
|
91a7663681 | ||
|
|
302bec114f | ||
|
|
65aa3c7de8 | ||
|
|
c6ef798b22 | ||
|
|
42a9506f02 | ||
|
|
9793ba8348 | ||
|
|
fbf18acf05 | ||
|
|
5c1f9c0ebc | ||
|
|
4cc1c9d157 | ||
|
|
7d03d0dea5 |
No files matched your search
@@ -0,0 +1,237 @@
|
||||
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: Pulizia Cache Dart e Download Dipendenze
|
||||
run: |
|
||||
if (Test-Path ".dart_tool") { Remove-Item -Recurse -Force ".dart_tool" }
|
||||
flutter pub get
|
||||
|
||||
- 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://supabaseapi.catelli.it/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: Pulizia Cache e Fetch Dipendenze
|
||||
run: |
|
||||
rm -rf .dart_tool
|
||||
flutter pub get
|
||||
|
||||
- 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://supabaseapi.catelli.it/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: Pulizia Cache e Fetch Dipendenze
|
||||
run: |
|
||||
rm -rf .dart_tool
|
||||
flutter pub get
|
||||
|
||||
- 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://supabaseapi.catelli.it/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: Pulizia Cache e Fetch Dipendenze
|
||||
run: |
|
||||
rm -rf .dart_tool
|
||||
flutter pub get
|
||||
|
||||
- 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://supabaseapi.catelli.it/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\"}"
|
||||
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"deno.enable": true
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"account_id": "6badf20faeef39fa5c99283f46f07508",
|
||||
"project_name": "flux"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"account": {
|
||||
"id": "6badf20faeef39fa5c99283f46f07508",
|
||||
"name": "Marco@catelli.it's Account"
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
import java.io.FileInputStream
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
// START: FlutterFire Configuration
|
||||
id("com.google.gms.google-services")
|
||||
// END: FlutterFire Configuration
|
||||
id("kotlin-android")
|
||||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle 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
|
||||
@@ -20,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.
|
||||
@@ -30,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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "249756116297",
|
||||
"project_id": "flux-87e49",
|
||||
"storage_bucket": "flux-87e49.firebasestorage.app"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:249756116297:android:a2c3d37323752069cf2698",
|
||||
"android_client_info": {
|
||||
"package_name": "com.catellisrl.flux"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyA6-uX6504B3yofeo7YQwfQaS0cCDoZnvY"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -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
|
||||
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://operations.gradle.org/distributions/gradle-8.14-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip
|
||||
@@ -20,6 +20,9 @@ pluginManagement {
|
||||
plugins {
|
||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||
id("com.android.application") version "8.11.1" apply false
|
||||
// START: FlutterFire Configuration
|
||||
id("com.google.gms.google-services") version("4.3.15") apply false
|
||||
// END: FlutterFire Configuration
|
||||
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 109 KiB |
@@ -0,0 +1 @@
|
||||
{"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"}}}}}}
|
||||
@@ -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"}]}]
|
||||
@@ -0,0 +1 @@
|
||||
{"format-version":[1,0,0],"native-assets":{}}
|
||||
|
After Width: | Height: | Size: 109 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
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 |
@@ -0,0 +1 @@
|
||||
{"app_name":"flux","version":"1.3.1","build_number":"47","package_name":"flux"}
|
||||
@@ -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"}}
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 839 B |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 704 B After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 7.6 KiB |
@@ -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>
|
||||
@@ -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
|
||||
@@ -22,14 +28,19 @@ class SessionCubit extends Cubit<SessionState> {
|
||||
: super(const SessionState(status: SessionStatus.initial)) {
|
||||
initializeSession();
|
||||
// Possiamo metterci in ascolto dei cambiamenti di Auth (Login/Logout)
|
||||
_supabase.auth.onAuthStateChange.listen((data) {
|
||||
final AuthChangeEvent event = data.event;
|
||||
if (event == AuthChangeEvent.signedIn) {
|
||||
initializeSession();
|
||||
} else if (event == AuthChangeEvent.signedOut) {
|
||||
emit(const SessionState(status: SessionStatus.unauthenticated));
|
||||
}
|
||||
});
|
||||
_supabase.auth.onAuthStateChange.listen(
|
||||
(data) {
|
||||
final AuthChangeEvent event = data.event;
|
||||
if (event == AuthChangeEvent.signedIn) {
|
||||
initializeSession();
|
||||
} else if (event == AuthChangeEvent.signedOut) {
|
||||
emit(const SessionState(status: SessionStatus.unauthenticated));
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
debugPrint('Auth state change error: $error');
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> initializeSession() async {
|
||||
@@ -39,110 +50,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 +248,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
const String resetPasswordUrl =
|
||||
'https://flux-web-invite.marco-6ba.workers.dev/';
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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/';
|
||||
@@ -1,97 +1,433 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/core/routes/routes.dart';
|
||||
import 'package:flux/core/utils/extensions.dart';
|
||||
import 'package:flux/core/widgets/app_version_label.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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// --- VERSIONE APP CON HYPERLINK ---
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: AppVersionLabel(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
|
||||
: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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
|
||||
: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.onSurface,
|
||||
),
|
||||
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
|
||||
: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.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
|
||||
: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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
|
||||
: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.onSurface,
|
||||
),
|
||||
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.colorScheme.onSurface,
|
||||
),
|
||||
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);
|
||||
}
|
||||
@@ -4,62 +4,133 @@ 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_daily_ricontatti/blocs/dashboard_daily_ricontatti_cubit.dart';
|
||||
import 'package:flux/features/home/dashboard_expiring_contracts/bloc/dashboard_expiring_contracts_cubit.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/financing_form_screen.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 sia state.uri.path che state.matchedLocation per sicurezza con i deep link
|
||||
final path = state.uri.path;
|
||||
final matched = state.matchedLocation;
|
||||
final isPublicRoute = path.startsWith('/upload') ||
|
||||
path.startsWith('/financing') ||
|
||||
matched.startsWith('/upload') ||
|
||||
matched.startsWith('/financing');
|
||||
|
||||
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 +141,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>(),
|
||||
@@ -86,151 +160,546 @@ class AppRouter {
|
||||
child: const OnboardingScreen(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/financing/:sessionId',
|
||||
name: Routes.financing,
|
||||
builder: (context, state) {
|
||||
final sessionId = state.pathParameters['sessionId'] ?? '';
|
||||
return FinancingFormScreen(sessionId: sessionId);
|
||||
},
|
||||
),
|
||||
|
||||
// --- CORE APP (DENTRO LA SHELL CON NAVIGATION BAR/RAIL) ---
|
||||
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,
|
||||
),
|
||||
),
|
||||
BlocProvider<DashboardExpiringContractsCubit>(
|
||||
create: (context) => DashboardExpiringContractsCubit(
|
||||
companyId: sessionCubit.state.company?.id,
|
||||
storeId: sessionCubit.state.currentStore?.id,
|
||||
),
|
||||
),
|
||||
BlocProvider<DashboardDailyRicontattiCubit>(
|
||||
create: (context) => DashboardDailyRicontattiCubit(
|
||||
companyId: sessionCubit.state.company?.id,
|
||||
storeId: sessionCubit.state.currentStore?.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(),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
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';
|
||||
static const String financing = 'financing';
|
||||
}
|
||||
@@ -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,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';
|
||||
|
||||
|
||||
@@ -104,11 +104,25 @@ ThemeData fluxDarkTheme = ThemeData(
|
||||
),
|
||||
),
|
||||
|
||||
drawerTheme: const DrawerThemeData(
|
||||
backgroundColor: FluxColors.darkSurface,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
),
|
||||
|
||||
expansionTileTheme: const ExpansionTileThemeData(
|
||||
iconColor: FluxColors.accentTurquoise,
|
||||
collapsedIconColor: FluxColors.darkTextSecondary,
|
||||
textColor: FluxColors.darkTextPrimary,
|
||||
collapsedTextColor: FluxColors.darkTextPrimary,
|
||||
),
|
||||
|
||||
listTileTheme: ListTileThemeData(
|
||||
// Definiamo la forma arrotondata (fondamentale per l'effetto moderno)
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
// Colore dell'icona (Turchese Flux)
|
||||
iconColor: FluxColors.accentTurquoise,
|
||||
selectedColor: FluxColors.primaryBlue,
|
||||
selectedTileColor: FluxColors.primaryBlue.withValues(alpha: 0.15),
|
||||
// Colore del testo
|
||||
titleTextStyle: GoogleFonts.poppins(
|
||||
color: FluxColors.darkTextPrimary,
|
||||
@@ -121,9 +135,6 @@ ThemeData fluxDarkTheme = ThemeData(
|
||||
),
|
||||
// Per far apparire la "manina" su Web/Desktop
|
||||
mouseCursor: WidgetStateProperty.all(SystemMouseCursors.click),
|
||||
|
||||
// NOTA: Se overlayColor non esiste, Flutter userà i colori
|
||||
// di default del tema (splashColor e hoverColor) definiti nel ThemeData generale.
|
||||
),
|
||||
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
@@ -189,26 +200,37 @@ ThemeData fluxLightTheme = ThemeData(
|
||||
),
|
||||
),
|
||||
|
||||
drawerTheme: const DrawerThemeData(
|
||||
backgroundColor: FluxColors.lightSurface,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
),
|
||||
|
||||
expansionTileTheme: const ExpansionTileThemeData(
|
||||
iconColor: FluxColors.accentTurquoise,
|
||||
collapsedIconColor: FluxColors.lightTextSecondary,
|
||||
textColor: FluxColors.lightTextPrimary,
|
||||
collapsedTextColor: FluxColors.lightTextPrimary,
|
||||
),
|
||||
|
||||
listTileTheme: ListTileThemeData(
|
||||
// Definiamo la forma arrotondata (fondamentale per l'effetto moderno)
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
// Colore dell'icona (Turchese Flux)
|
||||
iconColor: FluxColors.accentTurquoise,
|
||||
// Colore del testo
|
||||
selectedColor: FluxColors.primaryBlue,
|
||||
selectedTileColor: FluxColors.primaryBlue.withValues(alpha: 0.1),
|
||||
// Colore del testo per il tema chiaro
|
||||
titleTextStyle: GoogleFonts.poppins(
|
||||
color: FluxColors.darkTextPrimary,
|
||||
color: FluxColors.lightTextPrimary,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
subtitleTextStyle: GoogleFonts.poppins(
|
||||
color: FluxColors.darkTextSecondary,
|
||||
color: FluxColors.lightTextSecondary,
|
||||
fontSize: 13,
|
||||
),
|
||||
// Per far apparire la "manina" su Web/Desktop
|
||||
mouseCursor: WidgetStateProperty.all(SystemMouseCursors.click),
|
||||
|
||||
// NOTA: Se overlayColor non esiste, Flutter userà i colori
|
||||
// di default del tema (splashColor e hoverColor) definiti nel ThemeData generale.
|
||||
),
|
||||
|
||||
// Il pulsante principale rimane Blu Elettrico, molto visibile
|
||||
@@ -260,12 +282,14 @@ extension FluxThemeContext on BuildContext {
|
||||
// --- Testi (La parte mancante) ---
|
||||
// Mappiamo primaryText sul colore del titolo e secondaryText su quello del corpo
|
||||
Color get primaryText =>
|
||||
Theme.of(this).textTheme.titleLarge?.color ?? Colors.white;
|
||||
Theme.of(this).textTheme.titleLarge?.color ??
|
||||
Theme.of(this).colorScheme.onSurface;
|
||||
Color get secondaryText =>
|
||||
Theme.of(this).textTheme.bodyMedium?.color ?? Colors.grey;
|
||||
Theme.of(this).textTheme.bodyMedium?.color ??
|
||||
Theme.of(this).colorScheme.onSurfaceVariant;
|
||||
|
||||
// Opzionale: un colore ancora più tenue per suggerimenti o icone disabilitate
|
||||
Color get hintText =>
|
||||
Theme.of(this).textTheme.bodySmall?.color ??
|
||||
Colors.grey.withValues(alpha: 0.5);
|
||||
Theme.of(this).colorScheme.onSurface.withValues(alpha: 0.5);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:image/image.dart' as img;
|
||||
|
||||
/// Utilità per la gestione delle immagini e normalizzazione dell'orientamento EXIF.
|
||||
class ImageUtils {
|
||||
/// Verifica se l'estensione corrisponde a un'immagine supportata.
|
||||
static bool isImageExtension(String? extension) {
|
||||
if (extension == null) return false;
|
||||
final ext = extension.toLowerCase().replaceAll('.', '');
|
||||
return ['jpg', 'jpeg', 'png', 'webp', 'bmp'].contains(ext);
|
||||
}
|
||||
|
||||
/// Verifica se un nome file o percorso è un'immagine supportata.
|
||||
static bool isImagePath(String path) {
|
||||
final dotIndex = path.lastIndexOf('.');
|
||||
if (dotIndex == -1 || dotIndex == path.length - 1) return false;
|
||||
return isImageExtension(path.substring(dotIndex + 1));
|
||||
}
|
||||
|
||||
/// Ruota fisicamente i pixel dell'immagine se contiene metadati EXIF di orientamento
|
||||
/// (tipico delle fotocamere degli smartphone), resettando l'orientamento a 1 (normale).
|
||||
/// Se l'immagine è già dritta o non possiede metadati EXIF, restituisce i byte originali.
|
||||
static Uint8List normalizeOrientation(Uint8List bytes, {String? extension}) {
|
||||
try {
|
||||
final image = img.decodeImage(bytes);
|
||||
if (image == null) return bytes;
|
||||
|
||||
// Se non ha tag di orientamento o è già orientata dritta (1)
|
||||
if (!image.exif.imageIfd.hasOrientation || image.exif.imageIfd.orientation == 1) {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// Applica la rotazione fisica dei pixel e resetta il tag EXIF
|
||||
final baked = img.bakeOrientation(image);
|
||||
|
||||
final ext = extension?.toLowerCase().replaceAll('.', '');
|
||||
final isPng = ext == 'png' || (ext == null && image.hasAlpha);
|
||||
|
||||
if (isPng) {
|
||||
return Uint8List.fromList(img.encodePng(baked));
|
||||
} else {
|
||||
return Uint8List.fromList(img.encodeJpg(baked, quality: 92));
|
||||
}
|
||||
} catch (_) {
|
||||
// In caso di errore di parsing/decodifica, restituisce i byte inalterati
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/core/utils/auto_update_service.dart';
|
||||
import 'package:flux/core/utils/version_check_service.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class UpdatePromptHelper {
|
||||
/// Avvia una verifica manuale degli aggiornamenti con feedback visivo immediato
|
||||
static Future<void> showManualUpdateCheck(BuildContext context) async {
|
||||
// Feedback immediato tramite SnackBar
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
messenger.hideCurrentSnackBar();
|
||||
messenger.showSnackBar(
|
||||
const SnackBar(
|
||||
content: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Text("Verifica aggiornamenti in corso..."),
|
||||
],
|
||||
),
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final currentVersion = await VersionCheckService.getShortVersionString();
|
||||
final updateInfo = await VersionCheckService().checkUpdate();
|
||||
|
||||
if (!context.mounted) return;
|
||||
messenger.hideCurrentSnackBar();
|
||||
|
||||
if (updateInfo != null && updateInfo.hasUpdate) {
|
||||
// Nuova versione disponibile: mostra il dialog informativo e di azione
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: !updateInfo.isMandatory,
|
||||
builder: (dialogContext) => _ManualUpdateDialog(
|
||||
updateInfo: updateInfo,
|
||||
currentVersion: currentVersion,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// Nessun aggiornamento: l'app è già all'ultima versione
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: Colors.green.shade700,
|
||||
content: Row(
|
||||
children: [
|
||||
const Icon(Icons.check_circle_outline, color: Colors.white),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Flux è aggiornato all'ultima versione disponibile ($currentVersion).",
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
duration: const Duration(seconds: 4),
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
messenger.hideCurrentSnackBar();
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: Colors.red.shade700,
|
||||
content: Row(
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: Colors.white),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Impossibile verificare gli aggiornamenti: $e",
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
duration: const Duration(seconds: 4),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _ManualUpdateDialog extends StatefulWidget {
|
||||
final UpdateInfo updateInfo;
|
||||
final String currentVersion;
|
||||
|
||||
const _ManualUpdateDialog({
|
||||
required this.updateInfo,
|
||||
required this.currentVersion,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_ManualUpdateDialog> createState() => _ManualUpdateDialogState();
|
||||
}
|
||||
|
||||
class _ManualUpdateDialogState extends State<_ManualUpdateDialog> {
|
||||
bool _isUpdating = false;
|
||||
double _downloadProgress = 0.0;
|
||||
String _statusMessage = "";
|
||||
String? _errorMessage;
|
||||
|
||||
Future<void> _startUpdate() async {
|
||||
setState(() {
|
||||
_isUpdating = true;
|
||||
_errorMessage = null;
|
||||
_downloadProgress = 0.0;
|
||||
_statusMessage = "Avvio aggiornamento...";
|
||||
});
|
||||
|
||||
try {
|
||||
await AutoUpdateService.downloadAndApplyUpdate(
|
||||
downloadUrl: widget.updateInfo.downloadUrl,
|
||||
onProgress: (progress, status) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_downloadProgress = progress;
|
||||
_statusMessage = status;
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isUpdating = false;
|
||||
_errorMessage = "Errore durante l'aggiornamento: $e";
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final updateInfo = widget.updateInfo;
|
||||
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(
|
||||
updateInfo.isMandatory
|
||||
? Icons.warning_amber_rounded
|
||||
: (kIsWeb ? Icons.cached : Icons.system_update),
|
||||
color: updateInfo.isMandatory ? Colors.amber[700] : Colors.blue,
|
||||
size: 28,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
updateInfo.isMandatory
|
||||
? "Aggiornamento Obbligatorio"
|
||||
: "Nuova Versione Disponibile",
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
content: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 400),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
style: const TextStyle(fontSize: 14),
|
||||
children: [
|
||||
const TextSpan(text: "Versione installata: "),
|
||||
TextSpan(
|
||||
text: widget.currentVersion,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const TextSpan(text: "\nNuova versione disponibile: "),
|
||||
TextSpan(
|
||||
text: "v${updateInfo.latestVersion}",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
kIsWeb
|
||||
? "È stata rilasciata una nuova versione. Ricarica la pagina per applicarla."
|
||||
: (updateInfo.isMandatory
|
||||
? "La versione attuale non è più supportata. Aggiorna all'ultima versione per continuare a lavorare."
|
||||
: "Vuoi scaricare e installare l'aggiornamento adesso?"),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.8),
|
||||
),
|
||||
),
|
||||
if (_errorMessage != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.red.withValues(alpha: 0.3)),
|
||||
),
|
||||
child: Text(
|
||||
_errorMessage!,
|
||||
style: const TextStyle(color: Colors.red, fontSize: 13),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (_isUpdating) ...[
|
||||
const SizedBox(height: 16),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: LinearProgressIndicator(
|
||||
value: _downloadProgress > 0 ? _downloadProgress : null,
|
||||
minHeight: 8,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
_statusMessage,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.7),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: _isUpdating
|
||||
? []
|
||||
: [
|
||||
if (!updateInfo.isMandatory)
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text("PIÙ TARDI"),
|
||||
),
|
||||
if (kIsWeb)
|
||||
FilledButton.icon(
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text("RICARICA ORA"),
|
||||
onPressed: () {
|
||||
html.window.location.reload();
|
||||
},
|
||||
)
|
||||
else if (AutoUpdateService.isAutoUpdateSupported)
|
||||
FilledButton.icon(
|
||||
icon: const Icon(Icons.system_update_alt),
|
||||
label: const Text("AGGIORNA ORA"),
|
||||
onPressed: _startUpdate,
|
||||
)
|
||||
else
|
||||
FilledButton.icon(
|
||||
icon: const Icon(Icons.open_in_browser),
|
||||
label: const Text("SCARICA"),
|
||||
onPressed: () async {
|
||||
final url = Uri.parse(updateInfo.downloadUrl);
|
||||
await launchUrl(url, mode: LaunchMode.externalApplication);
|
||||
if (context.mounted) Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
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;
|
||||
}
|
||||
|
||||
static Future<String> getAppVersionString() async {
|
||||
try {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
return info.buildNumber.isNotEmpty
|
||||
? 'v${info.version}+${info.buildNumber}'
|
||||
: 'v${info.version}';
|
||||
} catch (_) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
static Future<String> getFullVersionString() => getAppVersionString();
|
||||
|
||||
static Future<String> getShortVersionString() async {
|
||||
try {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
return 'v${info.version}';
|
||||
} catch (_) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/core/utils/update_prompt_helper.dart';
|
||||
import 'package:flux/core/utils/version_check_service.dart';
|
||||
|
||||
class AppVersionLabel extends StatefulWidget {
|
||||
final bool isCollapsed;
|
||||
final bool showIcon;
|
||||
|
||||
const AppVersionLabel({
|
||||
super.key,
|
||||
this.isCollapsed = false,
|
||||
this.showIcon = true,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AppVersionLabel> createState() => _AppVersionLabelState();
|
||||
}
|
||||
|
||||
class _AppVersionLabelState extends State<AppVersionLabel> {
|
||||
String _version = "";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadVersion();
|
||||
}
|
||||
|
||||
Future<void> _loadVersion() async {
|
||||
final v = await VersionCheckService.getShortVersionString();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_version = v;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_version.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
final theme = Theme.of(context);
|
||||
final textMuted = theme.colorScheme.onSurface.withValues(alpha: 0.5);
|
||||
|
||||
if (widget.isCollapsed) {
|
||||
return Tooltip(
|
||||
message: "Flux $_version\nClicca per verificare aggiornamenti",
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: () => UpdatePromptHelper.showManualUpdateCheck(context),
|
||||
child: Container(
|
||||
height: 36,
|
||||
width: 36,
|
||||
alignment: Alignment.center,
|
||||
child: Icon(
|
||||
Icons.info_outline,
|
||||
size: 16,
|
||||
color: textMuted,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Tooltip(
|
||||
message: "Clicca per verificare se ci sono aggiornamenti",
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
onTap: () => UpdatePromptHelper.showManualUpdateCheck(context),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (widget.showIcon) ...[
|
||||
Icon(
|
||||
Icons.info_outline,
|
||||
size: 13,
|
||||
color: textMuted,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
Text(
|
||||
"Flux $_version",
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: textMuted,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: textMuted.withValues(alpha: 0.4),
|
||||
decorationStyle: TextDecorationStyle.dotted,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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,88 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/utils/image_utils.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 clearFiles() {
|
||||
emit(state.copyWith(status: ImageUploadStatus.initial, stagedFiles: []));
|
||||
}
|
||||
|
||||
void addFiles(List<PlatformFile> files) {
|
||||
final List<PlatformFile> processedFiles = files.map((file) {
|
||||
if (file.bytes != null && ImageUtils.isImagePath(file.name)) {
|
||||
final normalizedBytes = ImageUtils.normalizeOrientation(
|
||||
file.bytes!,
|
||||
extension: file.extension,
|
||||
);
|
||||
return PlatformFile(
|
||||
name: file.name,
|
||||
size: normalizedBytes.length,
|
||||
bytes: normalizedBytes,
|
||||
path: file.path,
|
||||
);
|
||||
}
|
||||
return file;
|
||||
}).toList();
|
||||
|
||||
List<PlatformFile> newFiles = List.from(state.stagedFiles);
|
||||
newFiles.addAll(processedFiles);
|
||||
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 rawBytes = await photo.readAsBytes();
|
||||
final normalizedBytes = ImageUtils.normalizeOrientation(
|
||||
rawBytes,
|
||||
extension: 'jpg',
|
||||
);
|
||||
|
||||
final List<PlatformFile> newFiles = List.from(files);
|
||||
newFiles.removeLast();
|
||||
final PlatformFile loadedFile = PlatformFile(
|
||||
name: photo.name,
|
||||
size: normalizedBytes.length,
|
||||
bytes: normalizedBytes,
|
||||
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,456 @@
|
||||
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(title),
|
||||
centerTitle: true,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
// --- BARRA SUPERIORE: ANNULLA / INVIA ---
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
vertical: 10.0,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// ANNULLA
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: SizedBox(
|
||||
height: 48,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed:
|
||||
state.status == ImageUploadStatus.uploading
|
||||
? null
|
||||
: () => _handleCancel(context),
|
||||
icon: const Icon(Icons.close, size: 20),
|
||||
label: const Text(
|
||||
'Annulla',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Colors.red.shade700,
|
||||
side: BorderSide(color: Colors.red.shade300),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// INVIA
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: SizedBox(
|
||||
height: 48,
|
||||
child: FilledButton.icon(
|
||||
onPressed:
|
||||
state.stagedFiles.isEmpty ||
|
||||
state.status ==
|
||||
ImageUploadStatus.uploading
|
||||
? null
|
||||
: () => _submitAllFiles(context),
|
||||
icon: const Icon(Icons.cloud_upload, size: 20),
|
||||
label: Text(
|
||||
state.stagedFiles.isEmpty
|
||||
? 'Invia'
|
||||
: 'Invia (${state.stagedFiles.length})',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
style: FilledButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const Divider(height: 1),
|
||||
|
||||
// --- SEZIONE ANTEPRIME ---
|
||||
Expanded(
|
||||
child: state.stagedFiles.isEmpty
|
||||
? const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.add_photo_alternate_outlined,
|
||||
size: 64,
|
||||
color: Colors.grey,
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
"Nessun file selezionato",
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Text(
|
||||
"Tocca 'Scatta' o 'Galleria' in basso per aggiungere foto o documenti.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: GridView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
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: [
|
||||
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
|
||||
? Image.memory(
|
||||
file.bytes!,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: 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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: -6,
|
||||
right: -6,
|
||||
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 INFERIORE (A portata di pollice: Scatta e Galleria) ---
|
||||
SafeArea(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
vertical: 12.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.06),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, -2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// SCATTA
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 56,
|
||||
child: FilledButton.icon(
|
||||
onPressed:
|
||||
state.status ==
|
||||
ImageUploadStatus.uploading
|
||||
? null
|
||||
: () => _handleCamera(context),
|
||||
icon: const Icon(Icons.camera_alt, size: 24),
|
||||
label: const Text(
|
||||
'Scatta',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
style: FilledButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// GALLERIA
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 56,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed:
|
||||
state.status ==
|
||||
ImageUploadStatus.uploading
|
||||
? null
|
||||
: () => _handleFilePicker(context),
|
||||
icon: const Icon(
|
||||
Icons.photo_library,
|
||||
size: 24,
|
||||
),
|
||||
label: const Text(
|
||||
'Galleria',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (state.status == ImageUploadStatus.uploading)
|
||||
Container(
|
||||
color: Colors.black45,
|
||||
child: const Center(
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Caricamento in corso...',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _handleCancel(BuildContext context) {
|
||||
final cubit = context.read<ImageUploadCubit>();
|
||||
if (cubit.state.stagedFiles.isNotEmpty) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Annullare caricamento?'),
|
||||
content: const Text('I file selezionati verranno rimossi.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('No, continua'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
|
||||
onPressed: () {
|
||||
Navigator.pop(ctx);
|
||||
cubit.clearFiles();
|
||||
if (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: const Text('Sì, annulla'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- 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,67 @@
|
||||
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),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (Navigator.of(context).canPop())
|
||||
OutlinedButton.icon(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
icon: const Icon(Icons.add_photo_alternate),
|
||||
label: const Text('Carica altri file per questa pratica'),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Colors.green.shade800,
|
||||
side: BorderSide(color: Colors.green.shade600),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/core/utils/extensions.dart';
|
||||
import 'package:flux/core/utils/functions.dart';
|
||||
import 'package:pdfx/pdfx.dart';
|
||||
import 'package:pdfrx/pdfrx.dart';
|
||||
import 'package:internet_file/internet_file.dart';
|
||||
|
||||
class PdfViewerWidget extends StatefulWidget {
|
||||
@@ -20,7 +20,7 @@ class PdfViewerWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PdfViewerWidgetState extends State<PdfViewerWidget> {
|
||||
late PdfControllerPinch _pdfController;
|
||||
Uint8List? _pdfData;
|
||||
bool _isLoading = true;
|
||||
String? _errorMessage;
|
||||
|
||||
@@ -45,11 +45,12 @@ class _PdfViewerWidgetState extends State<PdfViewerWidget> {
|
||||
throw Exception("Nessun documento trovato");
|
||||
}
|
||||
|
||||
_pdfController = PdfControllerPinch(
|
||||
document: PdfDocument.openData(pdfData),
|
||||
);
|
||||
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_pdfData = pdfData;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@@ -60,12 +61,6 @@ class _PdfViewerWidgetState extends State<PdfViewerWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_pdfController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isLoading) {
|
||||
@@ -87,7 +82,10 @@ class _PdfViewerWidgetState extends State<PdfViewerWidget> {
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
),
|
||||
body: PdfViewPinch(controller: _pdfController),
|
||||
body: PdfViewer.data(
|
||||
_pdfData!,
|
||||
sourceName: widget.storagePath ?? 'document.pdf',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
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 {
|
||||
class QrUploadDialog extends StatefulWidget {
|
||||
final String deepLinkUrl;
|
||||
final String title;
|
||||
|
||||
@@ -12,83 +14,143 @@ class QrUploadDialog extends StatelessWidget {
|
||||
required this.title,
|
||||
});
|
||||
|
||||
@override
|
||||
State<QrUploadDialog> createState() => _QrUploadDialogState();
|
||||
}
|
||||
|
||||
class _QrUploadDialogState extends State<QrUploadDialog> {
|
||||
int _initialFileCount = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Memorizziamo quanti file c'erano al momento dell'apertura per contare solo i nuovi ricevuti
|
||||
_initialFileCount = context.read<AttachmentsBloc>().state.allFiles.length;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 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) =>
|
||||
current.allFiles.length > previous.allFiles.length,
|
||||
listener: (context, state) {
|
||||
final sessionReceived = (state.allFiles.length - _initialFileCount).clamp(0, 99999);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'Nuovo file ricevuto via QR Code! 📄 ($sessionReceived in questa sessione)',
|
||||
),
|
||||
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 sessionReceived = (state.allFiles.length - _initialFileCount).clamp(0, 99999);
|
||||
|
||||
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,
|
||||
),
|
||||
widget.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,
|
||||
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,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: QrImageView(
|
||||
data: widget.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(
|
||||
sessionReceived > 0
|
||||
? Icons.check_circle_outline
|
||||
: Icons.hourglass_empty,
|
||||
size: 18,
|
||||
color: sessionReceived > 0
|
||||
? Colors.green
|
||||
: theme.colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
sessionReceived > 0
|
||||
? "$sessionReceived file ricevuti! (In ascolto...)"
|
||||
: "In attesa di file...",
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: sessionReceived > 0
|
||||
? Colors.green
|
||||
: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_initialFileCount > 0 && sessionReceived == 0) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
"($_initialFileCount file già presenti nella pratica)",
|
||||
style: const TextStyle(fontSize: 11, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 8),
|
||||
const LinearProgressIndicator(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(context.l10n.commonClose),
|
||||
),
|
||||
],
|
||||
actionsAlignment: MainAxisAlignment.center,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||