Added the payment options to the summary and enhanced usability handling with delivery options
This commit is contained in:
@ -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);
|
||||
},
|
||||
),
|
||||
|
||||
@ -119,6 +119,8 @@ class _SignatureViewState extends State<SignatureView> {
|
||||
builder: (context, state) {
|
||||
final current = state;
|
||||
|
||||
debugPrint("STATE: $current");
|
||||
|
||||
if (current is NoteLoaded) {
|
||||
if (current.notes.isEmpty) {
|
||||
return const SizedBox(
|
||||
@ -209,7 +211,7 @@ class _SignatureViewState extends State<SignatureView> {
|
||||
Flexible(
|
||||
child: InkWell(
|
||||
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,
|
||||
),
|
||||
onTap: () {
|
||||
|
||||
@ -26,7 +26,7 @@ class _DeliverySummaryState extends State<DeliverySummary> {
|
||||
final tourState = context.read<TourBloc>().state as TourLoaded;
|
||||
_paymentMethods = [
|
||||
widget.delivery.payment,
|
||||
...tourState.tour.paymentMethods,
|
||||
...tourState.paymentOptions,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -267,14 +267,17 @@ class Delivery implements Comparable<Delivery> {
|
||||
}
|
||||
|
||||
Article? findArticleWithNoteId(String noteId) {
|
||||
Article? filteredArticle =
|
||||
articles.where((article) => article.removeNoteId == noteId).firstOrNull;
|
||||
|
||||
if (filteredArticle == null && discount?.article != null) {
|
||||
filteredArticle = discount?.article;
|
||||
if (discount != null && discount?.noteId == noteId) {
|
||||
return 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() {
|
||||
|
||||
Reference in New Issue
Block a user