import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:stadtbote/model/task_info.dart'; import 'package:stadtbote/model/tour_task.dart'; import 'package:stadtbote/tools/util.dart'; showReceiptGiverPopup(BuildContext context, TaskInfo taskInfo, Function(String, TourEntry) onFinished) async { List> entries = []; for (var entry in taskInfo.task?.entries ?? []) { var dropdownMenuEntry = DropdownMenuEntry(value: entry, label: entry.text); entries.add(dropdownMenuEntry); } TextEditingController controller = TextEditingController(); TourEntry? selectedTourEntry; await showDialog( context: context, builder: (BuildContext context) { return PopScope( canPop: false, onPopInvokedWithResult: (bool didPop, dynamic result) async { if (!didPop) { final shouldPop = await taskDialogSecurityException(context); if (shouldPop && context.mounted) { Navigator.of(context).pop(); } } }, child: AlertDialog( contentPadding: EdgeInsets.zero, shadowColor: Colors.transparent, backgroundColor: Colors.white, content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) { TextEditingController textEditingController = TextEditingController(); return SizedBox( key: GlobalKey(), height: 350, width: MediaQuery.of(context).size.width * 0.8, child: Container( height: 100, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, border: Border.all( color: Colors.grey, width: 0.5, ), ), child: Padding( padding: const EdgeInsets.all(35.0), child: Column( children: [ Text(taskInfo.task?.topic ?? ''), const SizedBox(height: 20), DropdownMenu( expandedInsets: const EdgeInsets.all(0), controller: controller, hintText: 'Geschlecht', onSelected: (TourEntry? value) { selectedTourEntry = value; controller.text = value!.text; }, dropdownMenuEntries: entries, ), const SizedBox(height: 30), Util.getDefaultTextField(taskInfo.task?.topic ?? '', textInputType: TextInputType.text, formatter: [FilteringTextInputFormatter.singleLineFormatter], controller: textEditingController, maxLength: 40, autofocus: true), const SizedBox(height: 20), getDefaultButton('Übernehmen', () { if (textEditingController.text.isNotEmpty && selectedTourEntry != null) { Navigator.of(context).pop(); onFinished(textEditingController.text, selectedTourEntry!); } else { showAlertDialog("Fehler", "Sie müssen einen Text eingeben und ein Geschlecht auswählen"); } }) ], ), ), )); }))); }); }