diff --git a/lib/src/components/banners.dart b/lib/src/components/banners.dart index 98f6994e..4623703e 100644 --- a/lib/src/components/banners.dart +++ b/lib/src/components/banners.dart @@ -169,6 +169,46 @@ class SavePermissionsBanner extends StatelessWidget { } } +class DecryptContentBanner extends StatelessWidget { + const DecryptContentBanner({ + required this.visible, + required this.onAccept, + required this.onDeny, + super.key, + }); + + final VoidCallback onAccept; + final void Function(DecryptPolicy, {required bool persist}) onDeny; + final bool visible; + + @override + Widget build(BuildContext context) { + return _NicelyTimedBanner( + visible: visible, + child: MaterialBanner( + content: const Text( + 'This document contains encrypted content. Decrypt it now?', + ), + leading: const Icon(Icons.lock), + actions: [ + _BannerButton( + text: 'Decrypt', + onPressed: onAccept, + ), + _BannerButton( + text: 'Not now', + onPressed: () => onDeny(DecryptPolicy.deny, persist: false), + ), + _BannerButton( + text: 'Never', + onPressed: () => onDeny(DecryptPolicy.deny, persist: true), + ), + ], + ), + ); + } +} + class _BannerButton extends StatelessWidget { const _BannerButton({required this.text, required this.onPressed}); diff --git a/lib/src/components/dialogs.dart b/lib/src/components/dialogs.dart index 57e00a6a..3c7bb316 100644 --- a/lib/src/components/dialogs.dart +++ b/lib/src/components/dialogs.dart @@ -96,3 +96,32 @@ extension SaveActionDisplayString on SaveAction { SaveAction.discard => AppLocalizations.of(context)!.saveActionDiscard, }; } + +class InputPasswordDialog extends StatelessWidget { + const InputPasswordDialog({super.key}); + + @override + Widget build(BuildContext context) { + return AlertDialog( + icon: const Icon(Icons.lock), + title: const Text('Password'), + content: TextField( + autofocus: true, + obscureText: true, + onSubmitted: (value) => Navigator.pop(context, value), + ), + ); + } +} + +class ProgressIndicatorDialog extends StatelessWidget { + const ProgressIndicatorDialog({super.key}); + + @override + Widget build(BuildContext context) { + return const AlertDialog( + title: Text('Decrypting...'), + content: LinearProgressIndicator(), + ); + } +}