2024-01-17 05:28:23 +02:00
|
|
|
// ignore_for_file: prefer-single-widget-per-file
|
|
|
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2022-02-09 20:41:02 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-17 05:28:23 +02:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2023-05-25 05:52:43 +02:00
|
|
|
import 'package:immich_mobile/shared/ui/confirm_dialog.dart';
|
2022-02-09 20:41:02 +02:00
|
|
|
|
2023-05-25 05:52:43 +02:00
|
|
|
class DeleteDialog extends ConfirmDialog {
|
2024-01-17 05:28:23 +02:00
|
|
|
const DeleteDialog({Key? key, String? alert, required Function onDelete})
|
2023-05-25 05:52:43 +02:00
|
|
|
: super(
|
|
|
|
key: key,
|
|
|
|
title: "delete_dialog_title",
|
2024-01-17 05:28:23 +02:00
|
|
|
content: alert ?? "delete_dialog_alert",
|
2023-05-25 05:52:43 +02:00
|
|
|
cancel: "delete_dialog_cancel",
|
|
|
|
ok: "delete_dialog_ok",
|
|
|
|
onOk: onDelete,
|
|
|
|
);
|
2022-02-09 20:41:02 +02:00
|
|
|
}
|
2024-01-17 05:28:23 +02:00
|
|
|
|
|
|
|
class DeleteLocalOnlyDialog extends StatelessWidget {
|
|
|
|
final void Function(bool onlyMerged) onDeleteLocal;
|
|
|
|
|
|
|
|
const DeleteLocalOnlyDialog({
|
|
|
|
super.key,
|
|
|
|
required this.onDeleteLocal,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
void onDeleteBackedUpOnly() {
|
|
|
|
context.pop();
|
|
|
|
onDeleteLocal(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void onForceDelete() {
|
|
|
|
context.pop();
|
|
|
|
onDeleteLocal(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return AlertDialog(
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
|
|
|
),
|
|
|
|
title: const Text("delete_dialog_title").tr(),
|
|
|
|
content: const Text("delete_dialog_alert_local_non_backed_up").tr(),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => context.pop(),
|
|
|
|
child: Text(
|
|
|
|
"delete_dialog_cancel",
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
).tr(),
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
onPressed: onDeleteBackedUpOnly,
|
|
|
|
child: Text(
|
|
|
|
"delete_local_dialog_ok_backed_up_only",
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colorScheme.tertiary,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
).tr(),
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
onPressed: onForceDelete,
|
|
|
|
child: Text(
|
|
|
|
"delete_local_dialog_ok_force",
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.red[400],
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
).tr(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|