Erweiterungen
This commit is contained in:
1 parent
98581c9a39
commit
f9ee90d861
12 files changed
+59
-23
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import 'package:stadtbote/model/status.dart';
|
||||
|
||||
class RankingUpdated {
|
||||
RankingUpdated();
|
||||
|
||||
@@ -56,9 +56,9 @@ class MqttCore {
|
||||
|
||||
late int _reconnectDelay = 0;
|
||||
|
||||
late Timer? _reconnectTimer = null;
|
||||
Timer? _reconnectTimer;
|
||||
|
||||
late Timer? _trackTimer = null;
|
||||
Timer? _trackTimer;
|
||||
|
||||
MqttCore() {
|
||||
_disconnectInProgress = false;
|
||||
|
||||
+29
-3
@@ -117,7 +117,7 @@ class Util {
|
||||
FocusNode? focusNode,
|
||||
IconButton? iconButton,
|
||||
int? maxLines = 1,
|
||||
TextInputType? type,
|
||||
TextInputType? textInputType,
|
||||
List<TextInputFormatter>? formatter,
|
||||
Function()? onTap,
|
||||
bool? autofocus}) {
|
||||
@@ -135,7 +135,7 @@ class Util {
|
||||
focusNode: focusNode,
|
||||
maxLines: maxLines,
|
||||
onTap: onTap,
|
||||
keyboardType: type,
|
||||
keyboardType: textInputType,
|
||||
inputFormatters: formatter,
|
||||
autofocus: (autofocus != null) ? autofocus : false,
|
||||
decoration: InputDecoration(
|
||||
@@ -337,4 +337,30 @@ Future<void> showAlertDialog(BuildContext context, String title, String message)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DecimalTextInputFormatter extends TextInputFormatter {
|
||||
int maxLength;
|
||||
|
||||
int decimalPlaces;
|
||||
|
||||
DecimalTextInputFormatter({required this.maxLength, required this.decimalPlaces});
|
||||
|
||||
@override
|
||||
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
|
||||
var text = newValue.text;
|
||||
String? filteredText = "";
|
||||
|
||||
if (text != "") {
|
||||
RegExp regExp;
|
||||
if (decimalPlaces > 0) {
|
||||
regExp = RegExp(r'[0-9]+[,]{0,1}[0-9]{0,' + decimalPlaces.toString() + '}');
|
||||
} else {
|
||||
regExp = RegExp(r'[0-9]{0,' + maxLength.toString() +'}');
|
||||
}
|
||||
filteredText = regExp.stringMatch(text);
|
||||
}
|
||||
|
||||
return TextEditingValue(text: filteredText ?? oldValue.text);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user