feedback: provide interactive feedback directly in the app

by annotating a screenshot of the current page, as well as by adding text.
This commit is contained in:
Calcitem 2021-06-26 19:38:47 +08:00
parent 3980ab464d
commit 8511f1891b
3 changed files with 43 additions and 7 deletions

View File

@ -21,6 +21,7 @@ import 'dart:io';
import 'package:catcher/catcher.dart'; import 'package:catcher/catcher.dart';
import 'package:double_back_to_close_app/double_back_to_close_app.dart'; import 'package:double_back_to_close_app/double_back_to_close_app.dart';
import 'package:feedback/feedback.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
@ -34,7 +35,11 @@ import 'package:sanmill/widgets/navigation_home_screen.dart';
import 'services/audios.dart'; import 'services/audios.dart';
Future<void> main() async { Future<void> main() async {
var catcher = Catcher(rootWidget: SanmillApp(), ensureInitialized: true); var catcher = Catcher(
rootWidget: BetterFeedback(
child: SanmillApp(),
),
ensureInitialized: true);
String externalDirStr; String externalDirStr;
try { try {

View File

@ -17,11 +17,15 @@
*/ */
import 'dart:io'; import 'dart:io';
import 'dart:typed_data';
import 'package:devicelocale/devicelocale.dart'; import 'package:devicelocale/devicelocale.dart';
import 'package:feedback/feedback.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_email_sender/flutter_email_sender.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sanmill/generated/flutter_version.dart'; import 'package:sanmill/generated/flutter_version.dart';
import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/generated/l10n.dart';
import 'package:sanmill/style/app_theme.dart'; import 'package:sanmill/style/app_theme.dart';
@ -62,6 +66,14 @@ class _AboutPageState extends State<AboutPage> {
return ret; return ret;
} }
Future<String> writeImageToStorage(Uint8List feedbackScreenshot) async {
final Directory output = await getTemporaryDirectory();
final String screenshotFilePath = '${output.path}/sanmill-feedback.png';
final File screenshotFile = File(screenshotFilePath);
await screenshotFile.writeAsBytes(feedbackScreenshot);
return screenshotFilePath;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String mode = getMode(); String mode = getMode();
@ -90,12 +102,29 @@ class _AboutPageState extends State<AboutPage> {
), ),
ListItemDivider(), ListItemDivider(),
SettingsListTile( SettingsListTile(
context: context, context: context,
titleString: S.of(context).feedback, titleString: S.of(context).feedback,
onTap: () { onTap: () {
_launchFeedback(); if (Platform.isWindows) {
}, // flutter_email_sender does not support Windows.
), _launchFeedback();
} else {
BetterFeedback.of(context).show((feedback) async {
// draft an email and send to developer
final screenshotFilePath =
await writeImageToStorage(feedback.screenshot);
final Email email = Email(
body: feedback.text,
subject: "[Mill] Sanmill " + "$_version" + " Feedback",
recipients: ['calcitem@outlook.com'],
attachmentPaths: [screenshotFilePath],
isHTML: false,
);
await FlutterEmailSender.send(email);
});
}
}),
ListItemDivider(), ListItemDivider(),
SettingsListTile( SettingsListTile(
context: context, context: context,

View File

@ -26,6 +26,8 @@ dependencies:
devicelocale: ^0.4.1 devicelocale: ^0.4.1
double_back_to_close_app: ^2.0.1 double_back_to_close_app: ^2.0.1
flutter_picker: ^2.0.1 flutter_picker: ^2.0.1
flutter_email_sender: ^5.0.1
feedback: ^2.0.0
#pref: ^2.3.0 #pref: ^2.3.0
#screen_recorder: ^0.0.2 #screen_recorder: ^0.0.2