diff --git a/mobile/lib/screens/account_settings.dart b/mobile/lib/screens/account_settings.dart index a51e4c7..449a050 100644 --- a/mobile/lib/screens/account_settings.dart +++ b/mobile/lib/screens/account_settings.dart @@ -42,12 +42,16 @@ class _AccountSettingsScreenState extends State { } Future _setCredentials(MusicusAccountCredentials credentials) async { - if (credentials != null) { - if (mounted) { + if (mounted) { + if (credentials != null) { setState(() { _loggedIn = true; _username = credentials.username; }); + } else { + setState(() { + _loggedIn = false; + }); } } } @@ -108,6 +112,36 @@ class _AccountSettingsScreenState extends State { ); }, ), + ListTile( + title: Text('Delete this account'), + onTap: () async { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Delete account'), + content: Text( + 'Do you really want to delete the account with the ' + 'username $_username?'), + actions: [ + FlatButton( + child: Text('DELETE'), + onPressed: () async { + await _backend.client.deleteAccount(); + await _backend.settings.clearAccount(); + Navigator.pop(context); + }, + ), + FlatButton( + child: Text('CANCEL'), + onPressed: () { + Navigator.pop(context); + }, + ), + ], + ), + ); + }, + ), ListTile( title: Text('Logout'), onTap: () async {