Камера не падает, проверка интернет соединения в условиях отсутствия интернета, буквенная клавиатура на вводе суммы
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:convert';
|
||||
import 'dart:async';
|
||||
import 'dart:core';
|
||||
|
||||
import 'main.dart';
|
||||
import 'common.dart';
|
||||
@@ -23,9 +24,12 @@ class PurchaseScreen extends StatefulWidget {
|
||||
|
||||
class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
|
||||
RegExp exp;
|
||||
|
||||
PurchaseScreenState(String userString, String card) {
|
||||
this.user = JSON.decode(userString);
|
||||
this.card = card;
|
||||
exp = new RegExp(r'''^(?!0\.00)\d{1,11}(\.\d{0,2})?$''');
|
||||
getLoyality(user['loyalty_url']);
|
||||
}
|
||||
|
||||
@@ -65,30 +69,36 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
|
||||
/// Смена состояния экрана при изменении текста в поле ввода.
|
||||
@override handleUserInput(String tmpString) {
|
||||
|
||||
setState(() {
|
||||
double.parse(tmpString);
|
||||
tmpString = tmpString.replaceAll('-', '');
|
||||
tmpString = tmpString.replaceAll(',', '');
|
||||
print(tmpString);
|
||||
if (tmpString.contains('.')) {
|
||||
int dotIndex = tmpString.indexOf('.');
|
||||
integerPart = tmpString.substring(0, dotIndex);
|
||||
fractionalPart = tmpString.substring(dotIndex + 1, tmpString.length);
|
||||
if (fractionalPart.length > 2) {
|
||||
fractionalPart = fractionalPart.substring(0, 2);
|
||||
|
||||
if (tmpString.length == 0 || exp.hasMatch(tmpString)) {
|
||||
if (tmpString.contains('.')) {
|
||||
int dotIndex = tmpString.indexOf('.');
|
||||
integerPart = tmpString.substring(0, dotIndex);
|
||||
fractionalPart = tmpString.substring(dotIndex + 1, tmpString.length);
|
||||
if (fractionalPart.length > 2) {
|
||||
fractionalPart = fractionalPart.substring(0, 2);
|
||||
}
|
||||
controller.text = '${integerPart}.${fractionalPart}';
|
||||
} else {
|
||||
integerPart = tmpString;
|
||||
controller.text = tmpString;
|
||||
}
|
||||
controller.text = '${integerPart}.${fractionalPart}';
|
||||
textFieldValue = tmpString;
|
||||
|
||||
} else {
|
||||
integerPart = tmpString;
|
||||
controller.text = tmpString;
|
||||
tmpString = tmpString.substring(0, tmpString.length - 1);
|
||||
controller.text = tmpString.replaceAll('a', '');
|
||||
textFieldValue = tmpString;
|
||||
}
|
||||
textFieldValue = tmpString;
|
||||
});
|
||||
}
|
||||
|
||||
@override getTextWidget() {
|
||||
return new TextField(decoration: new InputDecoration.collapsed(hintText: getHint(),
|
||||
return new TextField(keyboardType: TextInputType.text, decoration: new InputDecoration.collapsed(hintText: getHint(),
|
||||
hintStyle: new TextStyle(color: greyTextColor, fontSize: 16.0)),
|
||||
controller: controller,
|
||||
onChanged: (text) => handleUserInput(text));
|
||||
}
|
||||
|
||||
@@ -136,6 +146,10 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
temporaryFractional = temporaryFractional + '0';
|
||||
}
|
||||
|
||||
if (temporaryInteger.length == 0) {
|
||||
temporaryInteger = '0';
|
||||
}
|
||||
|
||||
return temporaryInteger + '.' + temporaryFractional;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user