aurcache/frontend/lib/components/confirm_popup.dart
lukas-heiligenbrunner c924a151cb add page for aur search
install aur package by button click
2024-01-27 14:51:45 +01:00

52 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
Future<bool> showConfirmationDialog(
BuildContext context,
String title,
String content,
void Function() successCallback,
void Function()? errorCallback,
) async {
return (await showDialog<bool>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Stack(
children: <Widget>[
GestureDetector(
onTap: () {
Navigator.of(context).pop(false); // Dismiss dialog on outside tap
},
child: Container(
color: Colors.black.withOpacity(0.5), // Adjust opacity for blur
),
),
// Delete confirmation dialog
AlertDialog(
title: Text(title),
content: Text(content),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop(true);
successCallback();
},
child: const Text('Yes'),
),
TextButton(
onPressed: () {
Navigator.of(context).pop(false); // Dismiss dialog
if (errorCallback != null) {
errorCallback();
}
},
child: const Text('Cancel'),
),
],
),
],
);
},
))!;
}