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: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/common/constants.dart';
|
import 'package:sanmill/common/constants.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';
|
||||||
|
@ -67,14 +63,6 @@ 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();
|
||||||
|
@ -105,29 +93,8 @@ class _AboutPageState extends State<AboutPage> {
|
||||||
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: Constants.feedbackSubjectPrefix +
|
|
||||||
"$_version" +
|
|
||||||
Constants.feedbackSubjectSuffix,
|
|
||||||
recipients: [Constants.recipients],
|
|
||||||
attachmentPaths: [screenshotFilePath],
|
|
||||||
isHTML: false,
|
|
||||||
);
|
|
||||||
await FlutterEmailSender.send(email);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
ListItemDivider(),
|
ListItemDivider(),
|
||||||
SettingsListTile(
|
SettingsListTile(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
|
@ -32,6 +32,7 @@ enum DrawerIndex {
|
||||||
preferences,
|
preferences,
|
||||||
ruleSettings,
|
ruleSettings,
|
||||||
personalization,
|
personalization,
|
||||||
|
feedback,
|
||||||
Help,
|
Help,
|
||||||
About
|
About
|
||||||
}
|
}
|
||||||
|
@ -103,6 +104,11 @@ class _HomeDrawerState extends State<HomeDrawer> {
|
||||||
title: S.of(context).personalization,
|
title: S.of(context).personalization,
|
||||||
icon: Icon(Icons.color_lens),
|
icon: Icon(Icons.color_lens),
|
||||||
),
|
),
|
||||||
|
DrawerListItem(
|
||||||
|
index: DrawerIndex.feedback,
|
||||||
|
title: S.of(context).feedback,
|
||||||
|
icon: Icon(Icons.feedback_outlined),
|
||||||
|
),
|
||||||
DrawerListItem(
|
DrawerListItem(
|
||||||
index: DrawerIndex.Help,
|
index: DrawerIndex.Help,
|
||||||
title: S.of(context).help,
|
title: S.of(context).help,
|
||||||
|
|
|
@ -16,8 +16,16 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
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/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/config.dart';
|
||||||
|
import 'package:sanmill/common/constants.dart';
|
||||||
import 'package:sanmill/engine/engine.dart';
|
import 'package:sanmill/engine/engine.dart';
|
||||||
import 'package:sanmill/mill/game.dart';
|
import 'package:sanmill/mill/game.dart';
|
||||||
import 'package:sanmill/style/app_theme.dart';
|
import 'package:sanmill/style/app_theme.dart';
|
||||||
|
@ -75,7 +83,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeIndex(DrawerIndex index) {
|
void changeIndex(DrawerIndex index) {
|
||||||
if (drawerIndex == index) {
|
if (drawerIndex == index && drawerIndex != DrawerIndex.feedback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +113,33 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
||||||
setState(() {
|
setState(() {
|
||||||
screenView = PersonalizationSettingsPage();
|
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) {
|
} else if (drawerIndex == DrawerIndex.Help && !Config.developerMode) {
|
||||||
setState(() {
|
setState(() {
|
||||||
screenView = HelpScreen();
|
screenView = HelpScreen();
|
||||||
|
@ -117,4 +152,12 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
||||||
//do in your way......
|
//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