diff --git a/lib/content_views/approach_area_page.dart b/lib/content_views/approach_area_page.dart index 4fd0c96..fc5d9ed 100644 --- a/lib/content_views/approach_area_page.dart +++ b/lib/content_views/approach_area_page.dart @@ -1,4 +1,3 @@ - import 'package:dart_mq/dart_mq.dart'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; @@ -28,7 +27,8 @@ class ApproachAreaPage extends ContentViewWidget { } } -class _ApproachAreaPageState extends State with ProducerMixin, ConsumerMixin { +class _ApproachAreaPageState extends State + with ProducerMixin, ConsumerMixin { late Ranking? _ranking; late bool _initCompleted = false; @@ -74,7 +74,9 @@ class _ApproachAreaPageState extends State with ProducerMixin, scrollDirection: Axis.vertical, child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: _fillColumns()), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: _fillColumns()), ), ), ), @@ -94,9 +96,14 @@ class _ApproachAreaPageState extends State with ProducerMixin, entries.add( GestureDetector( onTap: () => { - if (i == 0) { - showZipPopup(context, 'ACHTUNG: Wenn Sie Ihre PLZ ändern, verlieren Sie Ihr Ranking!\n', 'Freimelden', (zip) => {_sendZip(rank, zip)}), - } + if (i == 0) + { + showZipPopup( + context, + 'ACHTUNG: Wenn Sie Ihre PLZ ändern, verlieren Sie Ihr Ranking!\n', + 'Freimelden', + (zip) => {_sendZip(rank, zip)}), + } }, child: Container( padding: const EdgeInsets.all(4), @@ -114,24 +121,28 @@ class _ApproachAreaPageState extends State with ProducerMixin, child: Column(children: [ Text( rank.zip, - style: TextStyle(fontSize: 20, color: (i == 0 ? Colors.white : Colors.black)), + style: TextStyle( + fontSize: 20, + color: (i == 0 ? Colors.white : Colors.black)), ), Text( rankArea, - style: TextStyle(fontSize: 13, color: (i == 0 ? Colors.white : Colors.black)), + style: TextStyle( + fontSize: 13, + color: (i == 0 ? Colors.white : Colors.black)), ) - ] - ) - ), + ])), ), ); for (int j = 0; j < rank.vehicles.length; j++) { var vehicle = rank.vehicles[j]; - var imageFilename = vehicle.self == true ? "assets/mein_${mapVehicleTypeToImageName(vehicle.type)}" : "assets/${mapVehicleTypeToImageName(vehicle.type)}"; + var imageFilename = vehicle.self == true + ? "assets/mein_${mapVehicleTypeToImageName(vehicle.type)}" + : "assets/${mapVehicleTypeToImageName(vehicle.type)}"; entries.add( - badges.Badge( + badges.Badge( showBadge: vehicle.cnt != null && vehicle.cnt! > 0, position: badges.BadgePosition.topEnd(top: -12, end: 0), badgeContent: Text( @@ -165,13 +176,11 @@ class _ApproachAreaPageState extends State with ProducerMixin, children: [ Image.asset(imageFilename, width: 30, height: 30), const SizedBox(width: 10), - Text( - mapVehicleTypeToText(vehicle.type) - ), + Text(mapVehicleTypeToText(vehicle.type)), ], ), )), - ); + ); } columns.add(Align( @@ -204,7 +213,10 @@ class _ApproachAreaPageState extends State with ProducerMixin, sendMessage( routingKey: Constants.messageTopicPublishPayload, - payload: PublishPayloadMessage(topic: "set_zip", message: setPosMessage.toJson(), acknowledgeRequired: false), + payload: PublishPayloadMessage( + topic: "set_zip", + message: setPosMessage.toJson(), + acknowledgeRequired: false), ); } @@ -265,7 +277,10 @@ class _HeaderWidgetState extends State<_HeaderWidget> with ProducerMixin { child: const CircleAvatar( radius: 10, backgroundColor: Constants.colorPrimary, - child: Padding(padding: EdgeInsets.all(1.0), child: Icon(Icons.arrow_back, size: 20.0, color: Colors.white)), + child: Padding( + padding: EdgeInsets.all(1.0), + child: Icon(Icons.arrow_back, + size: 20.0, color: Colors.white)), ), ), ), @@ -291,7 +306,10 @@ class _HeaderWidgetState extends State<_HeaderWidget> with ProducerMixin { child: const CircleAvatar( backgroundColor: Constants.colorPrimary, radius: 10, - child: Padding(padding: EdgeInsets.all(1.0), child: Icon(Icons.info_outline, size: 20.0, color: Colors.white))), + child: Padding( + padding: EdgeInsets.all(1.0), + child: Icon(Icons.info_outline, + size: 20.0, color: Colors.white))), ), ), ), @@ -305,7 +323,10 @@ class _HeaderWidgetState extends State<_HeaderWidget> with ProducerMixin { child: Text( textAlign: TextAlign.center, "Anfahrtsbereich", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.white), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + color: Colors.white), ), ), ), @@ -313,4 +334,4 @@ class _HeaderWidgetState extends State<_HeaderWidget> with ProducerMixin { ), ); } -} \ No newline at end of file +} diff --git a/lib/popups/tasks_popups/zip_popup.dart b/lib/popups/tasks_popups/zip_popup.dart index 07e71ce..1b3eaaf 100644 --- a/lib/popups/tasks_popups/zip_popup.dart +++ b/lib/popups/tasks_popups/zip_popup.dart @@ -1,9 +1,15 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:stadtbote/tools/util.dart'; -showZipPopup(BuildContext context, String text, String buttonText, Function(String) onFinished) async { +showZipPopup(BuildContext context, String text, String buttonText, + Function(String) onFinished) async { + final TextEditingController textEditingController = TextEditingController(); + final FocusNode focusNode = FocusNode(); + await showDialog( context: context, + barrierDismissible: false, builder: (BuildContext context) { return PopScope( canPop: false, @@ -16,49 +22,65 @@ showZipPopup(BuildContext context, String text, String buttonText, Function(Stri } }, child: AlertDialog( - contentPadding: EdgeInsets.zero, - shadowColor: Colors.transparent, - backgroundColor: Colors.white, - content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) { - TextEditingController textEditingController = TextEditingController(); + contentPadding: EdgeInsets.zero, + shadowColor: Colors.transparent, + backgroundColor: Colors.white, + content: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (context.mounted && !focusNode.hasFocus) { + focusNode.requestFocus(); + } + }); - return SizedBox( - key: GlobalKey(), - height: 293, - width: MediaQuery.of(context).size.width * 0.8, - child: Container( - height: 100, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, - border: Border.all( - color: Colors.grey, - width: 0.5, - ), - ), - child: Padding( - padding: const EdgeInsets.all(35.0), - child: Column( - children: [ - Text(text, style: const TextStyle(fontWeight: FontWeight.bold)), - const SizedBox(height: 20), - Util.getDefaultTextField('Postleitzahl', - formatter: [DecimalTextInputFormatter(maxLength: 5, decimalPlaces: 0)], - textInputType: const TextInputType.numberWithOptions(signed: true, decimal: true), - controller: textEditingController, - autofocus: true), - const SizedBox(height: 20), - getDefaultButton( - buttonText, - () => { - if (_checkInput(context, textEditingController.text)) - {Navigator.of(context).pop(), onFinished(textEditingController.text)}, - }), - ], - ), - ), - )); - }))); + return SizedBox( + key: GlobalKey(), + height: 293, + width: MediaQuery.of(context).size.width * 0.8, + child: Container( + height: 100, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 0.5, + ), + ), + child: Padding( + padding: const EdgeInsets.all(35.0), + child: Column( + children: [ + Text(text, + style: const TextStyle( + fontWeight: FontWeight.bold)), + const SizedBox(height: 20), + Util.getDefaultTextField('Postleitzahl', + formatter: [ + FilteringTextInputFormatter.digitsOnly, + LengthLimitingTextInputFormatter(5), + ], + textInputType: TextInputType.number, + controller: textEditingController, + focusNode: focusNode, + autofocus: true), + const SizedBox(height: 20), + getDefaultButton( + buttonText, + () => { + if (_checkInput(context, + textEditingController.text)) + { + Navigator.of(context).pop(), + onFinished( + textEditingController.text) + }, + }), + ], + ), + ), + )); + }))); }); } diff --git a/pubspec.yaml b/pubspec.yaml index 0a3b25b..cf1eee3 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: 344.0.0+344 +version: 345.0.0+345 environment: sdk: '>=3.5.0 <4.0.0'