Поправил отзывчивость кнопок валют на экране валюты, исправил отображение названий валюты на экранах проведения покупки (рубль, рубля, рублей) для русской локали
This commit is contained in:
@@ -26,24 +26,6 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
/// Введенное пользователем значение.
|
||||
String dinCode = '';
|
||||
|
||||
@override Widget build(BuildContext ctx) {
|
||||
|
||||
if (helper == null) {
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_) {
|
||||
if (app == null) {
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
app = flavor;
|
||||
setState(() {
|
||||
onStart();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return getMainWidget();
|
||||
}
|
||||
|
||||
Widget getMainWidget() {
|
||||
return app == null ? getBackground() : new Scaffold(appBar: getAppBar(),
|
||||
body: new Stack(children: <Widget>[
|
||||
|
||||
@@ -13,6 +13,10 @@ abstract class SettingsBaseState<T extends StatefulWidget> extends BaseState<T>
|
||||
|
||||
int selectedItem;
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return getMainWidget();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget getScreenContent() {
|
||||
|
||||
|
||||
@@ -130,9 +130,9 @@ showYesNoDialog(BuildContext context, String title, String content, VoidCallback
|
||||
|
||||
getCurrencyTitle(int code) {
|
||||
switch(code) {
|
||||
case 643: return StringsLocalization.ruble();
|
||||
case 840: return StringsLocalization.dollar();
|
||||
case 980: return StringsLocalization.hryvna();
|
||||
case 643: return StringsLocalization.nominativeRuble();
|
||||
case 840: return StringsLocalization.nominativeDollar();
|
||||
case 980: return StringsLocalization.nominativeHryvna();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"logout" : MessageLookupByLibrary.simpleMessage("Exit"),
|
||||
"currency" : MessageLookupByLibrary.simpleMessage("Currency"),
|
||||
"locale" : MessageLookupByLibrary.simpleMessage("Language"),
|
||||
"rubles" : MessageLookupByLibrary.simpleMessage("Ruble"),
|
||||
"dollars" : MessageLookupByLibrary.simpleMessage("Dollar"),
|
||||
"ruble" : MessageLookupByLibrary.simpleMessage("Ruble"),
|
||||
"dollar" : MessageLookupByLibrary.simpleMessage("Dollar"),
|
||||
"hryvna" : MessageLookupByLibrary.simpleMessage("Hryvna")
|
||||
|
||||
};
|
||||
|
||||
@@ -44,8 +44,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"logout" : MessageLookupByLibrary.simpleMessage("Salir"),
|
||||
"currency" : MessageLookupByLibrary.simpleMessage("La Moneda"),
|
||||
"locale" : MessageLookupByLibrary.simpleMessage("La lengua"),
|
||||
"rubles" : MessageLookupByLibrary.simpleMessage("Ruble"),
|
||||
"dollars" : MessageLookupByLibrary.simpleMessage("Dollar"),
|
||||
"ruble" : MessageLookupByLibrary.simpleMessage("Ruble"),
|
||||
"dollar" : MessageLookupByLibrary.simpleMessage("Dollar"),
|
||||
"hryvna" : MessageLookupByLibrary.simpleMessage("Hryvna")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"carry_purchase" : MessageLookupByLibrary.simpleMessage("Проведение покупки"),
|
||||
"complite_activ" : MessageLookupByLibrary.simpleMessage("Завершить регистрацию"),
|
||||
"complite_purchase" : MessageLookupByLibrary.simpleMessage("Завершить покупку"),
|
||||
"confirm_purchase" : MessageLookupByLibrary.simpleMessage("Вы подтверждаете покупку на %s рублей"),
|
||||
"confirm_purchase" : MessageLookupByLibrary.simpleMessage("Вы подтверждаете покупку на %s %s"),
|
||||
"confirmation" : MessageLookupByLibrary.simpleMessage("Подтверждение"),
|
||||
"no" : MessageLookupByLibrary.simpleMessage("Нет"),
|
||||
"purchase_complite" : MessageLookupByLibrary.simpleMessage("Покупка на сумму %s рублей проведена"),
|
||||
"purchase_complite" : MessageLookupByLibrary.simpleMessage("Покупка на сумму %s %s проведена"),
|
||||
"registration" : MessageLookupByLibrary.simpleMessage("Регистрация"),
|
||||
"request_sent_wait_activ" : MessageLookupByLibrary.simpleMessage("Запрос на активацию приложения отправлен, дождитесь подтверждения активации администратором"),
|
||||
"reward" : MessageLookupByLibrary.simpleMessage("Вознаграждение"),
|
||||
@@ -44,8 +44,14 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"logout" : MessageLookupByLibrary.simpleMessage("Выход"),
|
||||
"currency" : MessageLookupByLibrary.simpleMessage("Валюта"),
|
||||
"locale" : MessageLookupByLibrary.simpleMessage("Язык"),
|
||||
"rubles" : MessageLookupByLibrary.simpleMessage("Рубль"),
|
||||
"dollars" : MessageLookupByLibrary.simpleMessage("Доллар"),
|
||||
"hryvna" : MessageLookupByLibrary.simpleMessage("Гривна")
|
||||
"nominative_ruble": MessageLookupByLibrary.simpleMessage("Рубль"),
|
||||
"singular_ruble": MessageLookupByLibrary.simpleMessage("Рубля"),
|
||||
"plural_ruble": MessageLookupByLibrary.simpleMessage("Рублей"),
|
||||
"nominative_dollar": MessageLookupByLibrary.simpleMessage("Доллар"),
|
||||
"singular_dollar": MessageLookupByLibrary.simpleMessage("Доллара"),
|
||||
"plural_dollar": MessageLookupByLibrary.simpleMessage("Долларов"),
|
||||
"nominative_hryvna": MessageLookupByLibrary.simpleMessage("Гривна"),
|
||||
"singular_hryvna": MessageLookupByLibrary.simpleMessage("Гривны"),
|
||||
"plural_hryvna": MessageLookupByLibrary.simpleMessage("Гривен")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"logout" : MessageLookupByLibrary.simpleMessage("Вихід"),
|
||||
"currency" : MessageLookupByLibrary.simpleMessage("Валюта"),
|
||||
"locale" : MessageLookupByLibrary.simpleMessage("Мова"),
|
||||
"rubles" : MessageLookupByLibrary.simpleMessage("Ruble"),
|
||||
"dollars" : MessageLookupByLibrary.simpleMessage("Dollar"),
|
||||
"ruble" : MessageLookupByLibrary.simpleMessage("Ruble"),
|
||||
"dollar" : MessageLookupByLibrary.simpleMessage("Dollar"),
|
||||
"hryvna" : MessageLookupByLibrary.simpleMessage("Hryvna")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ class _CurrenciesState extends SettingsBaseState<CurrenciesScreen> {
|
||||
@override
|
||||
List<String> getOptions() {
|
||||
|
||||
String ruble = StringsLocalization.ruble();
|
||||
String dollar = StringsLocalization.dollar();
|
||||
String hryvna = StringsLocalization.hryvna();
|
||||
String ruble = StringsLocalization.nominativeRuble();
|
||||
String dollar = StringsLocalization.nominativeDollar();
|
||||
String hryvna = StringsLocalization.nominativeHryvna();
|
||||
|
||||
return [ruble, dollar, hryvna];
|
||||
}
|
||||
|
||||
@@ -55,6 +55,10 @@ class FAQScreenState<T> extends BaseState<FAQScreen> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return getScreenContent();
|
||||
}
|
||||
|
||||
/// Метод возвращает ListView с блоками faq.
|
||||
@override Widget getScreenContent() {
|
||||
return new WillPopScope(onWillPop: onWillPop, child: new ListView.builder(
|
||||
|
||||
@@ -1,29 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:convert'; // Пакет для обработки json с ответом от сервера.
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:checker/base/base_screen.dart';
|
||||
import 'package:checker/base/base_state.dart';
|
||||
import 'package:checker/common.dart';
|
||||
import 'package:checker/consts.dart';
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:checker/network.dart';
|
||||
import 'package:checker/base/base_state.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class FinishRegistrationScreen extends StatefulWidget {
|
||||
@override State createState() => new _RegistrationScreenState();
|
||||
class FinishRegistrationScreen extends BaseScreen {
|
||||
|
||||
FinishRegistrationScreen(helper, app) : super(helper, app);
|
||||
|
||||
@override State createState() => new RegistrationScreenState(helper, app);
|
||||
}
|
||||
|
||||
class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
class RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
|
||||
RegistrationScreenState(SqliteHelper helper, String app) {
|
||||
this.helper = helper;
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
bool _tokenActive = false;
|
||||
String _merchantID;
|
||||
String _merchantID = '';
|
||||
|
||||
@override void onStart() {
|
||||
@override Widget build(BuildContext context) {
|
||||
if (_merchantID == '') {
|
||||
helper.getMerchantID().then((result) {
|
||||
setState(() {
|
||||
_merchantID = result;
|
||||
});
|
||||
});
|
||||
}
|
||||
return getMainWidget();
|
||||
}
|
||||
|
||||
@override String getTitle() {
|
||||
return StringsLocalization.registration();
|
||||
@@ -54,7 +67,6 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
if (await platform.invokeMethod('isOnline')) {
|
||||
String token = await helper.getToken();
|
||||
checkTokenStatus(token).then((response) {
|
||||
|
||||
print(response.body);
|
||||
Map parsedMap = JSON.decode(response.body);
|
||||
|
||||
@@ -72,13 +84,16 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
}
|
||||
|
||||
@override getTextWidget() {
|
||||
return new Row(children: <Widget>[new Text(_merchantID != null ? _merchantID : '',
|
||||
style: new TextStyle(color: Colors.black, fontSize: 16.0))]);
|
||||
return new Row(
|
||||
children: <Widget>[new Text(_merchantID != null ? _merchantID : '',
|
||||
style: new TextStyle(color: Colors.black, fontSize: 16.0))
|
||||
]);
|
||||
}
|
||||
|
||||
/// Метод возвращает контейнер с текстом сообщения и бэкграундом.
|
||||
getMessage() {
|
||||
return new Container(height: _tokenActive ? 72.0 : 108.0, decoration: _getDecorationForMessageField(),
|
||||
return new Container(height: _tokenActive ? 72.0 : 108.0,
|
||||
decoration: _getDecorationForMessageField(),
|
||||
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: getMessageTextWidget()));
|
||||
@@ -87,8 +102,11 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
/// Метод возвращает виджет с текстом сообщения, всеми его привязками и стилями.
|
||||
getMessageTextWidget() {
|
||||
return new Text(getMessageString(), textAlign: TextAlign.center,
|
||||
style: new TextStyle(height: 1.5, fontWeight: FontWeight.bold, fontSize: 14.0,
|
||||
color: _tokenActive ? tokenActiveTextColor : tokenActivateTextColor));
|
||||
style: new TextStyle(
|
||||
height: 1.5, fontWeight: FontWeight.bold, fontSize: 14.0,
|
||||
color: _tokenActive
|
||||
? tokenActiveTextColor
|
||||
: tokenActivateTextColor));
|
||||
}
|
||||
|
||||
/// Получаем текст сообщения, в зависимости от статуса активации.
|
||||
@@ -101,7 +119,8 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
/// Фоновое изображение для сообщения.
|
||||
Decoration _getDecorationForMessageField() {
|
||||
return new BoxDecoration(image: new DecorationImage(
|
||||
image: new ExactAssetImage(_tokenActive ? active_token_bg_png : activate_token_bg_png),
|
||||
image: new ExactAssetImage(
|
||||
_tokenActive ? active_token_bg_png : activate_token_bg_png),
|
||||
fit: _tokenActive ? BoxFit.fitWidth : BoxFit.fill));
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:convert';
|
||||
@@ -34,8 +35,21 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
@override void onStart() {
|
||||
@override Widget build(BuildContext ctx) {
|
||||
if (helper == null) {
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_) {
|
||||
if (app == null) {
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
app = flavor;
|
||||
setState(() {
|
||||
getLoyalty(user['loyalty_url']);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return getMainWidget();
|
||||
}
|
||||
|
||||
bool purchaseInProgress = false;
|
||||
@@ -126,8 +140,8 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
this.loyalty = '${user['discount']}%';
|
||||
} else {
|
||||
List amountToBonus = bonuses['amount_to_bonus'];
|
||||
double loyalityVal = (double.parse(amountToBonus[1]) / amountToBonus[0]) * 100;
|
||||
this.loyalty = '${loyalityVal.toStringAsFixed(0)}%';
|
||||
double loyaltyVal = (double.parse(amountToBonus[1]) / amountToBonus[0]) * 100;
|
||||
this.loyalty = '${loyaltyVal.toStringAsFixed(0)}%';
|
||||
}
|
||||
});
|
||||
}).catchError((error) {
|
||||
@@ -136,6 +150,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Переделать? чтобы работало хорошо
|
||||
String _cleanupNumber(String text){
|
||||
String tmp = text
|
||||
.replaceAll(' ', '')
|
||||
@@ -174,9 +189,10 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
|
||||
onPurchaseClick() {
|
||||
String val = _parseSum(controller.text);
|
||||
helper.getCurrency().then((currency) {
|
||||
showDialog(context: context, child: new AlertDialog(
|
||||
title: new Text(StringsLocalization.confirmation()),
|
||||
content: new Text(StringsLocalization.confirmPurchase(val)),
|
||||
content: new Text(StringsLocalization.confirmPurchase(val, currency)),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
@@ -191,6 +207,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
},
|
||||
)
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
purchase(String sumTotal) async {
|
||||
@@ -221,14 +238,13 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
print(response.body);
|
||||
Map parsedMap = JSON.decode(response.body);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
|
||||
if (parsedMap.containsKey('errors')) {
|
||||
List<String> errors = parsedMap['errors'];
|
||||
// TODO: ПОказывать сообщение с ошибкой!
|
||||
Scaffold.of(context).showSnackBar(new SnackBar(content: new Text(errors[0])));
|
||||
} else {
|
||||
helper.close().then((_) {
|
||||
Navigator.of(context).pop();
|
||||
pushRouteReplacement(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name']));
|
||||
});
|
||||
pushRouteReplacement(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name'], helper, app));
|
||||
}
|
||||
|
||||
}).catchError((error) {
|
||||
|
||||
@@ -1,26 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:checker/base/base_state.dart';
|
||||
import 'package:checker/common.dart';
|
||||
import 'package:checker/consts.dart';
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
import 'package:checker/base/base_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Экран проведения покупки.
|
||||
class PurchaseSuccessScreen extends StatefulWidget {
|
||||
|
||||
PurchaseSuccessScreen(this.val, this.name);
|
||||
PurchaseSuccessScreen(this.val, this.name, this.helper, this.app);
|
||||
|
||||
final String val;
|
||||
final String name;
|
||||
final String app;
|
||||
final SqliteHelper helper;
|
||||
|
||||
@override State createState() => new PurchaseSuccessScreenState(val, name);
|
||||
@override State createState() =>
|
||||
new PurchaseSuccessScreenState(val, name, helper, app);
|
||||
}
|
||||
|
||||
class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
|
||||
PurchaseSuccessScreenState(this.sum, this.username);
|
||||
PurchaseSuccessScreenState(String sum, String username, SqliteHelper helper,
|
||||
String app) {
|
||||
this.sum = sum;
|
||||
this.username = username;
|
||||
this.helper = helper;
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
String sum;
|
||||
String username;
|
||||
String sum, username;
|
||||
int currency;
|
||||
|
||||
@override String getTitle() {
|
||||
return StringsLocalization.carryingPurchase();
|
||||
@@ -30,6 +40,17 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
if (currency == null) {
|
||||
helper.getCurrency().then((currency) {
|
||||
setState(() {
|
||||
this.currency = currency;
|
||||
});
|
||||
});
|
||||
}
|
||||
return getMainWidget();
|
||||
}
|
||||
|
||||
@override Widget getScreenContent() {
|
||||
return new Column(children: <Widget>[
|
||||
getValueWithDescription(StringsLocalization.buyer(), username),
|
||||
@@ -50,14 +71,22 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
}
|
||||
|
||||
getSuccessMessage() {
|
||||
return new Row(children: <Widget>[new Expanded(child: new Container(margin: new EdgeInsets.only(top: 20.0), height: 64.0,
|
||||
return new Row(children: <Widget>[new Expanded(child: new Container(
|
||||
margin: new EdgeInsets.only(top: 20.0), height: 64.0,
|
||||
decoration: new BoxDecoration(color: greenBackground),
|
||||
child: new Center(child: new Text(getMessageTitle(), textAlign: TextAlign.center,
|
||||
style: new TextStyle(fontWeight: FontWeight.bold, color: tokenActiveTextColor)))))]);
|
||||
child: new Center(
|
||||
child: new Text(getMessageTitle(), textAlign: TextAlign.center,
|
||||
style: new TextStyle(fontWeight: FontWeight.bold,
|
||||
color: tokenActiveTextColor)))))
|
||||
]);
|
||||
}
|
||||
|
||||
getMessageTitle() {
|
||||
return StringsLocalization.purchaseCompleted(sum);
|
||||
if (currency != null) {
|
||||
return StringsLocalization.purchaseCompleted(sum, currency);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +1,35 @@
|
||||
import 'package:checker/base/base_screen.dart';
|
||||
import 'package:checker/screens/finish_registration.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:convert'; // Пакет для обработки json с ответом от сервера.
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:checker/base/base_screen.dart';
|
||||
import 'package:checker/base/base_state.dart';
|
||||
import 'package:checker/common.dart';
|
||||
import 'package:checker/consts.dart';
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:checker/network.dart';
|
||||
import 'package:checker/base/base_state.dart';
|
||||
import 'package:checker/screens/finish_registration.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
// Пакет для обработки json с ответом от сервера.
|
||||
|
||||
|
||||
/// Экран регистрации магазина и кассы.
|
||||
class RegistrationScreen extends BaseScreen {
|
||||
|
||||
RegistrationScreen(helper, app) : super(helper, app);
|
||||
|
||||
@override State createState() => new _RegistrationScreenState();
|
||||
@override State createState() => new RegistrationScreenState(helper, app);
|
||||
}
|
||||
|
||||
class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
class RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
|
||||
RegistrationScreenState(SqliteHelper helper, String app) {
|
||||
this.helper = helper;
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext ctx) {
|
||||
return getMainWidget();
|
||||
}
|
||||
|
||||
@override String getTitle() {
|
||||
return StringsLocalization.registration();
|
||||
@@ -35,7 +47,8 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
getLogo(),
|
||||
getHintLabel(),
|
||||
getInputField(),
|
||||
getButton()])
|
||||
getButton()
|
||||
])
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -74,11 +87,9 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
/// Получение от платформы id установки, формирование запроса на получение токена, сохранение токена.
|
||||
_register() async {
|
||||
if (await platform.invokeMethod('isOnline')) {
|
||||
|
||||
String posID = await helper.getPosID();
|
||||
|
||||
createToken(dinCode, posID).then((response) {
|
||||
|
||||
setState(() {
|
||||
error = null;
|
||||
loading = false;
|
||||
@@ -90,8 +101,7 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
|
||||
if (response.statusCode == 201) {
|
||||
helper.createSession(dinCode, posID, parsedMap['token']).then((_) {
|
||||
helper.close();
|
||||
pushRouteReplacement(context, new FinishRegistrationScreen());
|
||||
pushRouteReplacement(context, new FinishRegistrationScreen(helper, app));
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
|
||||
@@ -61,8 +61,10 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
List<Widget> getSettings() {
|
||||
List<Widget> widgets = new List();
|
||||
for (MenuItem item in menuItems) {
|
||||
if (item.selectedValue != '') {
|
||||
widgets.add(getSettingsItem(item));
|
||||
}
|
||||
}
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@@ -77,15 +79,19 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
fontWeight: FontWeight.w600,
|
||||
color: faqGrey,
|
||||
fontSize: 14.0))),
|
||||
new Text(getCurrencyTitle(int.parse(item.selectedValue)), style: new TextStyle(
|
||||
fontWeight: FontWeight.w400, color: faqGrey, fontSize: 14.0)),
|
||||
new Text(getCurrencyTitle(int.parse(item.selectedValue)),
|
||||
style: new TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: faqGrey,
|
||||
fontSize: 14.0)),
|
||||
getArrow()
|
||||
]))));
|
||||
}
|
||||
|
||||
void onPressed(int position) {
|
||||
switch (position) {
|
||||
case 0 : return pushRoute(context, new CurrenciesScreen(helper, app));
|
||||
case 0 :
|
||||
return pushRoute(context, new CurrenciesScreen(helper, app));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,20 @@ class SplashScreen extends StatefulWidget {
|
||||
|
||||
class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
|
||||
@override Widget getMainWidget() {
|
||||
@override Widget build(BuildContext ctx) {
|
||||
if (helper == null) {
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_) {
|
||||
if (app == null) {
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
app = flavor;
|
||||
setState(() {
|
||||
onStart();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return getScreenContent();
|
||||
}
|
||||
|
||||
@@ -110,10 +123,7 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
checkTokenStatus(token).then((statusResponse) {
|
||||
handleStatusResponse(statusResponse, helper);
|
||||
}).catchError((error) {
|
||||
helper.close().then((_) {
|
||||
print(error.toString());
|
||||
return false;
|
||||
});
|
||||
handleError(error.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -157,12 +167,13 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
|
||||
createToken(merchantID, posID).then((response) {
|
||||
if (response.statusCode == 409) {
|
||||
helper.close();
|
||||
pushRouteReplacement(context, new FinishRegistrationScreen());
|
||||
pushRouteReplacement(context, new FinishRegistrationScreen(helper, app));
|
||||
} else if (response.statusCode == 201) {
|
||||
clearToken(response, helper);
|
||||
}
|
||||
}).catchError((error) => print(error.toString()));
|
||||
}).catchError((error) {
|
||||
handleError(error.toString());
|
||||
});
|
||||
}
|
||||
|
||||
/// Очищаем бд, делаем запрос на удаление токена.
|
||||
@@ -173,9 +184,16 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
Navigator.of(context).pop();
|
||||
pushRouteReplacement(context, new RegistrationScreen(helper, app));
|
||||
}).catchError((error) {
|
||||
helper.close();
|
||||
print(error.toString());
|
||||
handleError(error.toString());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// Закрываем соединение, логируем ошибку.
|
||||
void handleError(String error) {
|
||||
helper.close().then((_) {
|
||||
print(error.toString());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,64 @@ class StringsLocalization {
|
||||
return initializeMessages(locale);
|
||||
}
|
||||
|
||||
static String confirmPurchase(String val) {
|
||||
return sprintf(Intl.message('confirm_purchase', name: 'confirm_purchase', locale: Intl.defaultLocale), [val]);
|
||||
static String declineCurrency(int num, int code) {
|
||||
|
||||
int residual = num % 100;
|
||||
if (residual >= 20) {
|
||||
residual %= 10;
|
||||
}
|
||||
|
||||
static String purchaseCompleted(String val) {
|
||||
return sprintf(Intl.message('purchase_complite', name: 'purchase_complite', locale: Intl.defaultLocale), [val]);
|
||||
List<String> strings = currencies(code);
|
||||
|
||||
switch (residual) {
|
||||
case 1:
|
||||
return strings[0];
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
return strings[1];
|
||||
default: // case 0, 5-19
|
||||
return strings[2];
|
||||
}
|
||||
}
|
||||
|
||||
static List<String> currencies(int code) {
|
||||
|
||||
String nominative, singular, plural;
|
||||
|
||||
switch (code) {
|
||||
case 643:
|
||||
nominative = nominativeRuble();
|
||||
singular = singularRuble();
|
||||
plural = pluralRuble();
|
||||
break;
|
||||
case 840:
|
||||
nominative = nominativeDollar();
|
||||
singular = singularDollar();
|
||||
plural = pluralDollar();
|
||||
break;
|
||||
case 980:
|
||||
nominative = nominativeHryvna();
|
||||
singular = singularHryvna();
|
||||
plural = pluralHryvna();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return [nominative, singular, plural];
|
||||
}
|
||||
|
||||
|
||||
static String confirmPurchase(String val, int code) {
|
||||
String trimmedVal =val.substring(0, val.length - 3);
|
||||
print(trimmedVal);
|
||||
return sprintf(Intl.message('confirm_purchase', name: 'confirm_purchase', locale: Intl.defaultLocale), [trimmedVal, declineCurrency(int.parse(trimmedVal), code)]);
|
||||
}
|
||||
|
||||
static String purchaseCompleted(String val, int code) {
|
||||
String trimmedVal =val.substring(0, val.length - 3);
|
||||
print(trimmedVal);
|
||||
return sprintf(Intl.message('purchase_complite', name: 'purchase_complite', locale: Intl.defaultLocale), [val, declineCurrency(int.parse(trimmedVal), code)]);
|
||||
}
|
||||
|
||||
static String registration() => Intl.message('registration', name: 'registration', locale: Intl.defaultLocale);
|
||||
@@ -46,7 +98,16 @@ class StringsLocalization {
|
||||
static String locale() => Intl.message('locale', name: 'locale', locale: Intl.defaultLocale);
|
||||
|
||||
// Валюты
|
||||
static String ruble() => Intl.message('rubles', name: 'rubles', locale: Intl.defaultLocale);
|
||||
static String dollar() => Intl.message('dollars', name: 'dollars', locale: Intl.defaultLocale);
|
||||
static String hryvna() => Intl.message('hryvna', name: 'hryvna', locale: Intl.defaultLocale);
|
||||
static String nominativeRuble() => Intl.message('nominative_ruble', name: 'nominative_ruble', locale: Intl.defaultLocale);
|
||||
static String singularRuble() => Intl.message('singular_ruble', name: 'singular_ruble', locale: Intl.defaultLocale);
|
||||
static String pluralRuble() => Intl.message('plural_ruble', name: 'plural_ruble', locale: Intl.defaultLocale);
|
||||
|
||||
static String nominativeDollar() => Intl.message('nominative_dollar', name: 'nominative_dollar', locale: Intl.defaultLocale);
|
||||
static String singularDollar() => Intl.message('singular_dollar', name: 'singular_dollar', locale: Intl.defaultLocale);
|
||||
static String pluralDollar() => Intl.message('plural_dollar', name: 'plural_dollar', locale: Intl.defaultLocale);
|
||||
|
||||
static String nominativeHryvna() => Intl.message('nominative_hryvna', name: 'nominative_hryvna', locale: Intl.defaultLocale);
|
||||
static String singularHryvna() => Intl.message('singular_hryvna', name: 'singular_hryvna', locale: Intl.defaultLocale);
|
||||
static String pluralHryvna() => Intl.message('plural_hryvna', name: 'plural_hryvna', locale: Intl.defaultLocale);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user