Skip to content

Commit

Permalink
Add decryption UI elements
Browse files Browse the repository at this point in the history
See #33
  • Loading branch information
amake committed Dec 24, 2023
1 parent 6cc3f20 commit 783ed67
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/src/components/banners.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand Down
29 changes: 29 additions & 0 deletions lib/src/components/dialogs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}
}

0 comments on commit 783ed67

Please sign in to comment.