develop-biggerFeedbackWidget #51
@@ -6,12 +6,14 @@ part 'addFeedbackParams.g.dart';
 | 
			
		||||
class AddFeedbackParams {
 | 
			
		||||
  String user;
 | 
			
		||||
  String feedback;
 | 
			
		||||
  String? screenshot;
 | 
			
		||||
  int appVersion;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  AddFeedbackParams({
 | 
			
		||||
    required this.user,
 | 
			
		||||
    required this.feedback,
 | 
			
		||||
    this.screenshot,
 | 
			
		||||
    required this.appVersion,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ AddFeedbackParams _$AddFeedbackParamsFromJson(Map<String, dynamic> json) =>
 | 
			
		||||
    AddFeedbackParams(
 | 
			
		||||
      user: json['user'] as String,
 | 
			
		||||
      feedback: json['feedback'] as String,
 | 
			
		||||
      screenshot: json['screenshot'] as String?,
 | 
			
		||||
      appVersion: json['appVersion'] as int,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
@@ -17,5 +18,6 @@ Map<String, dynamic> _$AddFeedbackParamsToJson(AddFeedbackParams instance) =>
 | 
			
		||||
    <String, dynamic>{
 | 
			
		||||
      'user': instance.user,
 | 
			
		||||
      'feedback': instance.feedback,
 | 
			
		||||
      'screenshot': instance.screenshot,
 | 
			
		||||
      'appVersion': instance.appVersion,
 | 
			
		||||
    };
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,16 @@
 | 
			
		||||
 | 
			
		||||
import 'dart:convert';
 | 
			
		||||
import 'dart:typed_data';
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:image_picker/image_picker.dart';
 | 
			
		||||
import 'package:loader_overlay/loader_overlay.dart';
 | 
			
		||||
import 'package:package_info/package_info.dart';
 | 
			
		||||
 | 
			
		||||
import '../../../../api/mhsl/server/feedback/addFeedback.dart';
 | 
			
		||||
import '../../../../api/mhsl/server/feedback/addFeedbackParams.dart';
 | 
			
		||||
import '../../../../model/accountData.dart';
 | 
			
		||||
import '../../../../widget/filePick.dart';
 | 
			
		||||
import '../../../../widget/infoDialog.dart';
 | 
			
		||||
 | 
			
		||||
class FeedbackDialog extends StatefulWidget {
 | 
			
		||||
@@ -15,7 +21,10 @@ class FeedbackDialog extends StatefulWidget {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _FeedbackDialogState extends State<FeedbackDialog> {
 | 
			
		||||
  final ImagePicker picker = ImagePicker();
 | 
			
		||||
 | 
			
		||||
  final TextEditingController _feedbackInput = TextEditingController();
 | 
			
		||||
  Uint8List? _image;
 | 
			
		||||
  String? _error;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
@@ -39,38 +48,68 @@ class _FeedbackDialogState extends State<FeedbackDialog> {
 | 
			
		||||
              autofocus: true,
 | 
			
		||||
              decoration: const InputDecoration(
 | 
			
		||||
                  border: OutlineInputBorder(),
 | 
			
		||||
                  label: Text('Feedback und Verbesserungen')
 | 
			
		||||
                  label: Text('Feedback und Verbesserungen'),
 | 
			
		||||
              ),
 | 
			
		||||
              // style: TextStyle(),
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 
					
					Pupsi marked this conversation as resolved
					
				 
				 | 
			||||
              // expands: true,
 | 
			
		||||
              minLines: 4,
 | 
			
		||||
              maxLines: 7,
 | 
			
		||||
            )
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
          if(_image != null) 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,
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
          Visibility(
 | 
			
		||||
              visible: _error != null,
 | 
			
		||||
              child: Text('Senden fehlgeschlagen: $_error', style: const TextStyle(color: Colors.red)),
 | 
			
		||||
          ),
 | 
			
		||||
          Padding(
 | 
			
		||||
            padding: const EdgeInsets.only(right: 20),
 | 
			
		||||
            padding: const EdgeInsets.only(right: 20, left: 10),
 | 
			
		||||
            child: Row(
 | 
			
		||||
              mainAxisAlignment: MainAxisAlignment.end,
 | 
			
		||||
              children: [
 | 
			
		||||
                IconButton(
 | 
			
		||||
                  onPressed: () async {
 | 
			
		||||
                    context.loaderOverlay.show();
 | 
			
		||||
                    var imageData = await (await FilePick.galleryPick())?.readAsBytes();
 | 
			
		||||
                    context.loaderOverlay.hide();
 | 
			
		||||
                    setState(() {
 | 
			
		||||
                      _image = imageData;
 | 
			
		||||
                    });
 | 
			
		||||
                  },
 | 
			
		||||
                  icon: const Icon(Icons.attach_file_outlined),
 | 
			
		||||
                ),
 | 
			
		||||
                const Expanded(child: SizedBox.shrink()),
 | 
			
		||||
                TextButton(
 | 
			
		||||
                  onPressed: () async {
 | 
			
		||||
                    context.loaderOverlay.show();
 | 
			
		||||
                    AddFeedback(
 | 
			
		||||
                        AddFeedbackParams(
 | 
			
		||||
                            user: AccountData().getUserSecret(),
 | 
			
		||||
                            feedback: _feedbackInput.text,
 | 
			
		||||
                            appVersion: int.parse((await PackageInfo.fromPlatform()).buildNumber)
 | 
			
		||||
                            screenshot: _image != null ? base64Encode(_image!) : null,
 | 
			
		||||
                            appVersion: int.parse((await PackageInfo.fromPlatform()).buildNumber),
 | 
			
		||||
                        )
 | 
			
		||||
                    ).run().then((value) {
 | 
			
		||||
                      Navigator.of(context).pop();
 | 
			
		||||
                      InfoDialog.show(context, 'Danke für dein Feedback!');
 | 
			
		||||
                      context.loaderOverlay.hide();
 | 
			
		||||
                    }).catchError((error, trace) {
 | 
			
		||||
                      setState(() {
 | 
			
		||||
                        _error = error.toString();
 | 
			
		||||
                      });
 | 
			
		||||
                      context.loaderOverlay.hide();
 | 
			
		||||
                    });
 | 
			
		||||
                  },
 | 
			
		||||
                  child: const Text('Senden'),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user
	
?