Локаль можно задать на этапе сборки
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'dart:convert'; // Пакет для обработки json с ответом от сервера.
|
||||
|
||||
import 'package:checker/common.dart';
|
||||
import 'package:checker/consts.dart';
|
||||
import 'package:checker/network.dart';
|
||||
import 'package:checker/base_state.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
@@ -14,36 +15,42 @@ class RegistrationScreen extends StatefulWidget {
|
||||
|
||||
class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
|
||||
@override String getTitle(BuildContext ctx) {
|
||||
return "registration";
|
||||
@override String getTitle() {
|
||||
return StringsLocalization.registration();
|
||||
}
|
||||
|
||||
@override getHint(BuildContext ctx) {
|
||||
return "idStore()";
|
||||
@override getHint() {
|
||||
return StringsLocalization.idStore();
|
||||
}
|
||||
|
||||
// Список виджетов, автоматически прокручиваемый вверх при открытии клавиатуры.
|
||||
@override Widget getScreenContent(BuildContext ctx) {
|
||||
print(new Strings().registration());
|
||||
/// Список виджетов, автоматически прокручиваемый вверх при открытии клавиатуры.
|
||||
@override Widget getScreenContent() {
|
||||
return new Container(
|
||||
child: new ListView(children: <Widget>[
|
||||
new Column(children: <Widget>[
|
||||
getLogo(),
|
||||
getHintLabel(ctx),
|
||||
getInputField(ctx),
|
||||
getButton(ctx)])
|
||||
getHintLabel(),
|
||||
getInputField(),
|
||||
getButton()])
|
||||
]));
|
||||
}
|
||||
|
||||
@override getTextWidget() {
|
||||
return new TextField(keyboardType: TextInputType.number,
|
||||
decoration: new InputDecoration.collapsed(hintText: getHint(),
|
||||
hintStyle: new TextStyle(color: greyTextColor, fontSize: 16.0)),
|
||||
onChanged: (text) => handleUserInput(text));
|
||||
}
|
||||
|
||||
/// Возвращает кнопку регистрации.
|
||||
getButton(BuildContext ctx) {
|
||||
getButton() {
|
||||
return new Container(margin: new EdgeInsets.only(top: 36.0), child:
|
||||
buildRaisedButton(ctx, "signUp()", getOnPressed(ctx)));
|
||||
buildRaisedButton(StringsLocalization.signUp(), getOnPressed()));
|
||||
}
|
||||
|
||||
// Возвращает обработчик нажатий на кнопку регистрации.
|
||||
getOnPressed(BuildContext ctx) {
|
||||
return _isValidMerchantID() && !loading ? () => _registerShop(ctx) : null;
|
||||
getOnPressed() {
|
||||
return _isValidMerchantID() && !loading ? () => _registerShop() : null;
|
||||
}
|
||||
|
||||
/// Токен кассы - это DIN код. DIN код - это специальный код динекта, максимальная его длина - 25 символов.
|
||||
@@ -53,15 +60,15 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
}
|
||||
|
||||
/// Показать progressBar, запросить токен.
|
||||
_registerShop(BuildContext ctx) {
|
||||
_registerShop() {
|
||||
setState(() {
|
||||
loading = true;
|
||||
_register(ctx);
|
||||
_register();
|
||||
});
|
||||
}
|
||||
|
||||
/// Получение от платформы id установки, формирование запроса на получение токена, сохранение токена.
|
||||
_register(BuildContext ctx) async {
|
||||
_register() async {
|
||||
if (await platform.invokeMethod('isOnline')) {
|
||||
createToken(textFieldValue, await platform.invokeMethod('getPosID')).then((response) {
|
||||
|
||||
@@ -69,14 +76,15 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
error = null;
|
||||
loading = false;
|
||||
});
|
||||
|
||||
|
||||
print(response.body);
|
||||
|
||||
Map parsedMap = JSON.decode(response.body);
|
||||
if (response.statusCode == 201) {
|
||||
token = parsedMap['token'];
|
||||
String token = parsedMap['token'];
|
||||
platform.invokeMethod('saveToken', {'token' : token});
|
||||
platform.invokeMethod('saveMerchantID', {'merchantID' : textFieldValue});
|
||||
pushRoute(ctx, new FinishRegistrationScreen());
|
||||
pushRoute(context, new FinishRegistrationScreen());
|
||||
} else {
|
||||
setState(() {
|
||||
error = parsedMap['errors'][0];
|
||||
|
||||
Reference in New Issue
Block a user