Added the payment options to the summary and enhanced usability handling with delivery options

This commit is contained in:
Dennis Nemec
2026-01-08 14:11:01 +01:00
parent ffdd7fa0ff
commit 6eafb0fab0
4 changed files with 42 additions and 20 deletions

View File

@ -6,7 +6,11 @@ import 'package:hl_lieferservice/model/delivery.dart' as model;
import '../../overview/bloc/tour_event.dart';
class DeliveryOptionsView extends StatefulWidget {
const DeliveryOptionsView({super.key, required this.options, required this.deliveryId});
const DeliveryOptionsView({
super.key,
required this.options,
required this.deliveryId,
});
final List<model.DeliveryOption> options;
final String deliveryId;
@ -16,9 +20,16 @@ class DeliveryOptionsView extends StatefulWidget {
}
class _DeliveryOptionsViewState extends State<DeliveryOptionsView> {
late Map<String, TextEditingController> _controllers;
@override
void initState() {
super.initState();
_controllers = {};
for (final option in widget.options.where((option) => option.numerical)) {
_controllers[option.key] = TextEditingController(text: option.getValue().toString());
}
}
@override
@ -27,31 +38,33 @@ class _DeliveryOptionsViewState extends State<DeliveryOptionsView> {
}
void _update(model.DeliveryOption option, dynamic value) {
debugPrint(option.key);
if (value is bool) {
context.read<TourBloc>().add(
UpdateDeliveryOptionEvent(key: option.key, value: !value, deliveryId: widget.deliveryId),
UpdateDeliveryOptionEvent(
key: option.key,
value: !value,
deliveryId: widget.deliveryId,
),
);
return;
}
context.read<TourBloc>().add(
UpdateDeliveryOptionEvent(key: option.key, value: value, deliveryId: widget.deliveryId),
UpdateDeliveryOptionEvent(
key: option.key,
value: value,
deliveryId: widget.deliveryId,
),
);
}
List<Widget> _options() {
List<Widget> boolOptions =
widget.options.where((option) => !option.numerical).map((option) {
debugPrint("Value: ${option.value}, Key: ${option.key}");
return CheckboxListTile(
value: option.getValue(),
onChanged: (value) {
debugPrint("HAHAHA");
debugPrint(value.toString());
_update(option, option.getValue());
},
title: Text(option.display),
@ -64,10 +77,14 @@ class _DeliveryOptionsViewState extends State<DeliveryOptionsView> {
padding: const EdgeInsets.all(15),
child: TextFormField(
decoration: InputDecoration(labelText: option.display),
initialValue: option.getValue().toString(),
controller: _controllers[option.key],
keyboardType: TextInputType.number,
onTapOutside: (event) => FocusScope.of(context).unfocus(),
onChanged: (value) {
onTapOutside: (event) {
FocusScope.of(context).unfocus();
_update(option, _controllers[option.key]?.text);
},
textInputAction: TextInputAction.done,
onFieldSubmitted: (value) {
_update(option, value);
},
),