Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
832be3d797 | ||
|
|
72f9d88f96 | ||
|
|
d4a6b142c5 | ||
|
|
8da4dc9d75 | ||
|
|
6ad0aa3e23 |
No files matched your search
@@ -49,44 +49,24 @@ jobs:
|
||||
files: "build/windows/installer/FluxInstaller.exe"
|
||||
api_key: ${{ secrets.MYRELEASE_TOKEN }}
|
||||
|
||||
- name: Aggiorna Link Windows su Supabase
|
||||
run: |
|
||||
$TagVersion = "${{ github.ref_name }}".TrimStart('v')
|
||||
$headers = @{
|
||||
"apikey" = "${{ secrets.SUPABASE_SERVICE_KEY }}"
|
||||
"Authorization" = "Bearer ${{ secrets.SUPABASE_SERVICE_KEY }}"
|
||||
"Content-Type" = "application/json"
|
||||
}
|
||||
$body = (@{
|
||||
download_url = "https://gitea.catelli.it/brontomark/flux/releases/download/${{ github.ref_name }}/FluxInstaller.exe"
|
||||
latest_version = $TagVersion
|
||||
} | ConvertTo-Json)
|
||||
Invoke-RestMethod -Uri "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.windows" -Method Patch -Headers $headers -Body $body
|
||||
|
||||
- name: Pulisci Workspace Windows
|
||||
if: always()
|
||||
run: Remove-Item -Recurse -Force ./*
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# JOB 2: ANDROID APPBUNDLE (Gira sul runner Fedora o Mac)
|
||||
# -----------------------------------------------------------------
|
||||
build-android:
|
||||
runs-on: cross-runner
|
||||
steps:
|
||||
- name: Checkout del codice
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Logica Bash per Mac/Linux: usiamo le virgolette singole forti per evitare escape strani
|
||||
- name: Crea file .env
|
||||
run: |
|
||||
cat << 'EOF' > .env
|
||||
${{ secrets.ENV_FILE_CONTENT }}
|
||||
EOF
|
||||
|
||||
- name: Build Flutter AppBundle
|
||||
run: flutter build appbundle --release
|
||||
|
||||
# Carichiamo l'AAB nelle release di Gitea per poi caricarlo su Google Play Console
|
||||
- name: Upload Android Asset
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
with:
|
||||
files: "build/app/outputs/bundle/release/app-release.aab"
|
||||
api_key: ${{ secrets.MYRELEASE_TOKEN }}
|
||||
|
||||
- name: Aggiorna Link Android su Supabase
|
||||
run: |
|
||||
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?id=eq.49f18b19-2129-46c0-b690-a97db725b5a8" -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 }}/app-release.aab\"}"
|
||||
|
||||
- name: Aggiorna Link Windows su Supabase
|
||||
run: |
|
||||
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?id=eq.1f888b30-5cbf-4a16-820c-5036a3af0cf8" -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 }}/FluxInstaller.exe\"}"
|
||||
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# JOB 3: WEB & CLOUDFLARE DEPLOY (Gira sul runner Fedora o Mac)
|
||||
@@ -114,6 +94,15 @@ jobs:
|
||||
run: |
|
||||
npx wrangler pages deploy build/web --project-name="flux" --branch="main"
|
||||
|
||||
- name: Aggiorna Versione Web su Supabase
|
||||
run: |
|
||||
TagVersion="${GITHUB_REF_NAME#v}"
|
||||
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.web" \
|
||||
-H "apikey: ${{ secrets.SUPABASE_SERVICE_KEY }}" \
|
||||
-H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_KEY }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"latest_version\": \"$TagVersion\"}"
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# JOB 4: LINUX APPIMAGE (Gira sul tuo PC Fedora / Linux Runner)
|
||||
# -----------------------------------------------------------------
|
||||
@@ -175,7 +164,12 @@ jobs:
|
||||
|
||||
- name: Aggiorna Link Linux su Supabase
|
||||
run: |
|
||||
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.linux" -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\"}"
|
||||
TagVersion="${GITHUB_REF_NAME#v}"
|
||||
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.AppImage" \
|
||||
-H "apikey: ${{ secrets.SUPABASE_SERVICE_KEY }}" \
|
||||
-H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_KEY }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"download_url\": \"https://gitea.catelli.it/brontomark/flux/releases/download/${{ github.ref_name }}/Flux-x86_64.AppImage\", \"latest_version\": \"$TagVersion\"}"
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# JOB 5: MACOS (Gira sul tuo Mac / macos-runner)
|
||||
@@ -215,4 +209,9 @@ jobs:
|
||||
|
||||
- name: Aggiorna Link macOS su Supabase
|
||||
run: |
|
||||
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.macos" -H "apikey: ${{ secrets.SUPABASE_SERVICE_KEY }}" -H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_KEY }}" -H "Content-Type: application/json" -d "{\"download_url\": \"https://gitea.catelli.it/brontomark/flux/releases/download/${{ github.ref_name }}/Flux-macOS.dmg\"}"
|
||||
TagVersion="${GITHUB_REF_NAME#v}"
|
||||
curl -X PATCH "https://pvqpjloswwvtfoxbkfbh.supabase.co/rest/v1/app_config?platform=eq.macos" \
|
||||
-H "apikey: ${{ secrets.SUPABASE_SERVICE_KEY }}" \
|
||||
-H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_KEY }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"download_url\": \"https://gitea.catelli.it/brontomark/flux/releases/download/${{ github.ref_name }}/Flux-macOS.dmg\", \"latest_version\": \"$TagVersion\"}"
|
||||
@@ -11,6 +11,10 @@ analyzer:
|
||||
- "ios/**"
|
||||
- "macos/**"
|
||||
- ".dart_tool/**"
|
||||
- android/**
|
||||
- web/**
|
||||
- windows/**
|
||||
- linux/**
|
||||
|
||||
linter:
|
||||
rules:
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,46 +3,86 @@ 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<String?> checkForceUpdate() async {
|
||||
Future<UpdateInfo?> checkUpdate() async {
|
||||
try {
|
||||
// 1. Capiamo su che piattaforma sta girando l'app in questo istante
|
||||
String currentPlatform = _getCurrentPlatform();
|
||||
final platformAliases = _getPlatformAliases();
|
||||
|
||||
// 2. Recuperiamo SOLO la riga corrispondente alla nostra piattaforma
|
||||
final dbResponse = await Supabase.instance.client
|
||||
.from('app_config')
|
||||
.select('min_version, download_url')
|
||||
.eq('platform', currentPlatform)
|
||||
.maybeSingle(); // Usiamo maybeSingle così se non c'è la riga non crasha
|
||||
.select('platform, min_version, latest_version, download_url');
|
||||
|
||||
if (dbResponse == null) {
|
||||
return null; // Nessuna regola per questa piattaforma
|
||||
if (dbResponse.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String minVersionFromDb = dbResponse['min_version'] as String;
|
||||
String downloadUrl = dbResponse['download_url'] as String;
|
||||
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: () => {},
|
||||
);
|
||||
|
||||
// 3. Recuperiamo la versione locale di Flutter
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
String localVersionRaw = packageInfo.version;
|
||||
if (config.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 🥷 TRUCCO 1: Pulizia totale dai build number (+37) o tag "v"
|
||||
String cleanLocal = localVersionRaw
|
||||
.split('+')
|
||||
.first
|
||||
.replaceAll('v', '')
|
||||
.trim();
|
||||
String cleanDb = minVersionFromDb
|
||||
.split('+')
|
||||
.first
|
||||
.replaceAll('v', '')
|
||||
.trim();
|
||||
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?) ?? '';
|
||||
|
||||
// 🥷 TRUCCO 2: Confronto Semantico Reale
|
||||
if (_isVersionLower(current: cleanLocal, minimum: cleanDb)) {
|
||||
// Ritorna il link VERO per questa specifica piattaforma preso dal CSV!
|
||||
return downloadUrl;
|
||||
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;
|
||||
@@ -52,43 +92,48 @@ class VersionCheckService {
|
||||
}
|
||||
}
|
||||
|
||||
// Helper ninja per mappare le piattaforme in base alle stringhe del tuo DB
|
||||
String _getCurrentPlatform() {
|
||||
if (kIsWeb) return 'web';
|
||||
if (Platform.isAndroid) return 'android';
|
||||
if (Platform.isIOS) return 'ios';
|
||||
if (Platform.isWindows) return 'windows';
|
||||
if (Platform.isMacOS) return 'macos';
|
||||
if (Platform.isLinux) return 'linux';
|
||||
return 'unknown';
|
||||
Future<String?> checkForceUpdate() async {
|
||||
final info = await checkUpdate();
|
||||
return info?.isMandatory == true ? info?.downloadUrl : null;
|
||||
}
|
||||
|
||||
// Il motore matematico (resta invariato)
|
||||
bool _isVersionLower({required String current, required String minimum}) {
|
||||
if (current == minimum) return false;
|
||||
String _cleanVersion(String raw) {
|
||||
return raw.split('+').first.replaceAll('v', '').trim();
|
||||
}
|
||||
|
||||
List<int> currentParts = current
|
||||
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();
|
||||
List<int> minParts = minimum
|
||||
final targetParts = target
|
||||
.split('.')
|
||||
.map((e) => int.tryParse(e) ?? 0)
|
||||
.toList();
|
||||
|
||||
while (currentParts.length < 3) {
|
||||
currentParts.add(0);
|
||||
}
|
||||
while (minParts.length < 3) {
|
||||
minParts.add(0);
|
||||
}
|
||||
final maxLength = currentParts.length > targetParts.length
|
||||
? currentParts.length
|
||||
: targetParts.length;
|
||||
|
||||
if (currentParts[0] != minParts[0]) {
|
||||
return currentParts[0] < minParts[0];
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (currentParts[1] != minParts[1]) {
|
||||
return currentParts[1] < minParts[1];
|
||||
}
|
||||
return currentParts[2] < minParts[2];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+216
-29
@@ -32,6 +32,7 @@ import 'package:flux/features/master_data/store/bloc/store_cubit.dart';
|
||||
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:flux/core/utils/auto_update_service.dart';
|
||||
|
||||
String? initialRecoveryFragment;
|
||||
void main() async {
|
||||
@@ -236,9 +237,14 @@ class GlobalUpdateChecker extends StatefulWidget {
|
||||
|
||||
class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker>
|
||||
with WidgetsBindingObserver {
|
||||
bool _mustUpdate = false;
|
||||
String? _updateUrl;
|
||||
UpdateInfo? _updateInfo;
|
||||
bool _isDismissed = false;
|
||||
String? _dismissedVersion;
|
||||
StreamSubscription? _versionSubscription;
|
||||
bool _isUpdating = false;
|
||||
double _downloadProgress = 0.0;
|
||||
String _statusMessage = "";
|
||||
String? _errorMessage;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -280,7 +286,7 @@ class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker>
|
||||
|
||||
// Riapriamo il rubinetto di Supabase
|
||||
_versionSubscription = GetIt.I<SupabaseClient>()
|
||||
.from('app_config') // <-- Sostituisci col nome reale della tua tabella
|
||||
.from('app_config')
|
||||
.stream(primaryKey: ['id'])
|
||||
.listen((_) {
|
||||
_checkVersion();
|
||||
@@ -294,19 +300,63 @@ class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker>
|
||||
}
|
||||
|
||||
Future<void> _checkVersion() async {
|
||||
final updateUrl = await VersionCheckService().checkForceUpdate();
|
||||
final updateInfo = await VersionCheckService().checkUpdate();
|
||||
|
||||
if (updateUrl != null && mounted) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_mustUpdate = true;
|
||||
_updateUrl = updateUrl;
|
||||
_updateInfo = updateInfo;
|
||||
// Se arriva una versione diversa da quella già rimandata, azzeriamo il dismiss
|
||||
if (updateInfo != null &&
|
||||
updateInfo.latestVersion != _dismissedVersion) {
|
||||
_isDismissed = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _startAutoUpdate() async {
|
||||
final updateUrl = _updateInfo?.downloadUrl;
|
||||
if (updateUrl == null || updateUrl.isEmpty) return;
|
||||
|
||||
setState(() {
|
||||
_isUpdating = true;
|
||||
_errorMessage = null;
|
||||
_downloadProgress = 0.0;
|
||||
_statusMessage = "Avvio aggiornamento in corso...";
|
||||
});
|
||||
|
||||
try {
|
||||
await AutoUpdateService.downloadAndApplyUpdate(
|
||||
downloadUrl: updateUrl,
|
||||
onProgress: (progress, status) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_downloadProgress = progress;
|
||||
_statusMessage = status;
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isUpdating = false;
|
||||
_errorMessage = "Errore durante l'aggiornamento automatico: $e";
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_mustUpdate) return widget.child;
|
||||
final updateInfo = _updateInfo;
|
||||
final showOverlay = updateInfo != null &&
|
||||
updateInfo.hasUpdate &&
|
||||
(updateInfo.isMandatory || !_isDismissed);
|
||||
|
||||
if (!showOverlay) return widget.child;
|
||||
|
||||
final isMandatory = updateInfo.isMandatory;
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
@@ -320,7 +370,7 @@ class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker>
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(24),
|
||||
padding: const EdgeInsets.all(24),
|
||||
constraints: const BoxConstraints(maxWidth: 400),
|
||||
constraints: const BoxConstraints(maxWidth: 440),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
@@ -339,32 +389,96 @@ class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker>
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
kIsWeb ? Icons.cached : Icons.system_update,
|
||||
color: Colors.orange,
|
||||
isMandatory
|
||||
? Icons.warning_amber_rounded
|
||||
: (kIsWeb ? Icons.cached : Icons.system_update),
|
||||
color:
|
||||
isMandatory ? Colors.amber[700] : Colors.blue,
|
||||
size: 32,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Flexible(
|
||||
Expanded(
|
||||
child: Text(
|
||||
kIsWeb
|
||||
? "Aggiornamento"
|
||||
: "Aggiornamento Obbligatorio",
|
||||
style: Theme.of(context).textTheme.titleLarge
|
||||
isMandatory
|
||||
? "Aggiornamento Obbligatorio"
|
||||
: (kIsWeb
|
||||
? "Aggiornamento Disponibile"
|
||||
: "Nuova Versione Disponibile"),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleLarge
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
if (!isMandatory && !_isUpdating)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
tooltip: "Chiudi e rimanda",
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isDismissed = true;
|
||||
_dismissedVersion =
|
||||
updateInfo.latestVersion;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
kIsWeb
|
||||
? "È stata rilasciata una nuova versione dell'applicazione. Ricarica la pagina per scaricare il nuovo codice."
|
||||
: "Per continuare ad utilizzare l'applicazione è necessario scaricare e installare l'ultimo aggiornamento.",
|
||||
? "È stata rilasciata una nuova versione dell'applicazione (${updateInfo.latestVersion}). Ricarica la pagina per scaricare il nuovo codice."
|
||||
: (isMandatory
|
||||
? "La versione attuale non è più supportata (minima richiesta: ${updateInfo.minVersion}). È necessario aggiornare all'ultima versione (${updateInfo.latestVersion}) per continuare a lavorare."
|
||||
: "È disponibile la nuova versione ${updateInfo.latestVersion}. Puoi aggiornare subito oppure rimandare."),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
style: const TextStyle(fontSize: 15),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (kIsWeb)
|
||||
if (_errorMessage != null) ...[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
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,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
if (_isUpdating) ...[
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: LinearProgressIndicator(
|
||||
value: _downloadProgress > 0
|
||||
? _downloadProgress
|
||||
: null,
|
||||
minHeight: 10,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
_statusMessage,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withValues(alpha: 0.7),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
] else if (kIsWeb) ...[
|
||||
FilledButton.icon(
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text("RICARICA ORA"),
|
||||
@@ -375,8 +489,50 @@ class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker>
|
||||
// Hard reload aggirando la cache!
|
||||
html.window.location.reload();
|
||||
},
|
||||
)
|
||||
else
|
||||
),
|
||||
if (!isMandatory) ...[
|
||||
const SizedBox(height: 10),
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
minimumSize: const Size(double.infinity, 44),
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isDismissed = true;
|
||||
_dismissedVersion =
|
||||
updateInfo.latestVersion;
|
||||
});
|
||||
},
|
||||
child: const Text("PIÙ TARDI"),
|
||||
),
|
||||
],
|
||||
] else if (AutoUpdateService.isAutoUpdateSupported) ...[
|
||||
FilledButton.icon(
|
||||
icon: const Icon(Icons.system_update_alt),
|
||||
label: const Text("AGGIORNA ORA"),
|
||||
style: FilledButton.styleFrom(
|
||||
minimumSize: const Size(double.infinity, 50),
|
||||
backgroundColor: Colors.blue,
|
||||
),
|
||||
onPressed: _startAutoUpdate,
|
||||
),
|
||||
if (!isMandatory) ...[
|
||||
const SizedBox(height: 10),
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
minimumSize: const Size(double.infinity, 44),
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isDismissed = true;
|
||||
_dismissedVersion =
|
||||
updateInfo.latestVersion;
|
||||
});
|
||||
},
|
||||
child: const Text("PIÙ TARDI"),
|
||||
),
|
||||
],
|
||||
] else ...[
|
||||
FilledButton.icon(
|
||||
icon: const Icon(Icons.download),
|
||||
label: const Text("SCARICA AGGIORNAMENTO"),
|
||||
@@ -385,15 +541,46 @@ class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker>
|
||||
backgroundColor: Colors.blue,
|
||||
),
|
||||
onPressed: () async {
|
||||
if (_updateUrl != null) {
|
||||
final url = Uri.parse(_updateUrl!);
|
||||
await launchUrl(
|
||||
url,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
}
|
||||
final url = Uri.parse(updateInfo.downloadUrl);
|
||||
await launchUrl(
|
||||
url,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
),
|
||||
if (!isMandatory) ...[
|
||||
const SizedBox(height: 10),
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
minimumSize: const Size(double.infinity, 44),
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isDismissed = true;
|
||||
_dismissedVersion =
|
||||
updateInfo.latestVersion;
|
||||
});
|
||||
},
|
||||
child: const Text("PIÙ TARDI"),
|
||||
),
|
||||
],
|
||||
],
|
||||
if (!_isUpdating &&
|
||||
AutoUpdateService.isAutoUpdateSupported &&
|
||||
_errorMessage != null) ...[
|
||||
const SizedBox(height: 10),
|
||||
TextButton.icon(
|
||||
icon: const Icon(Icons.open_in_browser, size: 16),
|
||||
label: const Text("Scarica manualmente dal browser"),
|
||||
onPressed: () async {
|
||||
final url = Uri.parse(updateInfo.downloadUrl);
|
||||
await launchUrl(
|
||||
url,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -11,6 +11,7 @@ import file_selector_macos
|
||||
import firebase_core
|
||||
import firebase_messaging
|
||||
import package_info_plus
|
||||
import path_provider_foundation
|
||||
import pdfx
|
||||
import printing
|
||||
import shared_preferences_foundation
|
||||
@@ -23,6 +24,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
||||
FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin"))
|
||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
PdfxPlugin.register(with: registry.registrar(forPlugin: "PdfxPlugin"))
|
||||
PrintingPlugin.register(with: registry.registrar(forPlugin: "PrintingPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
|
||||
+13
-53
@@ -137,14 +137,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
code_assets:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: code_assets
|
||||
sha256: bf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
collection:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -469,14 +461,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
hooks:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: hooks
|
||||
sha256: "9a62a50b50b769a737bc0a8ff381f333529df3ab746b2f6b02e83760231455ba"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
html:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -585,10 +569,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: intl
|
||||
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
|
||||
sha256: "1ca20c894b1717686a2319b8548763d812bc0aabdac580420a44c5178c57a867"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.20.2"
|
||||
version: "0.20.3"
|
||||
jni:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -665,10 +649,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
|
||||
sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.19"
|
||||
version: "0.12.20"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -681,10 +665,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
|
||||
sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.18.0"
|
||||
version: "1.19.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -701,14 +685,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
objective_c:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: objective_c
|
||||
sha256: "6cb691c686fa2838c6deb34980d426145c2a5d537491cb83d463c33cdbc726ed"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.4.1"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -774,13 +750,13 @@ packages:
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699"
|
||||
sha256: "6d13aece7b3f5c5a9731eaf553ff9dcbc2eff41087fd2df587fd0fed9a3eb0c4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.0"
|
||||
version: "2.5.1"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -950,14 +926,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.5+1"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pub_semver
|
||||
sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
qr:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -982,14 +950,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.0"
|
||||
record_use:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: record_use
|
||||
sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
retry:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1143,10 +1103,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e"
|
||||
sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.11"
|
||||
version: "0.7.12"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1287,10 +1247,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
|
||||
sha256: "92b9910f66ed1057fd4da7b040ae7c74cafacf885bdc81be496928d5049b032d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
version: "2.4.3"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
+2
-1
@@ -1,7 +1,7 @@
|
||||
name: flux
|
||||
description: "Gestione attività negozio di telefonia"
|
||||
publish_to: 'none'
|
||||
version: 2.0.3+59
|
||||
version: 2.0.8+64
|
||||
|
||||
environment:
|
||||
sdk: ^3.11.3
|
||||
@@ -49,6 +49,7 @@ dependency_overrides:
|
||||
url: https://github.com/ScerIO/packages.flutter.git
|
||||
ref: main
|
||||
path: packages/pdfx
|
||||
path_provider_foundation: 2.5.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
+9
-7
@@ -4,7 +4,7 @@ AppName=Flux
|
||||
AppVersion={#MyAppVersion}
|
||||
VersionInfoVersion={#MyAppVersion}
|
||||
AppPublisher=Catelli
|
||||
DefaultDirName={autopf}\Flux
|
||||
DefaultDirName={autolocalappdata}\Programs\Flux
|
||||
; DefaultGroupName=Programs
|
||||
|
||||
; Cartella di output dell'installer e nome del file generato
|
||||
@@ -16,11 +16,13 @@ Compression=lzma2/max
|
||||
SolidCompression=yes
|
||||
WizardStyle=modern
|
||||
|
||||
; Icona dell'installer (opzionale, decommenta se hai il file .ico)
|
||||
; Icona dell'installer
|
||||
SetupIconFile=windows\runner\resources\app_icon.ico
|
||||
|
||||
; Richiede privilegi di amministratore per installare nella cartella Programmi
|
||||
PrivilegesRequired=admin
|
||||
; Installazione utente (senza richiesta di privilegi amministratore UAC)
|
||||
PrivilegesRequired=lowest
|
||||
PrivilegesRequiredOverridesAllowed=dialog
|
||||
CloseApplications=force
|
||||
|
||||
[Files]
|
||||
; 1. L'eseguibile principale di Flutter
|
||||
@@ -31,12 +33,12 @@ Source: "build\windows\x64\runner\Release\*"; DestDir: "{app}"; Flags: ignorever
|
||||
|
||||
[Icons]
|
||||
; Scorciatoie nel menu Start e sul Desktop
|
||||
Name: "{autoprograms}\LaMiaApp"; Filename: "{app}\Flux.exe"
|
||||
Name: "{autodesktop}\LaMiaApp"; Filename: "{app}\Flux.exe"; Tasks: desktopicon
|
||||
Name: "{autoprograms}\Flux"; Filename: "{app}\Flux.exe"
|
||||
Name: "{autodesktop}\Flux"; Filename: "{app}\Flux.exe"; Tasks: desktopicon
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "Crea un'icona sul &Desktop"; GroupDescription: "Icone aggiuntive:"; Flags: unchecked
|
||||
|
||||
[Run]
|
||||
; Opzione per avviare l'app subito dopo la fine dell'installazione
|
||||
Filename: "{app}\Flux.exe"; Description: "Avvia LaMiaApp"; Flags: nowait postinstall skipifsilent
|
||||
Filename: "{app}\Flux.exe"; Description: "Avvia Flux"; Flags: nowait postinstall
|
||||
Reference in new issue
Block a user