Feature: Jederzeit von 'nur lokal' auf Cloud wechseln + Abmelden-Fix
- Profil-Dialog: 'Cloud aktivieren' erscheint im Lokal-Modus -> setzt Modus + Login - Abmelden loescht jetzt wirklich das Token (CloudService.logout) - _zeigeProfil liest Modus vor dem Dialog
This commit is contained in:
@@ -103,7 +103,10 @@ class _MeloHomeState extends State<MeloHome> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _zeigeProfil() {
|
Future<void> _zeigeProfil() async {
|
||||||
|
final p = await SharedPreferences.getInstance();
|
||||||
|
final modus = p.getString('melo_modus') ?? 'cloud';
|
||||||
|
if (!mounted) return;
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) => AlertDialog(
|
builder: (ctx) => AlertDialog(
|
||||||
@@ -119,6 +122,23 @@ class _MeloHomeState extends State<MeloHome> {
|
|||||||
_profilZeile(Icons.music_note, 'Lieder auf Gerät', '${_vm.songs.length}'),
|
_profilZeile(Icons.music_note, 'Lieder auf Gerät', '${_vm.songs.length}'),
|
||||||
_profilZeile(Icons.cloud, 'Cloud-Server', '${_cloud.status().then((s) => s?['total'] ?? 0)}'),
|
_profilZeile(Icons.cloud, 'Cloud-Server', '${_cloud.status().then((s) => s?['total'] ?? 0)}'),
|
||||||
const Divider(color: MeloTheme.dunkel2),
|
const Divider(color: MeloTheme.dunkel2),
|
||||||
|
// Später von "nur lokal" auf Cloud wechseln – jederzeit möglich
|
||||||
|
if (modus == 'lokal') ...[
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.cloud_upload, color: Colors.blueAccent, size: 18),
|
||||||
|
title: const Text('☁️ Cloud aktivieren',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 13)),
|
||||||
|
subtitle: const Text('Musik sichern & geräteübergreifend nutzen',
|
||||||
|
style: TextStyle(color: Colors.grey, fontSize: 11)),
|
||||||
|
onTap: () async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.setString('melo_modus', 'cloud');
|
||||||
|
if (ctx.mounted) Navigator.pop(ctx);
|
||||||
|
_nutzerWechseln();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(color: MeloTheme.dunkel2),
|
||||||
|
],
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.swap_horiz, color: Colors.grey, size: 18),
|
leading: const Icon(Icons.swap_horiz, color: Colors.grey, size: 18),
|
||||||
title: const Text('Nutzer wechseln', style: TextStyle(color: Colors.white, fontSize: 13)),
|
title: const Text('Nutzer wechseln', style: TextStyle(color: Colors.white, fontSize: 13)),
|
||||||
@@ -131,10 +151,12 @@ class _MeloHomeState extends State<MeloHome> {
|
|||||||
leading: const Icon(Icons.logout, color: Colors.red, size: 18),
|
leading: const Icon(Icons.logout, color: Colors.red, size: 18),
|
||||||
title: const Text('Abmelden', style: TextStyle(color: Colors.red, fontSize: 13)),
|
title: const Text('Abmelden', style: TextStyle(color: Colors.red, fontSize: 13)),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final p = await SharedPreferences.getInstance();
|
// Token wirklich löschen, sonst wäre man gar nicht abgemeldet
|
||||||
await p.remove('melo_nutzer');
|
await CloudService().logout();
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.remove('melo_nutzer');
|
||||||
if (ctx.mounted) Navigator.pop(ctx);
|
if (ctx.mounted) Navigator.pop(ctx);
|
||||||
setState(() => _nutzer = '');
|
if (mounted) setState(() => _nutzer = '');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user