2023-05-25 05:52:43 +02:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
|
|
|
|
class ConfirmDialog extends ConsumerWidget {
|
|
|
|
final Function onOk;
|
|
|
|
final String title;
|
|
|
|
final String content;
|
|
|
|
final String cancel;
|
|
|
|
final String ok;
|
|
|
|
|
|
|
|
const ConfirmDialog({
|
|
|
|
Key? key,
|
|
|
|
required this.onOk,
|
|
|
|
required this.title,
|
|
|
|
required this.content,
|
|
|
|
this.cancel = "delete_dialog_cancel",
|
|
|
|
this.ok = "backup_controller_page_background_battery_info_ok",
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
return AlertDialog(
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
|
|
title: Text(title).tr(),
|
|
|
|
content: Text(content).tr(),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
2023-08-27 07:07:35 +02:00
|
|
|
onPressed: () => Navigator.of(context).pop(false),
|
2023-05-25 05:52:43 +02:00
|
|
|
child: Text(
|
|
|
|
cancel,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
).tr(),
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
onOk();
|
2023-08-27 07:07:35 +02:00
|
|
|
Navigator.of(context).pop(true);
|
2023-05-25 05:52:43 +02:00
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
ok,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.red[400],
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
).tr(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|