Added api for sending feedback
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:marianum_mobile/api/mhsl/server/feedback/addFeedback.dart';
|
||||
import 'package:marianum_mobile/api/mhsl/server/feedback/addFeedbackParams.dart';
|
||||
import 'package:marianum_mobile/model/accountData.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
|
||||
class FeedbackDialog extends StatefulWidget {
|
||||
const FeedbackDialog({super.key});
|
||||
@ -9,21 +13,25 @@ class FeedbackDialog extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FeedbackDialogState extends State<FeedbackDialog> {
|
||||
final TextEditingController _feedbackInput = TextEditingController();
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
|
||||
title: const Text("Feedback"),
|
||||
content: const Column(
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text("Feedback, Anregungen, Ideen, Fehler und Verbesserungen"),
|
||||
SizedBox(height: 10),
|
||||
Text("Bitte gib keine geheimen Daten wie z.B. Passwörter weiter.", style: TextStyle(fontSize: 10)),
|
||||
SizedBox(height: 10),
|
||||
const Text("Feedback, Anregungen, Ideen, Fehler und Verbesserungen"),
|
||||
const SizedBox(height: 10),
|
||||
const Text("Bitte gib keine geheimen Daten wie z.B. Passwörter weiter.", style: TextStyle(fontSize: 10)),
|
||||
const SizedBox(height: 10),
|
||||
TextField(
|
||||
controller: _feedbackInput,
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
label: Text("Feedback und Verbesserungen")
|
||||
),
|
||||
@ -31,14 +39,31 @@ class _FeedbackDialogState extends State<FeedbackDialog> {
|
||||
// expands: true,
|
||||
minLines: 3,
|
||||
maxLines: 5,
|
||||
),
|
||||
Visibility(
|
||||
visible: _error != null,
|
||||
child: Text("Senden fehlgeschlagen: $_error", style: const TextStyle(color: Colors.red))
|
||||
)
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.of(context).pop(), child: const Text("Abbrechen")),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
|
||||
onPressed: () async {
|
||||
AddFeedback(
|
||||
AddFeedbackParams(
|
||||
user: AccountData().getUserId(),
|
||||
feedback: _feedbackInput.text,
|
||||
appVersion: int.parse((await PackageInfo.fromPlatform()).buildNumber)
|
||||
)
|
||||
)
|
||||
.run()
|
||||
.then((value) => Navigator.of(context).pop())
|
||||
.catchError((error, trace) {
|
||||
setState(() {
|
||||
_error = error.toString();
|
||||
});
|
||||
});
|
||||
},
|
||||
child: const Text("Senden"),
|
||||
)
|
||||
|
Reference in New Issue
Block a user