Небольшие исправления

This commit is contained in:
Ivan Murashov
2017-07-24 19:45:04 +03:00
parent 080c7ec471
commit ff0573d65d
5 changed files with 69 additions and 87 deletions

View File

@@ -48,7 +48,7 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
return textFieldValue.length > 0 && textFieldValue.length < 25;
}
/// Показать индикатор, запросить токен.
/// Показать progressBar, запросить токен.
_registerShop(BuildContext context) {
setState(() {
loading = true;
@@ -56,14 +56,6 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
});
}
/// Экран зависает на 1 сек, после этого выполняется переход на экран потверждения токена.
_registerDemo(BuildContext context) {
new Future.delayed(const Duration(milliseconds: 1000), () {
loading = false;
pushRoute(context, new FinishRegistrationScreen());
});
}
/// Получение от платформы id установки, формирование запроса на получение токена, сохранение токена.
_register(BuildContext context) async {
@@ -76,33 +68,27 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
'pos': pos,
};
pushRoute(context, new FinishRegistrationScreen());
// httpClient.post(url, body: body).then((response) {
httpClient.post(url, body: body).then((response) {
setState(() {
error = null;
loading = false;
});
// print(response.body);
// Map parsedMap = JSON.decode(response.body);
// setState(() {
// loading = false;
// });
// if (response.statusCode == 201) {
// token = parsedMap['token'];
// platform.invokeMethod('saveToken', {'token' : token});
// platform.invokeMethod('saveMerchantID', {'merchantID' : merchantID});
// pushRoute(context, new FinishRegistrationScreen());
// } else {
// setState(() {
// error = parsedMap['errors'][0];
// });
// }
// }).catchError((error) {
// setState(() {
// error = 'Отсутствует интернет соединение';
// });
// });
print(response.body);
Map parsedMap = JSON.decode(response.body);
if (response.statusCode == 201) {
token = parsedMap['token'];
platform.invokeMethod('saveToken', {'token' : token});
platform.invokeMethod('saveMerchantID', {'merchantID' : textFieldValue});
pushRoute(context, new FinishRegistrationScreen());
} else {
setState(() {
error = parsedMap['errors'][0];
});
}
}).catchError((error) {
print(error.toString());
});
}
}