From a2e70f7dffda2a669fb6018fbdbc39fd87d7deae Mon Sep 17 00:00:00 2001 From: lemoer Date: Sat, 19 Jul 2025 11:16:36 +0200 Subject: [PATCH] Make logs copyable --- lib/main.dart | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index a6556b2..7839fbc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -459,6 +459,33 @@ class _MyHomePageState extends State { ); final actionButtonLogs = FloatingActionButton( + onPressed: () { + // Copy the logs to the clipboard + final error = widget.errorNotifier.value; + if (error != null) { + SystemChannels.platform.invokeMethod( + 'Clipboard.setData', + {'text': error}, + ); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Logs copied to clipboard."), + duration: const Duration(seconds: 3), + ), + ); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("No logs to copy."), + duration: const Duration(seconds: 3), + ), + ); + } + }, + tooltip: 'Copy Logs', + child: const Icon(Icons.copy), + ); + final actionButtonInfo = FloatingActionButton( onPressed: () => obtainKeyPair(regenerate: true), tooltip: 'Regenerate Key', @@ -479,7 +506,7 @@ class _MyHomePageState extends State { } else if (navIndex == 2) { // Logs page bodyComponent = bodyComponentLogs; - actionButton = null; + actionButton = actionButtonLogs; } else { throw Exception('Unknown navIndex: $navIndex'); }