Skip to content

Commit f7699f2

Browse files
committed
Add OkCancelDialog widget
1 parent 0ddecf2 commit f7699f2

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

lib/widgets/dialog_ok_cancel.dart

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import 'package:apidash/consts.dart';
2+
import 'package:apidash_design_system/apidash_design_system.dart';
3+
import 'package:flutter/material.dart';
4+
5+
showOkCancelDialog(
6+
BuildContext context, {
7+
String? dialogTitle,
8+
String? content,
9+
String? buttonLabelOk,
10+
VoidCallback? onClickOk,
11+
String? buttonLabelCancel,
12+
VoidCallback? onClickCancel,
13+
}) {
14+
showDialog(
15+
context: context,
16+
builder: (context) {
17+
return AlertDialog(
18+
title: Text(dialogTitle ?? ""),
19+
titleTextStyle: Theme.of(context).textTheme.titleLarge,
20+
content: Container(
21+
padding: kPt20,
22+
width: 300,
23+
child: Text(content ?? ""),
24+
),
25+
actions: <Widget>[
26+
TextButton(
27+
onPressed: () {
28+
onClickCancel?.call();
29+
if (context.mounted) {
30+
Navigator.pop(context);
31+
}
32+
},
33+
child: Text(buttonLabelCancel ?? kLabelCancel),
34+
),
35+
TextButton(
36+
onPressed: () {
37+
onClickOk?.call();
38+
if (context.mounted) {
39+
Navigator.pop(context);
40+
}
41+
},
42+
child: Text(buttonLabelOk ?? kLabelOk),
43+
),
44+
],
45+
);
46+
});
47+
}

lib/widgets/widgets.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export 'codegen_previewer.dart';
1616
export 'dialog_about.dart';
1717
export 'dialog_history_retention.dart';
1818
export 'dialog_import.dart';
19+
export 'dialog_ok_cancel.dart';
1920
export 'dialog_rename.dart';
2021
export 'dialog_text.dart';
2122
export 'drag_and_drop_area.dart';

0 commit comments

Comments
 (0)