Implemented settings, new scan, enhanced UI/UX
This commit is contained in:
@ -8,6 +8,9 @@ import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_event.dar
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_state.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/delivery_sign.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_event.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_state.dart';
|
||||
import 'package:hl_lieferservice/model/delivery.dart' as model;
|
||||
|
||||
class DeliveryDetail extends StatefulWidget {
|
||||
@ -126,7 +129,14 @@ class _DeliveryDetailState extends State<DeliveryDetail> {
|
||||
}
|
||||
|
||||
void _onSign(Uint8List customer, Uint8List driver) async {
|
||||
|
||||
final currentState = context.read<DeliveryBloc>().state as DeliveryLoaded;
|
||||
context.read<DeliveryBloc>().add(
|
||||
FinishDeliveryEvent(
|
||||
delivery: currentState.delivery,
|
||||
customerSignature: customer,
|
||||
driverSignature: driver,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _stepsNavigation() {
|
||||
@ -143,7 +153,10 @@ class _DeliveryDetailState extends State<DeliveryDetail> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20),
|
||||
child: FilledButton(
|
||||
onPressed: _step == _steps.length - 1 ? _openSignatureView : _clickForward,
|
||||
onPressed:
|
||||
_step == _steps.length - 1
|
||||
? _openSignatureView
|
||||
: _clickForward,
|
||||
child:
|
||||
_step == _steps.length - 1
|
||||
? const Text("Unterschreiben")
|
||||
@ -159,7 +172,24 @@ class _DeliveryDetailState extends State<DeliveryDetail> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text("Auslieferungsdetails")),
|
||||
body: BlocBuilder<DeliveryBloc, DeliveryState>(
|
||||
body: BlocConsumer<DeliveryBloc, DeliveryState>(
|
||||
listener: (context, state) {
|
||||
if (state is DeliveryFinished) {
|
||||
final tourState = context.read<TourBloc>().state as TourLoaded;
|
||||
final newTour = tourState.tour.copyWith(deliveries: tourState.tour.deliveries.map((delivery) {
|
||||
if (delivery.id == state.delivery.id) {
|
||||
return state.delivery;
|
||||
}
|
||||
|
||||
return delivery;
|
||||
}).toList());
|
||||
|
||||
context.read<TourBloc>().add(UpdateTour(tour: newTour));
|
||||
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
final currentState = state;
|
||||
|
||||
|
||||
@ -25,17 +25,34 @@ class _DeliveryOptionsViewState extends State<DeliveryOptionsView> {
|
||||
}
|
||||
|
||||
void _update(model.DeliveryOption option, dynamic value) {
|
||||
debugPrint(option.key);
|
||||
|
||||
if (value is bool) {
|
||||
context.read<DeliveryBloc>().add(
|
||||
UpdateDeliveryOptionEvent(key: option.key, value: !value),
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
context.read<DeliveryBloc>().add(
|
||||
UpdateDeliveryOption(key: option.key, value: value),
|
||||
UpdateDeliveryOptionEvent(key: option.key, value: value),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
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() as bool,
|
||||
onChanged: (value) => _update(option, value),
|
||||
value: option.getValue(),
|
||||
onChanged: (value) {
|
||||
debugPrint("HAHAHA");
|
||||
debugPrint(value.toString());
|
||||
_update(option, option.getValue());
|
||||
},
|
||||
title: Text(option.display),
|
||||
);
|
||||
}).toList();
|
||||
@ -49,7 +66,9 @@ class _DeliveryOptionsViewState extends State<DeliveryOptionsView> {
|
||||
initialValue: option.getValue().toString(),
|
||||
keyboardType: TextInputType.number,
|
||||
onTapOutside: (event) => FocusScope.of(context).unfocus(),
|
||||
onChanged: (value) => _update(option, value),
|
||||
onChanged: (value) {
|
||||
_update(option, value);
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
|
||||
@ -98,7 +98,7 @@ class _DeliverySummaryState extends State<DeliverySummary> {
|
||||
initialSelection: widget.delivery.payment.id,
|
||||
onSelected: (id) {
|
||||
context.read<DeliveryBloc>().add(
|
||||
UpdateSelectedPaymentMethod(
|
||||
UpdateSelectedPaymentMethodEvent(
|
||||
payment: _paymentMethods.firstWhere(
|
||||
(payment) => payment.id == id,
|
||||
),
|
||||
@ -108,10 +108,6 @@ class _DeliverySummaryState extends State<DeliverySummary> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _payment() {
|
||||
return _paymentOptions();
|
||||
}
|
||||
|
||||
Widget _paymentDone() {
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
@ -174,7 +170,7 @@ class _DeliverySummaryState extends State<DeliverySummary> {
|
||||
),
|
||||
),
|
||||
|
||||
Padding(padding: insets, child: _payment()),
|
||||
Padding(padding: insets, child: _paymentOptions()),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@ -39,6 +39,8 @@ class _NoteOverviewState extends State<NoteOverview> {
|
||||
}
|
||||
|
||||
Widget _images() {
|
||||
debugPrint("IMAGES: ${widget.images}");
|
||||
|
||||
return NoteImageOverview(
|
||||
images: widget.images,
|
||||
deliveryId: widget.deliveryId,
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_event.dart';
|
||||
import 'package:hl_lieferservice/model/article.dart';
|
||||
import 'package:hl_lieferservice/model/delivery.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../../overview/bloc/tour_bloc.dart';
|
||||
import '../../../overview/bloc/tour_state.dart';
|
||||
@ -16,6 +18,100 @@ class DeliveryStepInfo extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
void _launchMapsUrl(String mapsApp) async {
|
||||
final address = widget.delivery.customer.address.toString();
|
||||
final encodedAddress = Uri.encodeComponent(address);
|
||||
Uri url;
|
||||
|
||||
switch (mapsApp) {
|
||||
case 'google':
|
||||
url = Uri.parse(
|
||||
'https://www.google.com/maps/search/?api=1&query=$encodedAddress',
|
||||
);
|
||||
break;
|
||||
case 'apple':
|
||||
url = Uri.parse('http://maps.apple.com/?daddr=$encodedAddress');
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
await launchUrl(url, mode: LaunchMode.externalApplication);
|
||||
}
|
||||
|
||||
Widget _deliveryStatusChangeActions() {
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (widget.delivery.state == DeliveryState.ongoing) {
|
||||
actions = [
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
context.read<TourBloc>().add(
|
||||
HoldDeliveryEvent(deliveryId: widget.delivery.id),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.change_circle,
|
||||
color: Colors.orangeAccent,
|
||||
size: 42,
|
||||
),
|
||||
),
|
||||
Text("Zurückstellen"),
|
||||
],
|
||||
),
|
||||
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
context.read<TourBloc>().add(
|
||||
CancelDeliveryEvent(deliveryId: widget.delivery.id),
|
||||
);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
//style: IconButton.styleFrom(backgroundColor: Colors.red),
|
||||
icon: Icon(Icons.cancel, color: Colors.red, size: 42),
|
||||
),
|
||||
Text("Abbrechen"),
|
||||
],
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
if (widget.delivery.state == DeliveryState.canceled ||
|
||||
widget.delivery.state == DeliveryState.onhold ||
|
||||
widget.delivery.state == DeliveryState.finished) {
|
||||
actions = [
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
context.read<TourBloc>().add(
|
||||
ReactivateDeliveryEvent(deliveryId: widget.delivery.id),
|
||||
);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.published_with_changes,
|
||||
color: Colors.blueAccent,
|
||||
size: 42
|
||||
),
|
||||
),
|
||||
Text("Reaktivieren"),
|
||||
],
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: actions,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _fastActions() {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
@ -23,25 +119,55 @@ class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
color: Theme.of(context).colorScheme.onSecondary,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
IconButton.filled(onPressed: () {}, icon: Icon(Icons.phone)),
|
||||
Text("Anrufen"),
|
||||
Column(
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed:
|
||||
widget.delivery.contactPerson?.phoneNumber != null
|
||||
? () async {
|
||||
await launchUrl(
|
||||
Uri(
|
||||
scheme: "tel",
|
||||
path:
|
||||
widget
|
||||
.delivery
|
||||
.contactPerson
|
||||
?.phoneNumber!,
|
||||
),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.phone),
|
||||
),
|
||||
Text("Anrufen"),
|
||||
],
|
||||
),
|
||||
|
||||
Column(
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed: () {
|
||||
_launchMapsUrl("google");
|
||||
},
|
||||
icon: Icon(Icons.map_outlined),
|
||||
),
|
||||
Text("Google Maps"),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Column(
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed: () {},
|
||||
icon: Icon(Icons.map_outlined),
|
||||
),
|
||||
Text("Navigation starten"),
|
||||
],
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 10, bottom: 10),
|
||||
child: Divider(),
|
||||
),
|
||||
|
||||
_deliveryStatusChangeActions(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -149,6 +275,34 @@ class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _deliveryAgreements() {
|
||||
String agreements = "keine Vereinbarungen getroffen!";
|
||||
if (widget.delivery.specialAgreements != null &&
|
||||
widget.delivery.specialAgreements != "") {
|
||||
agreements = widget.delivery.specialAgreements!;
|
||||
}
|
||||
|
||||
return Card(
|
||||
color: Theme.of(context).colorScheme.onSecondary,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Icon(
|
||||
Icons.warning,
|
||||
color: Theme.of(context).primaryColor,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
Expanded(child: Text(agreements)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
@ -167,6 +321,18 @@ class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
child: _fastActions(),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: Text(
|
||||
"Sondervereinbarungen",
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: _deliveryAgreements(),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: Text(
|
||||
|
||||
Reference in New Issue
Block a user