mobile: Allow account deletion

This commit is contained in:
Elias Projahn 2020-05-13 17:42:04 +02:00
parent 95b3e9b00d
commit 0e10edb87f

View file

@ -42,12 +42,16 @@ class _AccountSettingsScreenState extends State<AccountSettingsScreen> {
}
Future<void> _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<AccountSettingsScreen> {
);
},
),
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: <Widget>[
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 {