3da8ccc4d3
Sposta la logica del dialog in lib/shared/widgets/update_dialog.dart per renderla importabile nei test senza duplicare il codice. Estrae parseTagName come metodo @visibleForTesting in UpdateService isolando il parsing JSON dalla chiamata HTTP. app.dart semplificato di conseguenza. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
931 B
Dart
32 lines
931 B
Dart
import 'package:flutter/material.dart';
|
|
import '../services/url_launcher_service.dart';
|
|
|
|
const _releasesUrl = 'https://github.com/davide3011/biteplan/releases/latest';
|
|
|
|
void showUpdateDialog(BuildContext context, String newVersion) {
|
|
showDialog<void>(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
icon: const Icon(Icons.system_update_outlined, size: 32),
|
|
title: const Text('Aggiornamento disponibile'),
|
|
content: Text(
|
|
'È disponibile la versione $newVersion di BitePlan.\n'
|
|
'Vuoi scaricare il nuovo APK?',
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(ctx).pop(),
|
|
child: const Text('Più tardi'),
|
|
),
|
|
FilledButton(
|
|
onPressed: () {
|
|
Navigator.of(ctx).pop();
|
|
UrlLauncherService.launch(_releasesUrl);
|
|
},
|
|
child: const Text('Scarica'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|