201 lines
5.7 KiB
Dart
201 lines
5.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_broadcast_receiver/flutter_broadcast_receiver.dart';
|
|
import 'package:stadtbote/content_views/tour_details_page.dart';
|
|
import 'package:stadtbote/content_views/utils/content_view_widget.dart';
|
|
import 'package:stadtbote/content_views/utils/header_info.dart';
|
|
import 'package:stadtbote/model/job_tour.dart';
|
|
import 'package:stadtbote/popups/map_popup.dart';
|
|
|
|
import '../model/job.dart';
|
|
import '../tools/constants.dart';
|
|
import '../tools/util.dart';
|
|
|
|
class TourListPage extends ContentViewWidget {
|
|
const TourListPage({super.key, required this.job, this.readOnly = false});
|
|
|
|
final Job job;
|
|
|
|
final bool readOnly;
|
|
|
|
@override
|
|
State<TourListPage> createState() => _TourListPageState();
|
|
|
|
@override
|
|
Future<HeaderInfo> getHeaderInfo(BuildContext context) async {
|
|
return HeaderInfo(
|
|
titleWidget: const Text(
|
|
'Liste der Stationen',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 24.0,
|
|
),
|
|
),
|
|
rightButtonEnabled: false,
|
|
rightButtonVisible: false,
|
|
rightButtonImage: null,
|
|
rightButtonOnPressed: () async {
|
|
//BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: EmployeeEditProfileWidget());
|
|
});
|
|
}
|
|
}
|
|
|
|
class _TourListPageState extends State<TourListPage> {
|
|
late List<JobTour> _tours;
|
|
|
|
late bool _initCompleted = false;
|
|
|
|
@override
|
|
void initState() {
|
|
Future.delayed(const Duration(seconds: 0), () async {
|
|
_tours = widget.job.tours;
|
|
|
|
_initCompleted = true;
|
|
|
|
setState(() {});
|
|
});
|
|
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (!_initCompleted) {
|
|
return Util.getWaitWidget(context);
|
|
}
|
|
|
|
late List<Widget> jobWidgets = _createjobWidgets();
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.all(18.0),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
color: Colors.transparent,
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
widget.job.id.toString(),
|
|
textAlign: TextAlign.left,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
widget.job.crFilter != null ? widget.job.crFilter.toString() : "",
|
|
textAlign: TextAlign.left,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
Image.asset("assets/${mapVehicleTypeToImageName(widget.job.vhtId)}", width: 60, height: 60),
|
|
const SizedBox(width: 10),
|
|
Expanded(
|
|
child: Text(
|
|
mapVehicleTypeToText(widget.job.vhtId)
|
|
),
|
|
),
|
|
const SizedBox(width: 10),
|
|
SizedBox(
|
|
width: 100,
|
|
child: Visibility(
|
|
visible: widget.job.tours[0].pos != null,
|
|
child: ElevatedButton(
|
|
style: ButtonStyle(
|
|
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
|
RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
side: const BorderSide(color: Colors.grey),
|
|
),
|
|
),
|
|
backgroundColor: MaterialStateProperty.all<Color>(Colors.lightGreen),
|
|
foregroundColor: MaterialStateProperty.all<Color>(Colors.black),
|
|
),
|
|
onPressed: () => { showMapPopup(context, widget.job.tours[0], widget.job.tours)},
|
|
child: const Text("Karte")),
|
|
))
|
|
],
|
|
),
|
|
Expanded(
|
|
child: ListView(
|
|
padding: const EdgeInsets.all(0),
|
|
children: jobWidgets
|
|
),
|
|
)
|
|
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
List<Widget> _createjobWidgets() {
|
|
List<Widget> jobWidgets = [];
|
|
|
|
for (var tour in _tours) {
|
|
Color color = Colors.transparent;
|
|
switch(tour.state) {
|
|
case 0:
|
|
color = Colors.white;
|
|
break;
|
|
|
|
case 1:
|
|
color = Colors.lightGreen;
|
|
break;
|
|
|
|
default:
|
|
color = Colors.yellow;
|
|
break;
|
|
}
|
|
|
|
jobWidgets.add(
|
|
ListTile(
|
|
contentPadding: const EdgeInsets.all(0),
|
|
onTap: () {
|
|
_clicked(tour);
|
|
},
|
|
title: Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: Colors.grey, width: 0.5),
|
|
color: color,
|
|
borderRadius: const BorderRadius.all(Radius.circular(13))
|
|
),
|
|
padding: const EdgeInsets.all(5.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Text(
|
|
"${"Station ${tour.sort}"} ${mapTourMode(tour.mode)}",
|
|
textAlign: TextAlign.left,
|
|
),
|
|
Text(
|
|
tour.comp,
|
|
textAlign: TextAlign.left,
|
|
),
|
|
Text(
|
|
tour.street,
|
|
textAlign: TextAlign.left,
|
|
),
|
|
Text(
|
|
tour.city,
|
|
textAlign: TextAlign.left,
|
|
),
|
|
],
|
|
),
|
|
)
|
|
),
|
|
);
|
|
}
|
|
|
|
return jobWidgets;
|
|
}
|
|
|
|
void _clicked(JobTour tour) {
|
|
if (tour.state == 0) {
|
|
BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: TourDetailsPage(job: widget.job, tour: tour, readOnly: widget.readOnly));
|
|
}
|
|
}
|
|
}
|