2024-01-17 03:28:23 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2022-02-09 12:41:02 -06:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-17 03:28:23 +00:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2024-05-06 23:04:21 -05:00
|
|
|
import 'package:immich_mobile/widgets/common/confirm_dialog.dart';
|
2022-02-09 12:41:02 -06:00
|
|
|
|
2023-05-25 05:52:43 +02:00
|
|
|
class DeleteDialog extends ConfirmDialog {
|
2024-01-27 16:14:32 +00:00
|
|
|
const DeleteDialog({super.key, String? alert, required Function onDelete})
|
2025-07-29 00:34:03 +05:30
|
|
|
: super(
|
|
|
|
|
title: "delete_dialog_title",
|
|
|
|
|
content: alert ?? "delete_dialog_alert",
|
|
|
|
|
cancel: "cancel",
|
|
|
|
|
ok: "delete",
|
|
|
|
|
onOk: onDelete,
|
|
|
|
|
);
|
2022-02-09 12:41:02 -06:00
|
|
|
}
|
2024-01-17 03:28:23 +00:00
|
|
|
|
|
|
|
|
class DeleteLocalOnlyDialog extends StatelessWidget {
|
|
|
|
|
final void Function(bool onlyMerged) onDeleteLocal;
|
|
|
|
|
|
2025-07-29 00:34:03 +05:30
|
|
|
const DeleteLocalOnlyDialog({super.key, required this.onDeleteLocal});
|
2024-01-17 03:28:23 +00:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
void onDeleteBackedUpOnly() {
|
2025-10-14 12:50:14 +05:30
|
|
|
context.pop(true);
|
2024-01-17 03:28:23 +00:00
|
|
|
onDeleteLocal(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onForceDelete() {
|
2025-10-14 12:50:14 +05:30
|
|
|
context.pop(false);
|
2024-01-17 03:28:23 +00:00
|
|
|
onDeleteLocal(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AlertDialog(
|
2025-07-29 00:34:03 +05:30
|
|
|
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
|
2024-01-17 03:28:23 +00:00
|
|
|
title: const Text("delete_dialog_title").tr(),
|
|
|
|
|
content: const Text("delete_dialog_alert_local_non_backed_up").tr(),
|
|
|
|
|
actions: [
|
2025-10-14 12:50:14 +05:30
|
|
|
SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 48,
|
|
|
|
|
child: FilledButton(
|
|
|
|
|
onPressed: () => context.pop(),
|
|
|
|
|
style: FilledButton.styleFrom(
|
|
|
|
|
backgroundColor: context.colorScheme.surfaceDim,
|
|
|
|
|
foregroundColor: context.primaryColor,
|
|
|
|
|
),
|
|
|
|
|
child: const Text("cancel", style: TextStyle(fontWeight: FontWeight.bold)).tr(),
|
|
|
|
|
),
|
2024-01-17 03:28:23 +00:00
|
|
|
),
|
2025-10-14 12:50:14 +05:30
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 48,
|
|
|
|
|
|
|
|
|
|
child: FilledButton(
|
|
|
|
|
onPressed: onDeleteBackedUpOnly,
|
|
|
|
|
style: FilledButton.styleFrom(
|
|
|
|
|
backgroundColor: context.colorScheme.errorContainer,
|
|
|
|
|
foregroundColor: context.colorScheme.onErrorContainer,
|
|
|
|
|
),
|
|
|
|
|
child: const Text(
|
|
|
|
|
"delete_local_dialog_ok_backed_up_only",
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
|
).tr(),
|
|
|
|
|
),
|
2024-01-17 03:28:23 +00:00
|
|
|
),
|
2025-10-14 12:50:14 +05:30
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 48,
|
|
|
|
|
child: FilledButton(
|
|
|
|
|
onPressed: onForceDelete,
|
|
|
|
|
style: FilledButton.styleFrom(backgroundColor: Colors.red[400], foregroundColor: Colors.white),
|
|
|
|
|
child: const Text("delete_local_dialog_ok_force", style: TextStyle(fontWeight: FontWeight.bold)).tr(),
|
|
|
|
|
),
|
2024-01-17 03:28:23 +00:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|