diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 2482583..3b20dbc 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -51,6 +51,11 @@ class _MeloHomeState extends State { setState(() => _nutzer = n); _vm.setzeNutzer(n); } + // Erster Start? → einmalig Modus wählen (Cloud oder nur lokal) – Login ist freiwillig + if (!p.containsKey('melo_modus')) { + await _zeigeModusWahl(); + return; + } // Login-Effekt beim App-Start: nur wenn ein Token vorhanden ist (eingeloggt) final ok = await CloudService().restoreLogin(); if (ok && mounted) { @@ -62,6 +67,42 @@ class _MeloHomeState extends State { } } + /// Einmalige Auswahl beim ersten App-Start: Cloud-Sync oder nur lokal. + Future _zeigeModusWahl() async { + if (!mounted) return; + final cloud = await showDialog( + context: context, + barrierDismissible: false, + builder: (ctx) => AlertDialog( + backgroundColor: MeloTheme.dunkel1, + title: const Text('👋 Willkommen bei Melo!', + style: TextStyle(color: Colors.white, fontSize: 16)), + content: const Text( + 'Wie möchtest du Melo nutzen?', + style: TextStyle(color: Colors.white, fontSize: 14), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(ctx, false), + child: const Text('📱 Nur lokal', + style: TextStyle(color: Colors.white)), + ), + TextButton( + onPressed: () => Navigator.pop(ctx, true), + child: const Text('☁️ Cloud (empfohlen)', + style: TextStyle(color: MeloTheme.rot, fontWeight: FontWeight.bold)), + ), + ], + ), + ); + final p = await SharedPreferences.getInstance(); + await p.setString('melo_modus', cloud == true ? 'cloud' : 'lokal'); + // Cloud gewählt → direkt zum Login-Dialog (Name + Passwort) + if (cloud == true && mounted) { + _nutzerWechseln(); + } + } + void _zeigeProfil() { showDialog( context: context,