Files
stadtbote-app/lib/popups/tasks_popups/pickup_delivery_status_popup.dart
T
2025-10-23 11:28:03 +02:00

94 lines
4.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:stadtbote/model/task_info.dart';
import 'package:stadtbote/model/tour_task.dart';
import 'package:stadtbote/tools/util.dart';
showPickupDeliveryStatusPopup(BuildContext context, TaskInfo taskInfo, Function(TourEntry?, String? remark) onFinished) async {
List<DropdownMenuEntry<TourEntry>> entries = [];
for (var entry in taskInfo.task?.entries ?? []) {
var dropdownMenuEntry = DropdownMenuEntry<TourEntry>(value: entry, label: entry.text);
entries.add(dropdownMenuEntry);
}
await showDialog(
context: context,
builder: (BuildContext context) {
TourEntry? selectedTourEntry;
TextEditingController controller = TextEditingController();
TextEditingController remController = TextEditingController();
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) {
return SizedBox(
key: GlobalKey(),
height: 280,
width: MediaQuery.of(context).size.width * 0.8,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
border: Border.all(
color: Colors.grey,
width: 0.5,
),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(taskInfo.task?.topic ?? ''),
const SizedBox(height: 20),
DropdownMenu<TourEntry>(
expandedInsets: const EdgeInsets.all(0),
controller: controller,
hintText: 'Status',
onSelected: (TourEntry? value) {
selectedTourEntry = value;
controller.text = value!.text;
setState(() {});
},
dropdownMenuEntries: entries,
),
const SizedBox(height: 20),
Visibility(visible: selectedTourEntry != null ? selectedTourEntry!.queryRemark : false, child: Util.getDefaultTextField(controller: remController, "Bemerkung")),
const SizedBox(height: 20),
getDefaultButton('Übernehmen', buttonHeight: 50, () => {
if (selectedTourEntry!.queryRemark) {
if (remController.text.isNotEmpty) {
Navigator.of(context).pop(),
onFinished(selectedTourEntry, remController.text)
} else {
showAlertDialog("Fehler", "Bitte geben Sie eine Bemerkung ein")
}
} else {
Navigator.of(context).pop(),
onFinished(selectedTourEntry, null)
}
})
],
),
),
));
},
)));
});
}