فهرست منبع

Copy next code to clipboard on tap (#238)

Vishnu Mohandas 1 سال پیش
والد
کامیت
442bab6bdd
2فایلهای تغییر یافته به همراه34 افزوده شده و 22 حذف شده
  1. 1 0
      lib/l10n/arb/app_en.arb
  2. 33 22
      lib/ui/code_widget.dart

+ 1 - 0
lib/l10n/arb/app_en.arb

@@ -183,6 +183,7 @@
   "enterDetailsManually": "Enter details manually",
   "enterDetailsManually": "Enter details manually",
   "edit": "Edit",
   "edit": "Edit",
   "copiedToClipboard": "Copied to clipboard",
   "copiedToClipboard": "Copied to clipboard",
+  "copiedNextToClipboard": "Copied next code to clipboard",
   "error": "Error",
   "error": "Error",
   "recoveryKeyCopiedToClipboard": "Recovery key copied to clipboard",
   "recoveryKeyCopiedToClipboard": "Recovery key copied to clipboard",
   "recoveryKeyOnForgotPassword": "If you forget your password, the only way you can recover your data is with this key.",
   "recoveryKeyOnForgotPassword": "If you forget your password, the only way you can recover your data is with this key.",

+ 33 - 22
lib/ui/code_widget.dart

@@ -214,29 +214,34 @@ class _CodeWidgetState extends State<CodeWidget> {
               ),
               ),
             ),
             ),
             widget.code.type == Type.totp
             widget.code.type == Type.totp
-                ? Column(
-                    crossAxisAlignment: CrossAxisAlignment.end,
-                    children: [
-                      Text(
-                        l10n.nextTotpTitle,
-                        style: Theme.of(context).textTheme.bodySmall,
-                      ),
-                      ValueListenableBuilder<String>(
-                        valueListenable: _nextCode,
-                        builder: (context, value, child) {
-                          return Material(
-                            type: MaterialType.transparency,
-                            child: Text(
-                              value,
-                              style: const TextStyle(
-                                fontSize: 18,
-                                color: Colors.grey,
+                ? GestureDetector(
+                    onTap: () {
+                      _copyNextToClipboard();
+                    },
+                    child: Column(
+                      crossAxisAlignment: CrossAxisAlignment.end,
+                      children: [
+                        Text(
+                          l10n.nextTotpTitle,
+                          style: Theme.of(context).textTheme.bodySmall,
+                        ),
+                        ValueListenableBuilder<String>(
+                          valueListenable: _nextCode,
+                          builder: (context, value, child) {
+                            return Material(
+                              type: MaterialType.transparency,
+                              child: Text(
+                                value,
+                                style: const TextStyle(
+                                  fontSize: 18,
+                                  color: Colors.grey,
+                                ),
                               ),
                               ),
-                            ),
-                          );
-                        },
-                      ),
-                    ],
+                            );
+                          },
+                        ),
+                      ],
+                    ),
                   )
                   )
                 : Column(
                 : Column(
                     crossAxisAlignment: CrossAxisAlignment.end,
                     crossAxisAlignment: CrossAxisAlignment.end,
@@ -333,6 +338,12 @@ class _CodeWidgetState extends State<CodeWidget> {
         .then((value) => showToast(context, context.l10n.copiedToClipboard));
         .then((value) => showToast(context, context.l10n.copiedToClipboard));
   }
   }
 
 
+  void _copyNextToClipboard() {
+    FlutterClipboard.copy(_getNextTotp()).then(
+      (value) => showToast(context, context.l10n.copiedNextToClipboard),
+    );
+  }
+
   void _onNextHotpTapped() {
   void _onNextHotpTapped() {
     if (widget.code.type == Type.hotp) {
     if (widget.code.type == Type.hotp) {
       CodeStore.instance
       CodeStore.instance