Erweiterungen
This commit is contained in:
1 parent
70a8c04516
commit
b7d45efecc
5 files changed
+117
-40
No files matched your search
@@ -1,6 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_broadcast_receiver/flutter_broadcast_receiver.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stadtbote/content_views/tour_list_page.dart';
|
||||
import 'package:stadtbote/content_views/utils/content_view_widget.dart';
|
||||
import 'package:stadtbote/content_views/utils/header_info.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../main.dart';
|
||||
import '../model/job.dart';
|
||||
import '../tools/constants.dart';
|
||||
import '../tools/util.dart';
|
||||
|
||||
class FinishedJobsPage extends ContentViewWidget {
|
||||
const FinishedJobsPage({super.key});
|
||||
@@ -12,7 +21,7 @@ class FinishedJobsPage extends ContentViewWidget {
|
||||
Future<HeaderInfo> getHeaderInfo(BuildContext context) async {
|
||||
return HeaderInfo(
|
||||
titleWidget: const Text(
|
||||
'Startseite',
|
||||
'Erledigte Aufträge',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24.0,
|
||||
@@ -28,42 +37,100 @@ class FinishedJobsPage extends ContentViewWidget {
|
||||
}
|
||||
|
||||
class _FinishedJobsPageState extends State<FinishedJobsPage> {
|
||||
void sendMessage(Widget message) {
|
||||
//Messaging.instance.sendMessage(message);
|
||||
}
|
||||
late List<Job> _jobs;
|
||||
|
||||
void _clicked() {
|
||||
//sendMessage(const InfoDetailsWidget());
|
||||
late bool _initCompleted = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
Future.delayed(const Duration(seconds: 0), () async {
|
||||
_jobs = await MyApp.isarInstance.jobs.filter().stateEqualTo(2).findAll();
|
||||
|
||||
_initCompleted = true;
|
||||
|
||||
setState(() {});
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_initCompleted) {
|
||||
return Util.getWaitWidget(context);
|
||||
}
|
||||
|
||||
late List<Widget> jobWidgets = _createjobWidgets();
|
||||
|
||||
return ListView(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Dies ist ein linksbündigerText',
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
Text(
|
||||
'Dies ist ein linksbündiger Text',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.blue,
|
||||
fontSize: 24.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
_clicked();
|
||||
},
|
||||
),
|
||||
],
|
||||
children: jobWidgets
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _createjobWidgets() {
|
||||
List<Widget> jobWidgets = [];
|
||||
|
||||
for (var job in _jobs) {
|
||||
jobWidgets.add(
|
||||
ListTile(
|
||||
onTap: () {
|
||||
_clicked(job);
|
||||
},
|
||||
title: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: Colors.grey, width: 0.5),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(13))
|
||||
),
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
Text(
|
||||
job.crFilter != null ? job.crFilter.toString() : "",
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset("assets/${mapVehicleTypeToImageName(job.vhtId)}", width: 60, height: 60),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
mapVehicleTypeToText(job.vhtId)
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
job.id.toString(),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
Text(
|
||||
job.tours[0].comp,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
Text(
|
||||
job.tours[0].street,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
Text(
|
||||
job.tours[0].city,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return jobWidgets;
|
||||
}
|
||||
|
||||
void _clicked(Job job) {
|
||||
BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: TourListPage(job: job, readOnly: true,));
|
||||
}
|
||||
}
|
||||
@@ -205,7 +205,7 @@ class _MainPageState extends State<MainPage> {
|
||||
getDefaultButton(
|
||||
'Abmelden',
|
||||
image: Image.asset('assets/abmelden.png', width: 30, height: 30),
|
||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const FinishedJobsPage())}),
|
||||
() => {}),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
|
||||
@@ -21,10 +21,12 @@ import '../model/task_info.dart';
|
||||
import '../tools/util.dart';
|
||||
|
||||
class TaskListPage extends ContentViewWidget {
|
||||
const TaskListPage({super.key, required this.tour});
|
||||
const TaskListPage({super.key, required this.tour, this.readOnly = false});
|
||||
|
||||
final JobTour tour;
|
||||
|
||||
final bool readOnly;
|
||||
|
||||
@override
|
||||
State<TaskListPage> createState() => _TaskListPageState();
|
||||
|
||||
@@ -80,9 +82,12 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: steps,
|
||||
child: AbsorbPointer(
|
||||
absorbing: widget.readOnly,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: steps,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -11,11 +11,14 @@ import '../tools/constants.dart';
|
||||
import '../tools/util.dart';
|
||||
|
||||
class TourDetailsPage extends ContentViewWidget {
|
||||
const TourDetailsPage({super.key, required this.job, required this.tour});
|
||||
const TourDetailsPage({super.key, required this.job, required this.tour, this.readOnly = false});
|
||||
|
||||
final Job job;
|
||||
final JobTour tour;
|
||||
|
||||
final bool readOnly;
|
||||
|
||||
|
||||
@override
|
||||
State<TourDetailsPage> createState() => _TourDetailsPageState();
|
||||
|
||||
@@ -139,7 +142,7 @@ class _TourDetailsPageState extends State<TourDetailsPage> {
|
||||
const SizedBox(height: 10),
|
||||
getDefaultButton('Weiter', () =>
|
||||
{
|
||||
BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: TaskListPage(tour: widget.tour))
|
||||
BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: TaskListPage(tour: widget.tour, readOnly: widget.readOnly))
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -11,10 +11,12 @@ import '../tools/constants.dart';
|
||||
import '../tools/util.dart';
|
||||
|
||||
class TourListPage extends ContentViewWidget {
|
||||
const TourListPage({super.key, required this.job});
|
||||
const TourListPage({super.key, required this.job, this.readOnly = false});
|
||||
|
||||
final Job job;
|
||||
|
||||
final bool readOnly;
|
||||
|
||||
@override
|
||||
State<TourListPage> createState() => _TourListPageState();
|
||||
|
||||
@@ -192,7 +194,7 @@ class _TourListPageState extends State<TourListPage> {
|
||||
|
||||
void _clicked(JobTour tour) {
|
||||
if (tour.state == 0) {
|
||||
BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: TourDetailsPage(job: widget.job, tour: tour));
|
||||
BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: TourDetailsPage(job: widget.job, tour: tour, readOnly: widget.readOnly));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user