mirror of
https://github.com/foss42/apidash.git
synced 2025-05-31 06:08:09 +08:00
Add OkCancelDialog widget
This commit is contained in:
47
lib/widgets/dialog_ok_cancel.dart
Normal file
47
lib/widgets/dialog_ok_cancel.dart
Normal file
@ -0,0 +1,47 @@
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
showOkCancelDialog(
|
||||
BuildContext context, {
|
||||
String? dialogTitle,
|
||||
String? content,
|
||||
String? buttonLabelOk,
|
||||
VoidCallback? onClickOk,
|
||||
String? buttonLabelCancel,
|
||||
VoidCallback? onClickCancel,
|
||||
}) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(dialogTitle ?? ""),
|
||||
titleTextStyle: Theme.of(context).textTheme.titleLarge,
|
||||
content: Container(
|
||||
padding: kPt20,
|
||||
width: 300,
|
||||
child: Text(content ?? ""),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
onClickCancel?.call();
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
child: Text(buttonLabelCancel ?? kLabelCancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
onClickOk?.call();
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
child: Text(buttonLabelOk ?? kLabelOk),
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
@ -16,6 +16,7 @@ export 'codegen_previewer.dart';
|
||||
export 'dialog_about.dart';
|
||||
export 'dialog_history_retention.dart';
|
||||
export 'dialog_import.dart';
|
||||
export 'dialog_ok_cancel.dart';
|
||||
export 'dialog_rename.dart';
|
||||
export 'dialog_text.dart';
|
||||
export 'drag_and_drop_area.dart';
|
||||
|
Reference in New Issue
Block a user