ask before deleting image

This commit is contained in:
otsmr 2025-11-09 23:32:46 +01:00
parent bc2c998850
commit 6d86af155c
7 changed files with 216 additions and 138 deletions

View file

@ -818,5 +818,7 @@
"deleteChatAfterAMonth": "einem Monat.", "deleteChatAfterAMonth": "einem Monat.",
"deleteChatAfterAYear": "einem Jahr.", "deleteChatAfterAYear": "einem Jahr.",
"yourTwonlyScore": "Dein twonly-Score", "yourTwonlyScore": "Dein twonly-Score",
"registrationClosed": "Aufgrund des aktuell sehr hohen Aufkommens haben wir die Registrierung vorübergehend deaktiviert, damit der Dienst zuverlässig bleibt. Bitte versuche es in ein paar Tagen noch einmal." "registrationClosed": "Aufgrund des aktuell sehr hohen Aufkommens haben wir die Registrierung vorübergehend deaktiviert, damit der Dienst zuverlässig bleibt. Bitte versuche es in ein paar Tagen noch einmal.",
"dialogAskDeleteMediaFilePopTitle": "Bist du sicher, dass du dein Meisterwerk löschen möchtest?",
"dialogAskDeleteMediaFilePopDelete": "Löschen"
} }

View file

@ -596,5 +596,7 @@
"deleteChatAfterAMonth": "one month.", "deleteChatAfterAMonth": "one month.",
"deleteChatAfterAYear": "one year.", "deleteChatAfterAYear": "one year.",
"yourTwonlyScore": "Your twonly-Score", "yourTwonlyScore": "Your twonly-Score",
"registrationClosed": "Due to the current high volume of registrations, we have temporarily disabled registration to ensure that the service remains reliable. Please try again in a few days." "registrationClosed": "Due to the current high volume of registrations, we have temporarily disabled registration to ensure that the service remains reliable. Please try again in a few days.",
"dialogAskDeleteMediaFilePopTitle": "Are you sure you want to delete your masterpiece?",
"dialogAskDeleteMediaFilePopDelete": "Delete"
} }

View file

@ -2683,6 +2683,18 @@ abstract class AppLocalizations {
/// In en, this message translates to: /// In en, this message translates to:
/// **'Due to the current high volume of registrations, we have temporarily disabled registration to ensure that the service remains reliable. Please try again in a few days.'** /// **'Due to the current high volume of registrations, we have temporarily disabled registration to ensure that the service remains reliable. Please try again in a few days.'**
String get registrationClosed; String get registrationClosed;
/// No description provided for @dialogAskDeleteMediaFilePopTitle.
///
/// In en, this message translates to:
/// **'Are you sure you want to delete your masterpiece?'**
String get dialogAskDeleteMediaFilePopTitle;
/// No description provided for @dialogAskDeleteMediaFilePopDelete.
///
/// In en, this message translates to:
/// **'Delete'**
String get dialogAskDeleteMediaFilePopDelete;
} }
class _AppLocalizationsDelegate class _AppLocalizationsDelegate

View file

@ -1481,4 +1481,11 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get registrationClosed => String get registrationClosed =>
'Aufgrund des aktuell sehr hohen Aufkommens haben wir die Registrierung vorübergehend deaktiviert, damit der Dienst zuverlässig bleibt. Bitte versuche es in ein paar Tagen noch einmal.'; 'Aufgrund des aktuell sehr hohen Aufkommens haben wir die Registrierung vorübergehend deaktiviert, damit der Dienst zuverlässig bleibt. Bitte versuche es in ein paar Tagen noch einmal.';
@override
String get dialogAskDeleteMediaFilePopTitle =>
'Bist du sicher, dass du dein Meisterwerk löschen möchtest?';
@override
String get dialogAskDeleteMediaFilePopDelete => 'Löschen';
} }

View file

@ -1471,4 +1471,11 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get registrationClosed => String get registrationClosed =>
'Due to the current high volume of registrations, we have temporarily disabled registration to ensure that the service remains reliable. Please try again in a few days.'; 'Due to the current high volume of registrations, we have temporarily disabled registration to ensure that the service remains reliable. Please try again in a few days.';
@override
String get dialogAskDeleteMediaFilePopTitle =>
'Are you sure you want to delete your masterpiece?';
@override
String get dialogAskDeleteMediaFilePopDelete => 'Delete';
} }

View file

@ -75,7 +75,7 @@ class _FilterLayerState extends State<FilterLayer> {
List<Widget> pages = [ List<Widget> pages = [
const FilterSkeleton(), const FilterSkeleton(),
const DateTimeFilter(), const DateTimeFilter(),
const LocationFilter(), // const LocationFilter(),
const FilterSkeleton(), const FilterSkeleton(),
]; ];

View file

@ -264,6 +264,40 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
]; ];
} }
Future<bool?> _showBackDialog() {
return showDialog<bool>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(
context.lang.dialogAskDeleteMediaFilePopTitle,
),
actions: [
FilledButton(
child: Text(context.lang.dialogAskDeleteMediaFilePopDelete),
onPressed: () {
Navigator.pop(context, true);
},
),
TextButton(
child: Text(context.lang.cancel),
onPressed: () {
Navigator.pop(context, false);
},
),
],
);
},
);
}
Future<void> askToCloseThenClose() async {
final shouldPop = await _showBackDialog() ?? false;
if (mounted && shouldPop) {
Navigator.pop(context);
}
}
List<Widget> get actionsAtTheTop { List<Widget> get actionsAtTheTop {
if (layers.isNotEmpty && if (layers.isNotEmpty &&
layers.last.isEditing && layers.last.isEditing &&
@ -275,7 +309,14 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
FontAwesomeIcons.xmark, FontAwesomeIcons.xmark,
tooltipText: context.lang.close, tooltipText: context.lang.close,
onPressed: () async { onPressed: () async {
final nonImageFilterLayer = layers.where(
(x) => x is! BackgroundLayerData && x is! FilterLayerData,
);
if (nonImageFilterLayer.isEmpty) {
Navigator.pop(context, false); Navigator.pop(context, false);
} else {
await askToCloseThenClose();
}
}, },
), ),
Expanded(child: Container()), Expanded(child: Container()),
@ -446,7 +487,13 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
pixelRatio = MediaQuery.of(context).devicePixelRatio; pixelRatio = MediaQuery.of(context).devicePixelRatio;
return Scaffold( return PopScope<bool?>(
canPop: false,
onPopInvokedWithResult: (bool didPop, bool? result) async {
if (didPop) return;
await askToCloseThenClose();
},
child: Scaffold(
backgroundColor: backgroundColor:
widget.sharedFromGallery ? null : Colors.white.withAlpha(0), widget.sharedFromGallery ? null : Colors.white.withAlpha(0),
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
@ -595,6 +642,7 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
), ),
], ],
), ),
),
); );
} }
} }