Files
stream-chat-flutter/packages/stream_chat_flutter/lib/src/dialogs/confirmation_dialog.dart
T
08295e5290 docs: v5 (#1341)
* feat: version docs and add stream_member_list_controller docs

* feat: add member list and grid doc

* exported extensions on ui package

* feat: add first version of v5 migration guide

* docs: grammar fixes and other v5 release details

* docs: add additional v5 migration info

* update WrapAttachmentWidget doc

* add back v4 migration guide

* docs(doc): add customize_attachment_picker_modal.mdx guide. (#1343)

Signed-off-by: xsahil03x <[email protected]>

Signed-off-by: xsahil03x <[email protected]>

* update link for attachment picker guide

* update share_plus

Signed-off-by: xsahil03x <[email protected]>
Co-authored-by: Gordon Hayes <[email protected]>
Co-authored-by: Sahil Kumar <[email protected]>
2022-10-05 17:08:45 +02:00

61 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// /// {@template confirmationDialog}
/// A dialog that prompts the user to take an action or cancel.
/// {@endtemplate}
class ConfirmationDialog extends StatelessWidget {
/// {@macro confirmationDialog}
const ConfirmationDialog({
super.key,
required this.titleText,
required this.promptText,
required this.affirmativeText,
required this.onConfirmation,
});
/// The text to use for the dialog title.
final String titleText;
/// The text to use for the dialog prompt.
final String promptText;
/// The text to use for the confirmation button.
final String affirmativeText;
/// The action to perform when the user confirms their choice.
final VoidCallback onConfirmation;
@override
Widget build(BuildContext context) {
final streamTheme = StreamChatTheme.of(context);
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
backgroundColor: streamTheme.colorTheme.appBg,
title: Text(titleText),
content: Text(promptText),
actions: [
TextButton(
style: TextButton.styleFrom(
foregroundColor: streamTheme.colorTheme.accentPrimary,
),
onPressed: () => Navigator.of(context).pop(false),
child: Text(context.translations.cancelLabel),
),
TextButton(
style: TextButton.styleFrom(
foregroundColor: streamTheme.colorTheme.accentPrimary,
),
onPressed: () {
onConfirmation.call();
Navigator.of(context).pop(true);
},
child: Text(affirmativeText),
),
],
);
}
}