diff --git a/lib/src/views/settings/help/diagnostics_view.dart b/lib/src/views/settings/help/diagnostics_view.dart index bb41b0c..a68667a 100644 --- a/lib/src/views/settings/help/diagnostics_view.dart +++ b/lib/src/views/settings/help/diagnostics_view.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'dart:io'; import 'package:path_provider/path_provider.dart'; import 'package:flutter/services.dart'; +import 'package:share_plus/share_plus.dart'; import 'package:twonly/src/utils/misc.dart'; class DiagnosticsView extends StatefulWidget { @@ -52,14 +53,27 @@ class _DiagnosticsViewState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ TextButton( - onPressed: () { - Clipboard.setData(ClipboardData(text: logText)); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Log copied to clipboard!')), + onPressed: () async { + final directory = + await getApplicationSupportDirectory(); + final logFile = XFile('${directory.path}/app.log'); + + final params = ShareParams( + text: 'Debug log', + files: [logFile], ); + + final result = await SharePlus.instance.share(params); + + if (result.status != ShareResultStatus.success) { + Clipboard.setData(ClipboardData(text: logText)); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Log copied to clipboard!')), + ); + } }, - child: const Text('Copy All Text'), + child: const Text('Share debug log'), ), TextButton( onPressed: _scrollToBottom, diff --git a/pubspec.lock b/pubspec.lock index a4eb13a..ddb866c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1396,6 +1396,22 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + share_plus: + dependency: "direct main" + description: + name: share_plus + sha256: b2961506569e28948d75ec346c28775bb111986bb69dc6a20754a457e3d97fa0 + url: "https://pub.dev" + source: hosted + version: "11.0.0" + share_plus_platform_interface: + dependency: transitive + description: + name: share_plus_platform_interface + sha256: "1032d392bc5d2095a77447a805aa3f804d2ae6a4d5eef5e6ebb3bd94c1bc19ef" + url: "https://pub.dev" + source: hosted + version: "6.0.0" shared_preferences: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f6bb327..a65c5bb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,6 +67,7 @@ dependencies: get: ^4.7.2 video_player: ^2.9.5 video_compress: ^3.1.4 + share_plus: ^11.0.0 dev_dependencies: flutter_test: