adding dialog box before delete a hub
This commit is contained in:
@@ -95,10 +95,10 @@ class ClientHubsPage extends StatelessWidget {
|
||||
).add(
|
||||
ClientHubsIdentifyDialogToggled(hub: hub),
|
||||
),
|
||||
onDeletePressed: () =>
|
||||
BlocProvider.of<ClientHubsBloc>(
|
||||
context,
|
||||
).add(ClientHubsDeleteRequested(hub.id)),
|
||||
onDeletePressed: () => _confirmDeleteHub(
|
||||
context,
|
||||
hub,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -221,4 +221,51 @@ class ClientHubsPage extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _confirmDeleteHub(BuildContext context, Hub hub) async {
|
||||
final String hubName = hub.name.isEmpty ? 'this hub' : hub.name;
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Hub Deletion'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text('Are you sure you want to delete "$hubName"?'),
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
const Text('This action cannot be undone.'),
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
Text(
|
||||
'Note that if there are any shifts/orders assigned to this hub we shouldn\'t be able to delete the hub.',
|
||||
style: UiTypography.footnote1r.copyWith(
|
||||
color: UiColors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
BlocProvider.of<ClientHubsBloc>(
|
||||
context,
|
||||
).add(ClientHubsDeleteRequested(hub.id));
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: UiColors.destructive,
|
||||
),
|
||||
child: const Text('Delete'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user