72 lines
2.8 KiB
Dart
72 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:stadtbote/tools/util.dart';
|
|
|
|
showZipPopup(BuildContext context, String text, String buttonText, Function(String) onFinished) async {
|
|
await showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return WillPopScope(
|
|
onWillPop: () async {
|
|
return await taskDialogSecurityException(context);
|
|
},
|
|
child: AlertDialog(
|
|
contentPadding: EdgeInsets.zero,
|
|
shadowColor: Colors.transparent,
|
|
backgroundColor: Colors.white,
|
|
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
|
TextEditingController textEditingController = TextEditingController();
|
|
|
|
return SizedBox(
|
|
key: GlobalKey(),
|
|
height: 280,
|
|
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)},
|
|
}),
|
|
],
|
|
),
|
|
),
|
|
));
|
|
})));
|
|
});
|
|
}
|
|
|
|
bool _checkInput(BuildContext context, String input) {
|
|
String message = '';
|
|
|
|
if (input.length != 5) {
|
|
message += 'Bitte geben Sie eine fünfstellige Postleitzahl ein';
|
|
}
|
|
|
|
if (message.isNotEmpty) {
|
|
showAlertDialog(context, 'Fehler', message);
|
|
}
|
|
|
|
return message.isEmpty;
|
|
}
|