added option to attach image to feedback
This commit is contained in:
parent
ea329d8d64
commit
07b32f1e32
@ -6,10 +6,13 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:loader_overlay/loader_overlay.dart';
|
import 'package:loader_overlay/loader_overlay.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info/package_info.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:badges/badges.dart' as badges;
|
||||||
|
|
||||||
import '../../../../api/mhsl/server/feedback/addFeedback.dart';
|
import '../../../../api/mhsl/server/feedback/addFeedback.dart';
|
||||||
import '../../../../api/mhsl/server/feedback/addFeedbackParams.dart';
|
import '../../../../api/mhsl/server/feedback/addFeedbackParams.dart';
|
||||||
import '../../../../model/accountData.dart';
|
import '../../../../model/accountData.dart';
|
||||||
|
import '../../../../storage/base/settingsProvider.dart';
|
||||||
import '../../../../widget/filePick.dart';
|
import '../../../../widget/filePick.dart';
|
||||||
import '../../../../widget/infoDialog.dart';
|
import '../../../../widget/infoDialog.dart';
|
||||||
|
|
||||||
@ -26,6 +29,18 @@ class _FeedbackDialogState extends State<FeedbackDialog> {
|
|||||||
final TextEditingController _feedbackInput = TextEditingController();
|
final TextEditingController _feedbackInput = TextEditingController();
|
||||||
Uint8List? _image;
|
Uint8List? _image;
|
||||||
String? _error;
|
String? _error;
|
||||||
|
bool _textFieldEmpty = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_feedbackInput.addListener(() {
|
||||||
|
setState(() {
|
||||||
|
_textFieldEmpty = _feedbackInput.text.isEmpty;
|
||||||
|
_error = null;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -46,53 +61,85 @@ class _FeedbackDialogState extends State<FeedbackDialog> {
|
|||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _feedbackInput,
|
controller: _feedbackInput,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
label: Text('Feedback und Verbesserungen'),
|
label: const Text('Feedback und Verbesserungen'),
|
||||||
|
errorText: _textFieldEmpty ? 'Bitte gib eine Beschreibung an' : null,
|
||||||
),
|
),
|
||||||
// style: TextStyle(),
|
|
||||||
// expands: true,
|
|
||||||
minLines: 4,
|
minLines: 4,
|
||||||
maxLines: 7,
|
maxLines: 7,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if(_image != null) Container(
|
const SizedBox(height: 10),
|
||||||
decoration: BoxDecoration(
|
if(_image != null) Row(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
border: Border.all(
|
children: [
|
||||||
width: 3,
|
badges.Badge(
|
||||||
color: Theme.of(context).primaryColor,
|
badgeContent: const Icon(Icons.close_outlined, size: 17),
|
||||||
|
badgeStyle: const badges.BadgeStyle(
|
||||||
|
padding: EdgeInsets.all(2),
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
||||||
|
border: Border.all(
|
||||||
|
width: 3,
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
height: 150,
|
||||||
|
child: Image(
|
||||||
|
image: Image.memory(_image!).image,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
setState(() {
|
||||||
|
_image = null;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(5),
|
||||||
|
child: Visibility(
|
||||||
|
visible: _error != null,
|
||||||
|
child: Visibility(
|
||||||
|
visible: Provider.of<SettingsProvider>(context, listen: false).val().devToolsEnabled,
|
||||||
|
replacement: const Text('Senden fehlgeschlagen, bitte überprüfe die Internetverbindung.', textAlign: TextAlign.center, style: TextStyle(color: Colors.red)),
|
||||||
|
child: Text('Senden fehlgeschlagen: \n $_error', textAlign: TextAlign.center, style: const TextStyle(color: Colors.red)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
height: 150,
|
|
||||||
child: Image(
|
|
||||||
image: Image.memory(_image!).image,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Visibility(
|
|
||||||
visible: _error != null,
|
|
||||||
child: Text('Senden fehlgeschlagen: $_error', style: const TextStyle(color: Colors.red)),
|
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 20, left: 10),
|
padding: const EdgeInsets.only(right: 20, left: 10),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
Visibility(
|
||||||
onPressed: () async {
|
visible: _image == null,
|
||||||
context.loaderOverlay.show();
|
child: IconButton(
|
||||||
var imageData = await (await FilePick.galleryPick())?.readAsBytes();
|
onPressed: () async {
|
||||||
context.loaderOverlay.hide();
|
context.loaderOverlay.show();
|
||||||
setState(() {
|
var imageData = await (await FilePick.galleryPick())?.readAsBytes();
|
||||||
_image = imageData;
|
context.loaderOverlay.hide();
|
||||||
});
|
setState(() {
|
||||||
},
|
_image = imageData;
|
||||||
icon: const Icon(Icons.attach_file_outlined),
|
});
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.attach_file_outlined),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Expanded(child: SizedBox.shrink()),
|
const Expanded(child: SizedBox.shrink()),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
if(_feedbackInput.text.isEmpty){
|
||||||
|
setState(() {
|
||||||
|
_textFieldEmpty = true;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
context.loaderOverlay.show();
|
context.loaderOverlay.show();
|
||||||
AddFeedback(
|
AddFeedback(
|
||||||
AddFeedbackParams(
|
AddFeedbackParams(
|
||||||
@ -122,75 +169,5 @@ class _FeedbackDialogState extends State<FeedbackDialog> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Raumplan'),
|
|
||||||
),
|
|
||||||
body: PhotoView(
|
|
||||||
imageProvider: Image.asset('assets/img/raumplan.jpg').image,
|
|
||||||
minScale: 0.5,
|
|
||||||
maxScale: 2.0,
|
|
||||||
backgroundDecoration: BoxDecoration(color: Theme.of(context).colorScheme.background),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
return AlertDialog(
|
|
||||||
|
|
||||||
title: const Text('Feedback'),
|
|
||||||
content: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
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: const InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
label: Text('Feedback und Verbesserungen')
|
|
||||||
),
|
|
||||||
// style: TextStyle(),
|
|
||||||
// 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: () async {
|
|
||||||
AddFeedback(
|
|
||||||
AddFeedbackParams(
|
|
||||||
user: AccountData().getUserSecret(),
|
|
||||||
feedback: _feedbackInput.text,
|
|
||||||
appVersion: int.parse((await PackageInfo.fromPlatform()).buildNumber)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.run()
|
|
||||||
.then((value) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
InfoDialog.show(context, 'Danke für dein Feedback!');
|
|
||||||
})
|
|
||||||
.catchError((error, trace) {
|
|
||||||
setState(() {
|
|
||||||
_error = error.toString();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: const Text('Senden'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user