mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Move more code from mobile to common
This commit is contained in:
parent
2e4f69a178
commit
5312bad52d
28 changed files with 258 additions and 215 deletions
|
|
@ -1,96 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:musicus_common/musicus_common.dart';
|
||||
|
||||
class DeleteAccountScreen extends StatefulWidget {
|
||||
@override
|
||||
_DeleteAccountScreenState createState() => _DeleteAccountScreenState();
|
||||
}
|
||||
|
||||
class _DeleteAccountScreenState extends State<DeleteAccountScreen> {
|
||||
final _passwordController = TextEditingController();
|
||||
|
||||
bool _loading = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Delete account'),
|
||||
actions: <Widget>[
|
||||
Builder(
|
||||
builder: (context) {
|
||||
if (_loading) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return FlatButton(
|
||||
onPressed: () async {
|
||||
final backend = MusicusBackend.of(context);
|
||||
|
||||
if (_passwordController.text ==
|
||||
backend.settings.account.value.password) {
|
||||
setState(() {
|
||||
_loading = true;
|
||||
});
|
||||
|
||||
await backend.client.deleteAccount();
|
||||
await backend.settings.clearAccount();
|
||||
|
||||
setState(() {
|
||||
_loading = false;
|
||||
});
|
||||
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Wrong password'),
|
||||
));
|
||||
}
|
||||
},
|
||||
child: Text('DELETE'),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 16.0,
|
||||
right: 16.0,
|
||||
top: 16.0,
|
||||
bottom: 8.0,
|
||||
),
|
||||
child: Text(
|
||||
'If you really want to delete your account, enter your password '
|
||||
'below.',
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: TextField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue