mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-14 10:12:21 -06:00
feat: Update translations, finish saved views rework, some other fixes
This commit is contained in:
31
lib/core/widgets/dialog_utils/pop_with_unsaved_changes.dart
Normal file
31
lib/core/widgets/dialog_utils/pop_with_unsaved_changes.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_mobile/core/widgets/dialog_utils/unsaved_changes_warning_dialog.dart';
|
||||
|
||||
class PopWithUnsavedChanges extends StatelessWidget {
|
||||
final bool Function() hasChangesPredicate;
|
||||
final Widget child;
|
||||
|
||||
const PopWithUnsavedChanges({
|
||||
super.key,
|
||||
required this.hasChangesPredicate,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
if (hasChangesPredicate()) {
|
||||
final shouldPop = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => const UnsavedChangesWarningDialog(),
|
||||
) ??
|
||||
false;
|
||||
return shouldPop;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_cancel_button.dart';
|
||||
import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_confirm_button.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class UnsavedChangesWarningDialog extends StatelessWidget {
|
||||
const UnsavedChangesWarningDialog({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Discard changes?"),
|
||||
content: Text(
|
||||
"You have unsaved changes. Do you want to continue without saving? Your changes will be discarded.",
|
||||
),
|
||||
actions: [
|
||||
DialogCancelButton(),
|
||||
DialogConfirmButton(
|
||||
label: S.of(context)!.continueLabel,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user