feat: Update-Hinweis beim App-Start
Ruft /static/downloads/version.txt vom konfigurierten Server ab und
vergleicht gegen kAppVersion. Bei Abweichung Hinweis-Banner auf HomeScreen
("Neue Version X verfügbar, installiert: Y"). Rein informativ, kein
Auto-Update (APK-Sideloading, kein Play-Store-Mechanismus verfügbar).
Fehler beim Check (offline, Server down) werden stillschweigend ignoriert.
v0.1.5+6.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dzdm3EWeNdYFUuXFRJryA1
This commit is contained in:
1 parent
bcf179e06f
commit
46cdcececd
4 files changed
+56
-2
No files matched your search
@@ -1,4 +1,4 @@
|
||||
/// Manuell mit `pubspec.yaml` synchron halten (kein package_info_plus, um
|
||||
/// keine zusätzliche Native-Plugin-Fläche in dieser Debugging-Phase
|
||||
/// einzuführen). Bei jedem Release beide Stellen bumpen.
|
||||
const String kAppVersion = '0.1.4+5';
|
||||
const String kAppVersion = '0.1.5+6';
|
||||
@@ -6,6 +6,7 @@ import '../app_version.dart';
|
||||
import '../models/time_entry.dart';
|
||||
import '../services/auth_service.dart';
|
||||
import '../services/time_service.dart';
|
||||
import '../services/update_check_service.dart';
|
||||
import 'login_screen.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
@@ -24,6 +25,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
TimeEntry? _openEntry;
|
||||
String? _error;
|
||||
Timer? _ticker;
|
||||
String? _newerVersion;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -32,6 +34,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
_ticker = Timer.periodic(const Duration(seconds: 1), (_) {
|
||||
if (_openEntry != null) setState(() {});
|
||||
});
|
||||
UpdateCheckService().checkForNewerVersion().then((v) {
|
||||
if (mounted && v != null) setState(() => _newerVersion = v);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -161,6 +166,26 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
: ListView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
children: [
|
||||
if (_newerVersion != null)
|
||||
Card(
|
||||
color: Colors.blue[50],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.system_update, color: Colors.blue),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Neue Version $_newerVersion verfügbar (installiert: $kAppVersion). '
|
||||
'Im Portal unter Profil herunterladen.',
|
||||
style: const TextStyle(color: Colors.blue),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_error != null)
|
||||
Card(
|
||||
color: Colors.red[50],
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../app_version.dart';
|
||||
import 'api_client.dart';
|
||||
|
||||
/// Prüft `/static/downloads/version.txt` auf dem konfigurierten Server gegen
|
||||
/// die eigene kAppVersion. Rein informativ – kein Erzwingen, kein Auto-Update
|
||||
/// (APK-Sideloading, kein Play Store). Fehler beim Check sind egal (offline,
|
||||
/// Server down) – dann einfach kein Hinweis.
|
||||
class UpdateCheckService {
|
||||
Future<String?> checkForNewerVersion() async {
|
||||
try {
|
||||
final apiBase = ApiClient.instance.baseUrl; // endet auf .../api/v1
|
||||
final origin = apiBase.replaceFirst(RegExp(r'/api/v1/?$'), '');
|
||||
final response = await Dio(BaseOptions(
|
||||
baseUrl: origin,
|
||||
connectTimeout: const Duration(seconds: 5),
|
||||
receiveTimeout: const Duration(seconds: 5),
|
||||
)).get<String>('/static/downloads/version.txt');
|
||||
|
||||
final remote = (response.data ?? '').trim();
|
||||
if (remote.isEmpty || remote == kAppVersion) return null;
|
||||
return remote;
|
||||
} on DioException {
|
||||
return null;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: timemaster_mobile
|
||||
description: TimeMaster Zeiterfassung – Employee App
|
||||
publish_to: 'none'
|
||||
version: 0.1.4+5
|
||||
version: 0.1.5+6
|
||||
|
||||
environment:
|
||||
sdk: '>=3.3.0 <4.0.0'
|
||||
|
||||
Reference in new issue
Block a user