Небольшие исправления
This commit is contained in:
@@ -11,12 +11,12 @@ class FinishRegistrationScreen extends StatefulWidget {
|
||||
|
||||
class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
|
||||
bool _tokenActive = true;
|
||||
bool _tokenActive = false;
|
||||
String _merchantID = '';
|
||||
|
||||
_RegistrationScreenState() {
|
||||
if (textFieldValue == "") {
|
||||
_getSavedMerchantID();
|
||||
getSavedMerchantID();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,17 +37,39 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
getLogo(),
|
||||
getHintLabel(),
|
||||
getDecoratedTextWidget(),
|
||||
_getMessage(),
|
||||
getMessage(),
|
||||
buildButton(new EdgeInsets.only(top: 36.0, left: buttonVerticalMargin, right: buttonVerticalMargin),
|
||||
buildRaisedButton(context, _tokenActive ? 'ЗАВЕРШИТЬ РЕГИСТРАЦИЮ' : 'ОБНОВИТЬ СТАТУС АКТИВАЦИИ',() => startScanner(context)))
|
||||
buildRaisedButton(context, _tokenActive ? 'ЗАВЕРШИТЬ РЕГИСТРАЦИЮ' : 'ОБНОВИТЬ СТАТУС АКТИВАЦИИ', () => handleTap()))
|
||||
]);
|
||||
}
|
||||
|
||||
handleTap() {
|
||||
if (_tokenActive) {
|
||||
startScanner(context);
|
||||
} else {
|
||||
checkToken(context).then((response) {
|
||||
|
||||
print(response.body);
|
||||
Map parsedMap = JSON.decode(response.body);
|
||||
|
||||
// Обновить экран, заменить сообщение о необходимости активации токена, на сообщние о том, что токен активен.
|
||||
setState(() {
|
||||
_tokenActive = parsedMap['active'];
|
||||
});
|
||||
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override Widget getTextWidget() {
|
||||
return new Row(children: <Widget>[new Text(_merchantID != null ? _merchantID : '', style: new TextStyle(color: Colors.black, fontSize: 16.0))]);
|
||||
}
|
||||
|
||||
_getSavedMerchantID() {
|
||||
/// Достаем сохраненный в SharedPreferences merchantID.
|
||||
getSavedMerchantID() {
|
||||
platform.invokeMethod('getMerchantID').then((result) {
|
||||
setState(() {
|
||||
_merchantID = result;
|
||||
@@ -56,54 +78,29 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
_getMessage() {
|
||||
/// Метод возвращает контейнер с текстом сообщения и бэкграундом.
|
||||
getMessage() {
|
||||
return new Container(height: _tokenActive ? 72.0 : 108.0, decoration: _getDecoraionForMessageField(),
|
||||
margin: new EdgeInsets.only(top: 20.0, left: 12.0, right: 12.0),
|
||||
padding: new EdgeInsets.only(bottom: 22.0, left: 14.0, right: 14.0),
|
||||
child: new Center(child: new Text(_getMessageText(),
|
||||
textAlign: TextAlign.center, style: new TextStyle(height: 1.5, fontWeight: FontWeight.bold, fontSize: 14.0, color: _tokenActive ? tokenActiveTextColor : tokenActivateTextColor))));
|
||||
child: new Center(child: getMessageTextWidget()));
|
||||
}
|
||||
|
||||
_getMessageText() {
|
||||
/// Метод возвращает виджет с текстом сообщения, всеми его привязками и стилями.
|
||||
getMessageTextWidget() {
|
||||
return new Text(getMessageString(), textAlign: TextAlign.center,
|
||||
style: new TextStyle(height: 1.5, fontWeight: FontWeight.bold, fontSize: 14.0,
|
||||
color: _tokenActive ? tokenActiveTextColor : tokenActivateTextColor));
|
||||
}
|
||||
|
||||
/// Получаем текст сообщения, в зависимости от статуса активации.
|
||||
getMessageString() {
|
||||
return _tokenActive ? 'Программа активирована' : 'Запрос на активацию программы отправлен, дождитесь подтверждения активации администратором';
|
||||
}
|
||||
|
||||
/// Фоновое изображение для сообщения.
|
||||
Decoration _getDecoraionForMessageField() {
|
||||
return new BoxDecoration(image: new DecorationImage(
|
||||
image: new ExactAssetImage(_tokenActive ? active_token_bg_png : activate_token_bg_png), fit: _tokenActive ? BoxFit.fitWidth : BoxFit.fill));
|
||||
}
|
||||
|
||||
/// Метод возвращает кнопку, которая запускает отправку токена кассы на сервер.
|
||||
_getButton(BuildContext context) {
|
||||
double buttonHeight = 42.0;
|
||||
double topMargin = 8.0;
|
||||
return new Container(margin: new EdgeInsets.only(top: topMargin), height: buttonHeight,
|
||||
child: new RaisedButton(child: new Text(,
|
||||
style: new TextStyle(fontSize: 14.0, color: Colors.white)),
|
||||
onPressed: () {
|
||||
|
||||
startScanner(context);
|
||||
|
||||
|
||||
// if (_tokenActive) {
|
||||
// startScanner(context);
|
||||
// } else {
|
||||
// checkToken(context).then((response) {
|
||||
|
||||
// print(response.body);
|
||||
// Map parsedMap = JSON.decode(response.body);
|
||||
|
||||
// // Обновить экран, заменить сообщение о необходимости активации токена, на сообщние о том, что токен активен.
|
||||
// setState(() {
|
||||
// _tokenActive = parsedMap['active'];
|
||||
// });
|
||||
|
||||
// }).catchError((error) {
|
||||
// print(error.toString());
|
||||
// return false;
|
||||
// });
|
||||
// }
|
||||
},
|
||||
color: primaryColor));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user