Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.0.13
* added automatic closing of native dialog.

## 0.0.12
* Updated dependencies
* Added test_util: catch presentation event helper, DeviceSizes
Expand Down
24 changes: 19 additions & 5 deletions lib/ui/native_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ void showNativeDialog(
showCupertinoDialog<void>(
context: context,
builder:
(context) => CupertinoAlertDialog(
(dialogContext) => CupertinoAlertDialog(
title: Text(title),
content: Text(content),
actions:
actions
.map(
(action) => CupertinoDialogAction(
onPressed: action.onTap,
onPressed: () {
action.onTap();
Navigator.of(dialogContext).pop();
},
isDestructiveAction: action.isDestructiveAction,
child: Text(action.text),
),
Expand All @@ -44,16 +47,27 @@ void showNativeDialog(
showDialog<void>(
context: context,
builder:
(context) => AlertDialog(
(dialogContext) => AlertDialog(
title: Text(title),
content: Text(content),
actions: actions.map((action) => TextButton(onPressed: action.onTap, child: Text(action.text))).toList(),
actions:
actions
.map(
(action) => TextButton(
onPressed: () {
action.onTap();
Navigator.of(dialogContext).pop();
},
child: Text(action.text),
),
)
.toList(),
),
);
}
}

/// A dialog action which is used to show the actions of a native dialog.
/// A dialog action which is used to show the actions of a native dialog. Tapping a action will also close the dialog.
class DialogAction {
/// Creates a [DialogAction].
const DialogAction({required this.text, required this.onTap, this.isDestructiveAction = false});
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dcc_toolkit
description: "Internal toolkit package used by the DCC team."
version: 0.0.12
version: 0.0.13
homepage: https://dutchcodingcompany.com
repository: https://github.com/DutchCodingCompany/dcc_toolkit

Expand Down