delete button only for existing profiles
This commit is contained in:
@@ -115,60 +115,60 @@ class ProfileEditScreen extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
const SizedBox(height: 16),
|
||||||
const SizedBox(height: 16),
|
SizedBox(
|
||||||
SizedBox(
|
width: double.infinity,
|
||||||
width: double.infinity,
|
child: OutlinedButton.icon(
|
||||||
child: OutlinedButton.icon(
|
style: OutlinedButton.styleFrom(
|
||||||
style: OutlinedButton.styleFrom(
|
side: BorderSide(
|
||||||
side: BorderSide(
|
color: Theme.of(context).colorScheme.error,
|
||||||
color: Theme.of(context).colorScheme.error,
|
),
|
||||||
|
foregroundColor: Theme.of(context).colorScheme.error,
|
||||||
|
iconColor: Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
foregroundColor: Theme.of(context).colorScheme.error,
|
label: const Text('Delete'),
|
||||||
iconColor: Theme.of(context).colorScheme.error,
|
icon: const Icon(Icons.delete),
|
||||||
),
|
onPressed: () async {
|
||||||
label: const Text('Delete'),
|
final result = await showDialog<bool?>(
|
||||||
icon: const Icon(Icons.delete),
|
context: context,
|
||||||
onPressed: () async {
|
builder: (BuildContext context) {
|
||||||
final result = await showDialog<bool?>(
|
return AlertDialog(
|
||||||
context: context,
|
icon: const Icon(Icons.warning),
|
||||||
builder: (BuildContext context) {
|
title: const Text('Delete User'),
|
||||||
return AlertDialog(
|
content: const Text(
|
||||||
icon: const Icon(Icons.warning),
|
'Are you sure you want to delete this User including all data?',
|
||||||
title: const Text('Delete User'),
|
|
||||||
content: const Text(
|
|
||||||
'Are you sure you want to delete this User including all data?',
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, false);
|
|
||||||
},
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
),
|
),
|
||||||
TextButton(
|
actions: <Widget>[
|
||||||
onPressed: () {
|
TextButton(
|
||||||
Navigator.pop(context, true);
|
onPressed: () {
|
||||||
},
|
Navigator.pop(context, false);
|
||||||
child: const Text('Delete'),
|
},
|
||||||
),
|
child: const Text('Cancel'),
|
||||||
],
|
),
|
||||||
);
|
TextButton(
|
||||||
},
|
onPressed: () {
|
||||||
);
|
Navigator.pop(context, true);
|
||||||
|
},
|
||||||
|
child: const Text('Delete'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
await ref
|
await ref
|
||||||
.read(profileRepositoryProvider.notifier)
|
.read(profileRepositoryProvider.notifier)
|
||||||
.deleteProfile(profile!.uuidValue.uuid);
|
.deleteProfile(profile!.uuidValue.uuid);
|
||||||
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
context.pop();
|
context.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user