@@ -62,19 +62,24 @@ class _HomePageState extends ConsumerState<HomePage> with BrightnessListener {
6262 appBar: AppBar (
6363 title: const TitleWidget (),
6464 actions: [
65- _SearchButton (
66- onTotpFound: (totp) async {
67- TotpList totps = await ref.read (totpRepositoryProvider.future);
68- int index = totps.indexOf (totp);
69- if (index >= 0 ) {
70- itemScrollController.jumpTo (index: index);
71- WidgetsBinding .instance.addPostFrameCallback ((_) {
72- if (mounted) {
73- setState (() => emphasis = totp);
74- }
75- });
76- }
77- },
65+ Builder (
66+ builder: (context) => _SearchButton (
67+ onTotpFound: (totp) async {
68+ TotpList totps = await ref.read (totpRepositoryProvider.future);
69+ int index = totps.indexOf (totp);
70+ if (index >= 0 ) {
71+ itemScrollController.jumpTo (index: index);
72+ WidgetsBinding .instance.addPostFrameCallback ((_) {
73+ if (mounted) {
74+ setState (() => emphasis = totp);
75+ }
76+ });
77+ }
78+ if (! (await ref.read (displayCopyButtonSettingsEntryProvider.future)) && totp.isDecrypted && context.mounted) {
79+ _HomePageBody ._copyCode (context, totp as DecryptedTotp );
80+ }
81+ },
82+ ),
7883 ),
7984 if (kDebugMode || currentPlatform != Platform .android)
8085 IconButton (
@@ -285,7 +290,7 @@ class _HomePageBody extends ConsumerWidget {
285290 }
286291
287292 /// Allows to copy the code to the clipboard.
288- Future <void > _copyCode (BuildContext context, DecryptedTotp totp) async {
293+ static Future <void > _copyCode (BuildContext context, DecryptedTotp totp) async {
289294 await Clipboard .setData (ClipboardData (text: totp.generateCode ()));
290295 if (context.mounted) {
291296 SnackBarIcon .showSuccessSnackBar (context, text: translations.totp.actions.copyConfirmation);
0 commit comments