BIG FAT
This commit is contained in:
@ -8,6 +8,8 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../../bloc/tour_bloc.dart';
|
||||
import '../../../bloc/tour_state.dart';
|
||||
|
||||
enum _StatusAction { hold, cancel, reactivate }
|
||||
|
||||
class DeliveryStepInfo extends StatefulWidget {
|
||||
final Delivery delivery;
|
||||
|
||||
@ -39,76 +41,73 @@ class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
await launchUrl(url, mode: LaunchMode.externalApplication);
|
||||
}
|
||||
|
||||
Widget _deliveryStatusChangeActions() {
|
||||
List<Widget> actions = [];
|
||||
Widget _statusOverflow() {
|
||||
final state = widget.delivery.state;
|
||||
final List<PopupMenuEntry<_StatusAction>> entries;
|
||||
|
||||
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"),
|
||||
],
|
||||
if (state == DeliveryState.ongoing) {
|
||||
entries = const [
|
||||
PopupMenuItem(
|
||||
value: _StatusAction.hold,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.change_circle, color: Colors.orangeAccent),
|
||||
SizedBox(width: 12),
|
||||
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"),
|
||||
],
|
||||
PopupMenuItem(
|
||||
value: _StatusAction.cancel,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.cancel, color: Colors.red),
|
||||
SizedBox(width: 12),
|
||||
Text("Abbrechen"),
|
||||
],
|
||||
),
|
||||
),
|
||||
];
|
||||
} else {
|
||||
entries = const [
|
||||
PopupMenuItem(
|
||||
value: _StatusAction.reactivate,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.published_with_changes, color: Colors.blueAccent),
|
||||
SizedBox(width: 12),
|
||||
Text("Reaktivieren"),
|
||||
],
|
||||
),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
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,
|
||||
return PopupMenuButton<_StatusAction>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
tooltip: "Status ändern",
|
||||
itemBuilder: (context) => entries,
|
||||
onSelected: (action) {
|
||||
switch (action) {
|
||||
case _StatusAction.hold:
|
||||
context.read<TourBloc>().add(
|
||||
HoldDeliveryEvent(deliveryId: widget.delivery.id),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
break;
|
||||
case _StatusAction.cancel:
|
||||
context.read<TourBloc>().add(
|
||||
CancelDeliveryEvent(deliveryId: widget.delivery.id),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
break;
|
||||
case _StatusAction.reactivate:
|
||||
context.read<TourBloc>().add(
|
||||
ReactivateDeliveryEvent(deliveryId: widget.delivery.id),
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -119,55 +118,46 @@ class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
color: Theme.of(context).colorScheme.onSecondary,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Column(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed:
|
||||
widget.delivery.contactPerson?.phoneNumber != null
|
||||
? () async {
|
||||
Expanded(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final phone = widget.delivery.contactPerson?.phoneNumber;
|
||||
final bool hasPhone = phone != null && phone.isNotEmpty;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed: hasPhone
|
||||
? () async {
|
||||
await launchUrl(
|
||||
Uri(
|
||||
scheme: "tel",
|
||||
path:
|
||||
widget
|
||||
.delivery
|
||||
.contactPerson
|
||||
?.phoneNumber!,
|
||||
),
|
||||
Uri(scheme: "tel", path: phone),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.phone),
|
||||
),
|
||||
Text("Anrufen"),
|
||||
],
|
||||
),
|
||||
|
||||
Column(
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed: () {
|
||||
_launchMapsUrl("google");
|
||||
},
|
||||
icon: Icon(Icons.map_outlined),
|
||||
),
|
||||
Text("Google Maps"),
|
||||
],
|
||||
),
|
||||
],
|
||||
: null,
|
||||
icon: const Icon(Icons.phone),
|
||||
),
|
||||
const Text("Anrufen"),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 10, bottom: 10),
|
||||
child: Divider(),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed: () => _launchMapsUrl("google"),
|
||||
icon: const Icon(Icons.map_outlined),
|
||||
),
|
||||
const Text("Google Maps"),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
_deliveryStatusChangeActions(),
|
||||
_statusOverflow(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -176,6 +166,16 @@ class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
}
|
||||
|
||||
Widget _customerInformation() {
|
||||
final phone = widget.delivery.contactPerson?.phoneNumber;
|
||||
final String phoneText = (phone != null && phone.isNotEmpty)
|
||||
? phone
|
||||
: "keine Nummer angegeben";
|
||||
|
||||
final email = widget.delivery.customer.email;
|
||||
final String emailText = (email != null && email.isNotEmpty)
|
||||
? email
|
||||
: "keine E-Mail angegeben";
|
||||
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: Card(
|
||||
@ -228,9 +228,24 @@ class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
Icon(Icons.phone, color: Theme.of(context).primaryColor),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
widget.delivery.contactPerson?.phoneNumber.toString() ??
|
||||
"",
|
||||
child: Text(phoneText),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.mail, color: Theme.of(context).primaryColor),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
emailText,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -275,28 +290,66 @@ class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _deliveryAgreements() {
|
||||
Widget _agreementsAndDesiredTime() {
|
||||
String agreements = "keine Vereinbarungen getroffen!";
|
||||
if (widget.delivery.specialAgreements != null &&
|
||||
widget.delivery.specialAgreements != "") {
|
||||
agreements = widget.delivery.specialAgreements!;
|
||||
}
|
||||
|
||||
final desiredTime = widget.delivery.desiredTime;
|
||||
final bool hasDesiredTime = desiredTime != null && desiredTime.isNotEmpty;
|
||||
final primary = Theme.of(context).primaryColor;
|
||||
|
||||
return Card(
|
||||
color: Theme.of(context).colorScheme.onSecondary,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Row(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Icon(
|
||||
Icons.warning,
|
||||
color: Theme.of(context).primaryColor,
|
||||
size: 28,
|
||||
if (hasDesiredTime) ...[
|
||||
Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(15),
|
||||
child: Icon(Icons.schedule, color: primary, size: 28),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Wunschtermin",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
desiredTime,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(height: 24),
|
||||
],
|
||||
Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(15),
|
||||
child: Icon(Icons.warning, color: primary, size: 28),
|
||||
),
|
||||
Expanded(child: Text(agreements)),
|
||||
],
|
||||
),
|
||||
Expanded(child: Text(agreements)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -330,7 +383,7 @@ class _DeliveryStepInfo extends State<DeliveryStepInfo> {
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: _deliveryAgreements(),
|
||||
child: _agreementsAndDesiredTime(),
|
||||
),
|
||||
|
||||
Padding(
|
||||
|
||||
Reference in New Issue
Block a user