From 9f5e1f52a2c99f4076cbfd29b1c8d79eaef0eb02 Mon Sep 17 00:00:00 2001 From: Sven Carstensen Date: Wed, 14 Feb 2024 16:19:10 +0100 Subject: [PATCH] Erweiterungen --- lib/content_views/accepted_jobs_page.dart | 1 + lib/content_views/assigned_jobs_page.dart | 6 +++++- lib/popups/accept_jobs_popup.dart | 11 ++++++----- lib/tools/util.dart | 5 +++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/content_views/accepted_jobs_page.dart b/lib/content_views/accepted_jobs_page.dart index b850e00..136682b 100644 --- a/lib/content_views/accepted_jobs_page.dart +++ b/lib/content_views/accepted_jobs_page.dart @@ -89,6 +89,7 @@ class _AcceptedJobsPageState extends State { children: [ Text( DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(), + style: TextStyle(backgroundColor: isJobInFuture(job) ? Colors.yellow : Colors.white), textAlign: TextAlign.left, ), Text( diff --git a/lib/content_views/assigned_jobs_page.dart b/lib/content_views/assigned_jobs_page.dart index 76d87cd..9cac4b0 100644 --- a/lib/content_views/assigned_jobs_page.dart +++ b/lib/content_views/assigned_jobs_page.dart @@ -114,7 +114,11 @@ class _AssignedJobsPageState extends State { padding: const EdgeInsets.all(12.0), child: Column( children: [ - Text(DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(), textAlign: TextAlign.left), + Text( + DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(), + textAlign: TextAlign.left, + style: TextStyle(backgroundColor: isJobInFuture(job) ? Colors.yellow : Colors.white), + ), Text('Auftragsnummer: ${job.id}'), Text(job.tours[0].comp), Text(job.tours[0].street), diff --git a/lib/popups/accept_jobs_popup.dart b/lib/popups/accept_jobs_popup.dart index bb4a9b8..497deff 100644 --- a/lib/popups/accept_jobs_popup.dart +++ b/lib/popups/accept_jobs_popup.dart @@ -77,8 +77,11 @@ Future showAcceptJobsPopup(BuildContext context, List jobs) async { children: [ SizedBox( width: double.infinity, - child: Text(DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(), - textAlign: TextAlign.left), + child: Text( + DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(), + textAlign: TextAlign.left, + style: TextStyle(backgroundColor: isJobInFuture(job) ? Colors.yellow : Colors.white), + ), ), SizedBox(width: double.infinity, child: Text('Auftragsnummer: ${job.id}', textAlign: TextAlign.left)), SizedBox(width: double.infinity, child: Text(job.tours[0].comp, textAlign: TextAlign.left)), @@ -88,9 +91,7 @@ Future showAcceptJobsPopup(BuildContext context, List jobs) async { children: [ Image.asset("assets/${mapVehicleTypeToImageName(job.vhtId)}", width: 60, height: 60), const SizedBox(width: 10), - Text( - mapVehicleTypeToText(job.vhtId) - ), + Text(mapVehicleTypeToText(job.vhtId)), ], ), const SizedBox(height: 10), diff --git a/lib/tools/util.dart b/lib/tools/util.dart index 2f6568b..f4f1a3b 100644 --- a/lib/tools/util.dart +++ b/lib/tools/util.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:image_picker/image_picker.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:stadtbote/model/job.dart'; import 'package:stadtbote/tools/constants.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:uuid/uuid.dart'; @@ -364,3 +365,7 @@ class DecimalTextInputFormatter extends TextInputFormatter { return TextEditingValue(text: filteredText ?? oldValue.text); } } + +bool isJobInFuture(Job job) { + return DateTime.parse(job.ordertime).add(Duration(minutes: job.offsWarn)).toUtc().millisecondsSinceEpoch > DateTime.now().toUtc().millisecondsSinceEpoch; +} \ No newline at end of file