feedback: Add Feedback button to main menu
And restore feedback in About page to link.
This commit is contained in:
parent
f2bdf24e15
commit
68ab0cf346
|
@ -17,15 +17,11 @@
|
|||
*/
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:devicelocale/devicelocale.dart';
|
||||
import 'package:feedback/feedback.dart';
|
||||
import 'package:flutter/foundation.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:path_provider/path_provider.dart';
|
||||
import 'package:sanmill/common/constants.dart';
|
||||
import 'package:sanmill/generated/flutter_version.dart';
|
||||
import 'package:sanmill/generated/l10n.dart';
|
||||
|
@ -67,14 +63,6 @@ class _AboutPageState extends State<AboutPage> {
|
|||
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
|
||||
Widget build(BuildContext context) {
|
||||
String mode = getMode();
|
||||
|
@ -103,31 +91,10 @@ class _AboutPageState extends State<AboutPage> {
|
|||
),
|
||||
ListItemDivider(),
|
||||
SettingsListTile(
|
||||
context: context,
|
||||
titleString: S.of(context).feedback,
|
||||
onTap: () {
|
||||
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: Constants.feedbackSubjectPrefix +
|
||||
"$_version" +
|
||||
Constants.feedbackSubjectSuffix,
|
||||
recipients: [Constants.recipients],
|
||||
attachmentPaths: [screenshotFilePath],
|
||||
isHTML: false,
|
||||
);
|
||||
await FlutterEmailSender.send(email);
|
||||
});
|
||||
}
|
||||
}),
|
||||
context: context,
|
||||
titleString: S.of(context).feedback,
|
||||
onTap: _launchFeedback,
|
||||
),
|
||||
ListItemDivider(),
|
||||
SettingsListTile(
|
||||
context: context,
|
||||
|
|
|
@ -32,6 +32,7 @@ enum DrawerIndex {
|
|||
preferences,
|
||||
ruleSettings,
|
||||
personalization,
|
||||
feedback,
|
||||
Help,
|
||||
About
|
||||
}
|
||||
|
@ -103,6 +104,11 @@ class _HomeDrawerState extends State<HomeDrawer> {
|
|||
title: S.of(context).personalization,
|
||||
icon: Icon(Icons.color_lens),
|
||||
),
|
||||
DrawerListItem(
|
||||
index: DrawerIndex.feedback,
|
||||
title: S.of(context).feedback,
|
||||
icon: Icon(Icons.feedback_outlined),
|
||||
),
|
||||
DrawerListItem(
|
||||
index: DrawerIndex.Help,
|
||||
title: S.of(context).help,
|
||||
|
|
|
@ -16,8 +16,16 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:feedback/feedback.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:path_provider/path_provider.dart';
|
||||
import 'package:sanmill/common/config.dart';
|
||||
import 'package:sanmill/common/constants.dart';
|
||||
import 'package:sanmill/engine/engine.dart';
|
||||
import 'package:sanmill/mill/game.dart';
|
||||
import 'package:sanmill/style/app_theme.dart';
|
||||
|
@ -75,7 +83,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
|||
}
|
||||
|
||||
void changeIndex(DrawerIndex index) {
|
||||
if (drawerIndex == index) {
|
||||
if (drawerIndex == index && drawerIndex != DrawerIndex.feedback) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -105,6 +113,33 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
|||
setState(() {
|
||||
screenView = PersonalizationSettingsPage();
|
||||
});
|
||||
} else if (drawerIndex == DrawerIndex.feedback) {
|
||||
setState(() {
|
||||
if (Platform.isWindows) {
|
||||
print("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 packageInfo = await PackageInfo.fromPlatform();
|
||||
var _version =
|
||||
'${packageInfo.version} (${packageInfo.buildNumber})';
|
||||
|
||||
final Email email = Email(
|
||||
body: feedback.text,
|
||||
subject: Constants.feedbackSubjectPrefix +
|
||||
"$_version" +
|
||||
Constants.feedbackSubjectSuffix,
|
||||
recipients: [Constants.recipients],
|
||||
attachmentPaths: [screenshotFilePath],
|
||||
isHTML: false,
|
||||
);
|
||||
await FlutterEmailSender.send(email);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (drawerIndex == DrawerIndex.Help && !Config.developerMode) {
|
||||
setState(() {
|
||||
screenView = HelpScreen();
|
||||
|
@ -117,4 +152,12 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
|||
//do in your way......
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue