From 777876bc8ddcafd1820b4ace7469d5c4d581b8ff Mon Sep 17 00:00:00 2001 From: Sven Carstensen Date: Mon, 24 Feb 2025 09:21:29 +0100 Subject: [PATCH] Fehlerkorrekturen und Erweiterungen --- assets/wunsch_plz.png | Bin 0 -> 2502 bytes lib/content_views/accepted_jobs_page.dart | 5 ++- lib/content_views/assigned_jobs_page.dart | 10 ++++++ lib/content_views/main_page.dart | 9 +++--- lib/content_views/set_desired_zip_page.dart | 32 ++++++++++++++------ lib/main.dart | 26 +++++++++------- lib/tools/util.dart | 31 +++++++++---------- pubspec.yaml | 2 +- 8 files changed, 70 insertions(+), 45 deletions(-) create mode 100644 assets/wunsch_plz.png diff --git a/assets/wunsch_plz.png b/assets/wunsch_plz.png new file mode 100644 index 0000000000000000000000000000000000000000..4b653de87cc6df634ddd63f0168af56922048677 GIT binary patch literal 2502 zcmV;%2|4zOP)MNnhVr8jHG~rU1F`(5@}sn* zCh9&+{6h&?j2aY?q<;`Vg`hELv>;7PwS;1AsqAhm(5j%a+irI)blu(KA9G)Q-M)8b z&b{y6`+}29n(UlAXXg9PJ!j6Dxu=nHj-n`vqHf>=Ku-;K12ce=;(trPC@>cDOTb@Z z{v+_Lb8f6j_Eem6m7r(x1Tc!CF5p7oeBeBw7l=}-odk9P&j3FIo^j4iB(SXl^f~9k z>~YRz%E$;>4m=1P0$j#C1S}1-u~L0L*uM;c>jZ8>UbU=2tK~{k@LB>upbJNv_$V&>~2_&Q_iaLP1 zfi+2W#Pm;K3-AK)A}|0P01hH?UkR8E%mT_ttk?@I0k$~jz8+w61?Wp@@3E9{)Rlp) zBp)@~fZK@Uz-CM%X-6IjM_>{|767{wfHnf$1-vH@z>hJddEC*=)X zD0rCy2%HAI9AL~8un9Q12;h={mw@}MhLi(e+d<&mqJYZ@yozZA0v&`c7!L!p{vW`z z0{9)H(n;XfB7w^rJQYCT(?+F7fU8nCeG0G&xEJ^pG6f6+;|X--2A&r{WP5hd2;PbW zj+TL&foFaCTL{48z|#P<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+Hf zk@VV=#B)^>fSU_^Kj4*h$Zq3wb02{Q^$=dKd;qwU1S@3<;L6CUisj0JT7Css7}Qq+ zB!IpfSd<}fy-19iBv{`GoEF??idQ3KVVTa`k;M2Cpp*iz5|TYz4?Lg3 zo-HK2nkw-vzH#Z;H<6TPnwxlEj~&a#aEPYt7AL;BZdCBS3U$jy>QkURA^0h?XM4(9!z5p*I|qZc5bcD;{uAK8Fx({>>BJ)422oO8a){H9W_ z03O$Q6wO2aJB)=$Y*+p7FlHigU$sDT42cUzk$S}e with ProducerMixin for (var job in _jobs) { var bottomText = "${job.id}\n${job.tours[0].comp}\n${job.tours[0].street}\n${job.tours[0].city}"; - // BWV - /*if (job.rem.trim().isNotEmpty) { + if (job.rem.trim().isNotEmpty) { bottomText += "\n\n${job.rem.trim()}"; - }*/ + } jobWidgets.add( ListTile( diff --git a/lib/content_views/assigned_jobs_page.dart b/lib/content_views/assigned_jobs_page.dart index 7ef26be..3ca3674 100644 --- a/lib/content_views/assigned_jobs_page.dart +++ b/lib/content_views/assigned_jobs_page.dart @@ -124,6 +124,16 @@ class _AssignedJobsPageState extends State with ProducerMixin, textAlign: TextAlign.left, style: TextStyle(backgroundColor: isJobTooFarInFuture(job) ? Colors.red : Colors.white), ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset("assets/${mapVehicleTypeToImageName(job.vhtId)}", width: 60, height: 60), + const SizedBox(width: 10), + Text( + mapVehicleTypeToText(job.vhtId) + ), + ], + ), Text('Auftragsnummer: ${job.id}'), Text(job.tours[0].comp), Text(job.tours[0].street), diff --git a/lib/content_views/main_page.dart b/lib/content_views/main_page.dart index 6512864..62f4351 100644 --- a/lib/content_views/main_page.dart +++ b/lib/content_views/main_page.dart @@ -6,6 +6,7 @@ import 'package:stadtbote/content_views/approach_area_page.dart'; import 'package:stadtbote/content_views/assigned_jobs_page.dart'; import 'package:stadtbote/content_views/finished_jobs_page.dart'; import 'package:stadtbote/content_views/messages_page.dart'; +import 'package:stadtbote/content_views/set_desired_zip_page.dart'; import 'package:stadtbote/content_views/utils/content_view_widget.dart'; import 'package:stadtbote/main.dart'; import 'package:stadtbote/model/job.dart'; @@ -219,21 +220,19 @@ class _MainPageState extends State with ConsumerMixin, ProducerMixin { //await MessageService().publish(Constants.messageTopicPushContentView, arguments: const ApproachAreaPage()) }), ), - /*SizedBox(height: _loggedOut == true ? 0 : 20), + SizedBox(height: _loggedOut == true ? 0 : 20), Visibility( visible: !_loggedOut, child: getDefaultButton( 'Wunschziel für heute', - image: Image.asset('assets/anfahrtsbereich.png', width: 30, height: 30), + image: Image.asset('assets/wunsch_plz.png', width: 30, height: 30), () async => { - // TODO MESSAGING sendMessage( routingKey: Constants.messageTopicPushContentView, payload: const SetDesiredZipPage(), ) - //await MessageService().publish(Constants.messageTopicPushContentView, arguments: const ApproachAreaPage()) }), - ),*/ + ), SizedBox(height: _loggedOut == true ? 0 : 20), getDefaultButton(_loggedOut ? 'Anmelden' : 'Abmelden', image: Image.asset(_loggedOut ? 'assets/anmelden.png' : 'assets/abmelden.png', width: 30, height: 30), () async { diff --git a/lib/content_views/set_desired_zip_page.dart b/lib/content_views/set_desired_zip_page.dart index 5eef752..686390f 100644 --- a/lib/content_views/set_desired_zip_page.dart +++ b/lib/content_views/set_desired_zip_page.dart @@ -28,6 +28,11 @@ class _SetDesiredZipPageState extends State with ProducerMixi @override void initState() { + var savedDesiredZip = Util.preferencesGetString(Constants.prefsDesiredZip, null); + if (savedDesiredZip != null) { + textEditController.text = savedDesiredZip; + } + super.initState(); } @@ -47,8 +52,13 @@ class _SetDesiredZipPageState extends State with ProducerMixi width: 120, // Festlegen der Breite des Textfelds child: Util.getDefaultTextField('PLZ', - textInputType: TextInputType.text, - formatter: [FilteringTextInputFormatter.singleLineFormatter], + textInputType: TextInputType.number, + formatter: [ + // Erlaubt nur Ziffern + FilteringTextInputFormatter.digitsOnly, + // Begrenzt die maximale Eingabelänge auf 5 Zeichen + LengthLimitingTextInputFormatter(5), + ], controller: textEditController, maxLength: 5, autofocus: true @@ -59,14 +69,18 @@ class _SetDesiredZipPageState extends State with ProducerMixi const SizedBox(height: 20), getDefaultButton('Übernehmen', () => { - Util.preferencesSaveString(Constants.prefsDesiredZip, textEditController.text), + if (textEditController.text.isEmpty || textEditController.text.length == 5) { + Util.preferencesSaveString(Constants.prefsDesiredZip, textEditController.text), - _sendDesiredZipMessage(textEditController.text), + _sendDesiredZipMessage(textEditController.text), - sendMessage( - routingKey: Constants.messageTopicPopContentView, - payload: PopContentViewMessage(count: 1), - ) + sendMessage( + routingKey: Constants.messageTopicPopContentView, + payload: PopContentViewMessage(count: 1), + ) + } else { + showAlertDialog("Fehler", "Das Feld muss leer sein, oder es müssen fünf Zahlen eingegeben werden") + } }) ] ), @@ -79,7 +93,7 @@ class _SetDesiredZipPageState extends State with ProducerMixi sendMessage( routingKey: Constants.messageTopicPublishPayload, - payload: PublishPayloadMessage(topic: "set_desired_zip", message: desiredZipMessage.toJson(),acknowledgeRequired: true), + payload: PublishPayloadMessage(topic: "set_desired_zip", message: desiredZipMessage.toJson(), acknowledgeRequired: true), ); } } diff --git a/lib/main.dart b/lib/main.dart index 39bb1b1..874cc35 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -36,6 +36,8 @@ Future main() async { runZonedGuarded(() async { WidgetsFlutterBinding.ensureInitialized(); + await Util.init(); + MQClient.initialize(); MQClient.instance.declareQueue(Constants.messageTopicRemoveJob); MQClient.instance.declareQueue(Constants.messageTopicPublishPayload); @@ -349,19 +351,21 @@ class _MainState extends State
with SingleTickerProviderStateMixin, Produc var job = await MyApp.isarInstance.jobs.where().filter().idEqualTo(removeJobMessage.id).findFirst(); - await MyApp.isarInstance.writeTxn(() async { - await MyApp.isarInstance.jobs.where().filter().idEqualTo(removeJobMessage.id).deleteAll(); - }); + if (job != null) { + await MyApp.isarInstance.writeTxn(() async { + await MyApp.isarInstance.jobs.where().filter().idEqualTo(removeJobMessage.id).deleteAll(); + }); - sendMessage( - routingKey: Constants.messageTopicJobDeleted, - payload: JobDeletedMessage(job: job!), - ); + sendMessage( + routingKey: Constants.messageTopicJobDeleted, + payload: JobDeletedMessage(job: job!), + ); - sendMessage( - routingKey: Constants.messageTopicUpdateBadges, - payload: RefreshBadgesMessage, - ); + sendMessage( + routingKey: Constants.messageTopicUpdateBadges, + payload: RefreshBadgesMessage, + ); + } }, ); diff --git a/lib/tools/util.dart b/lib/tools/util.dart index c853000..ad3e06f 100644 --- a/lib/tools/util.dart +++ b/lib/tools/util.dart @@ -16,19 +16,22 @@ import 'package:uuid/uuid.dart'; import '../Tools/colored_safe_area.dart'; class Util { - static Future preferencesContainsKey(String key) async { - var prefs = await SharedPreferences.getInstance(); + static late SharedPreferences prefs; + + static init() async { + prefs = await SharedPreferences.getInstance(); + } + + static bool preferencesContainsKey(String key) { return prefs.containsKey(key); } static void preferencesSaveString(String key, String value) async { - var prefs = await SharedPreferences.getInstance(); await prefs.setString(key, value); } - static Future preferencesGetString(String key, String? defaultValue) async { - if (await preferencesContainsKey(key)) { - var prefs = await SharedPreferences.getInstance(); + static String? preferencesGetString(String key, String? defaultValue) { + if (preferencesContainsKey(key)) { return prefs.getString(key); } @@ -36,13 +39,11 @@ class Util { } static void preferencesSaveInt(String key, int value) async { - var prefs = await SharedPreferences.getInstance(); await prefs.setInt(key, value); } - static Future preferencesGetInt(String key, int? defaultValue) async { - if (await preferencesContainsKey(key)) { - var prefs = await SharedPreferences.getInstance(); + static int? preferencesGetInt(String key, int? defaultValue) { + if (preferencesContainsKey(key)) { return prefs.getInt(key); } @@ -50,21 +51,19 @@ class Util { } static void preferencesSaveBool(String key, bool value) async { - var prefs = await SharedPreferences.getInstance(); await prefs.setBool(key, value); } - static Future preferencesGetBool(String key, bool defaultValue) async { - if (await preferencesContainsKey(key)) { - var prefs = await SharedPreferences.getInstance(); + static bool preferencesGetBool(String key, bool defaultValue) { + if (preferencesContainsKey(key)) { return prefs.getBool(key) as bool; } return defaultValue; } - static Future getAppUuid() async { - var currentUuid = await preferencesGetString('uuid', null); + static String getAppUuid() { + var currentUuid = preferencesGetString('uuid', null); if (currentUuid == null) { currentUuid ??= const Uuid().v4(); diff --git a/pubspec.yaml b/pubspec.yaml index badff4e..9af01f9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 332.0.0+332 +version: 335.0.0+335 environment: sdk: '>=2.19.6 <3.0.0'