瀏覽代碼

Copy code on long press as well as on tap

vishnukvmd 2 年之前
父節點
當前提交
2b5f349b2f
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. 10 3
      lib/ui/code_widget.dart

+ 10 - 3
lib/ui/code_widget.dart

@@ -79,9 +79,10 @@ class _CodeWidgetState extends State<CodeWidget> {
                     borderRadius: BorderRadius.circular(10),
                   ),
                   onTap: () {
-                    FlutterClipboard.copy(_getTotp()).then(
-                      (value) => showToast(context, "Copied to clipboard"),
-                    );
+                    _copyToClipboard();
+                  },
+                  onLongPress: () {
+                    _copyToClipboard();
                   },
                   child: SizedBox(
                     child: Column(
@@ -155,6 +156,12 @@ class _CodeWidgetState extends State<CodeWidget> {
     );
   }
 
+  void _copyToClipboard() {
+    FlutterClipboard.copy(_getTotp()).then(
+      (value) => showToast(context, "Copied to clipboard"),
+    );
+  }
+
   void _onDeletePressed(_) {
     final AlertDialog alert = AlertDialog(
       shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),