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

View File

@ -119,6 +119,8 @@ class _SignatureViewState extends State<SignatureView> {
builder: (context, state) { builder: (context, state) {
final current = state; final current = state;
debugPrint("STATE: $current");
if (current is NoteLoaded) { if (current is NoteLoaded) {
if (current.notes.isEmpty) { if (current.notes.isEmpty) {
return const SizedBox( return const SizedBox(
@ -209,7 +211,7 @@ class _SignatureViewState extends State<SignatureView> {
Flexible( Flexible(
child: InkWell( child: InkWell(
child: Text( child: Text(
"Ich bestätige, dass ich die Ware im ordnungsgemäßen Zustand erhalten habe und, dass die Aufstell- und Einbauarbeiten korrekt durchgeführt wurden.", "Ware in ordnungsgemäßem Zustand erhalten. Aufstell- und Einbauarbeiten wurden korrekt durchgeführt",
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
), ),
onTap: () { onTap: () {

View File

@ -26,7 +26,7 @@ class _DeliverySummaryState extends State<DeliverySummary> {
final tourState = context.read<TourBloc>().state as TourLoaded; final tourState = context.read<TourBloc>().state as TourLoaded;
_paymentMethods = [ _paymentMethods = [
widget.delivery.payment, widget.delivery.payment,
...tourState.tour.paymentMethods, ...tourState.paymentOptions,
]; ];
} }

View File

@ -267,14 +267,17 @@ class Delivery implements Comparable<Delivery> {
} }
Article? findArticleWithNoteId(String noteId) { Article? findArticleWithNoteId(String noteId) {
Article? filteredArticle = if (discount != null && discount?.noteId == noteId) {
articles.where((article) => article.removeNoteId == noteId).firstOrNull; return discount?.article;
if (filteredArticle == null && discount?.article != null) {
filteredArticle = discount?.article;
} }
return filteredArticle; int index = articles.indexWhere((article) => article.removeNoteId == noteId);
// If no article with an according remove note id is found, skip this step.
if (index == -1) {
return null;
}
return articles[index];
} }
double getGrossPrice() { double getGrossPrice() {