diff --git a/changelog.yml b/changelog.yml index 0e103a77..5eed8e48 100644 --- a/changelog.yml +++ b/changelog.yml @@ -10,6 +10,7 @@ image: ios_shortcuts.png - text: "Custom SSH keys with passwords can now be used - #227" - text: "Create new note when clicking on non existing Wiki Link - #240" + - text: "Debug Screen: Add a button to easily copy all the logs" bugs: - text: "Fix notes not always showing up - #270" diff --git a/lib/screens/debug_screen.dart b/lib/screens/debug_screen.dart index eb23d587..3553f79c 100644 --- a/lib/screens/debug_screen.dart +++ b/lib/screens/debug_screen.dart @@ -1,4 +1,7 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:provider/provider.dart'; @@ -52,6 +55,10 @@ class _DebugScreenState extends State { }, ), actions: [ + IconButton( + icon: const Icon(Icons.copy), + onPressed: _copyToClipboard, + ), IconButton( icon: const Icon(Icons.filter_list), onPressed: _showFilterSelection, @@ -123,6 +130,16 @@ class _DebugScreenState extends State { } } + void _copyToClipboard() async { + var messages = []; + for (var logMsg in _logs) { + var msg = json.encode(logMsg.toMap()); + messages.add(msg); + } + + Clipboard.setData(ClipboardData(text: messages.join('\n'))); + } + Widget _buildLogWidget(LogMessage msg) { var textStyle = Theme.of(context) .textTheme