Исправлены баги
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.dinect.checker"
|
package="com.dinect.checker"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.1.1">
|
android:versionName="1.1.2">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="16"
|
android:minSdkVersion="16"
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
pushRoute(context, new FAQScreen(false));
|
pushRoute(context, new FAQScreen(helper, app, false));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ pushRoute(BuildContext context, Widget widget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Добавление route, с возможностью вернуться к предыдущему экрану.
|
// Добавление route, с возможностью вернуться к предыдущему экрану.
|
||||||
faq(BuildContext context, bool returnToScanner) {
|
faq(SqliteHelper helper, String app, BuildContext context, bool returnToScanner) {
|
||||||
pushRoute(context, new FAQScreen(returnToScanner));
|
pushRoute(context, new FAQScreen(helper, app, returnToScanner));
|
||||||
}
|
}
|
||||||
|
|
||||||
// В методе отправляется запрос на удаление токена кассы, очищаются SharedPreferences приложения.
|
// В методе отправляется запрос на удаление токена кассы, очищаются SharedPreferences приложения.
|
||||||
@@ -93,7 +93,7 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async {
|
|||||||
if (call.method == 'logout') {
|
if (call.method == 'logout') {
|
||||||
forceLogout(token, context);
|
forceLogout(token, context);
|
||||||
} else if (call.method == 'faq') {
|
} else if (call.method == 'faq') {
|
||||||
faq(context, true);
|
faq(helper, app, context, true);
|
||||||
} else if(call.method == 'settings') {
|
} else if(call.method == 'settings') {
|
||||||
if (helper == null) {
|
if (helper == null) {
|
||||||
helper = new SqliteHelper();
|
helper = new SqliteHelper();
|
||||||
@@ -108,8 +108,7 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async {
|
|||||||
String card = call.arguments[1];
|
String card = call.arguments[1];
|
||||||
var route = new MaterialPageRoute<Null>(
|
var route = new MaterialPageRoute<Null>(
|
||||||
builder: (BuildContext context) =>
|
builder: (BuildContext context) =>
|
||||||
new PurchaseScreen(
|
new PurchaseScreen(helper, app, userString, card));
|
||||||
userString, card));
|
|
||||||
while (Navigator.of(context).canPop()) {
|
while (Navigator.of(context).canPop()) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
const String appName = "Autobonus";
|
const String appName = "PIP";
|
||||||
|
|
||||||
// Assets
|
// Assets
|
||||||
const String logout_png = 'assets/logout.png';
|
const String logout_png = 'assets/logout.png';
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:checker/base/base_screen.dart';
|
||||||
|
import 'package:checker/db.dart';
|
||||||
import 'package:checker/resources.dart';
|
import 'package:checker/resources.dart';
|
||||||
import 'package:checker/strings.dart';
|
import 'package:checker/strings.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -62,17 +64,22 @@ class EntryItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FAQScreen extends StatefulWidget {
|
class FAQScreen extends BaseScreen {
|
||||||
|
|
||||||
FAQScreen(this.b);
|
FAQScreen(SqliteHelper helper, String app,
|
||||||
final bool b;
|
this.returnToScanner) : super(helper, app);
|
||||||
|
|
||||||
@override State createState() => new FAQScreenState<FAQScreen>(b);
|
final bool returnToScanner;
|
||||||
|
|
||||||
|
@override State createState() => new FAQScreenState<FAQScreen>(returnToScanner, helper, app);
|
||||||
}
|
}
|
||||||
|
|
||||||
class FAQScreenState<T> extends BaseState<FAQScreen> {
|
class FAQScreenState<T> extends BaseState<FAQScreen> {
|
||||||
|
|
||||||
FAQScreenState(this.returnToScanner);
|
FAQScreenState(this.returnToScanner, SqliteHelper helper, String app) {
|
||||||
|
this.helper = helper;
|
||||||
|
this.app = app;
|
||||||
|
}
|
||||||
|
|
||||||
bool returnToScanner;
|
bool returnToScanner;
|
||||||
|
|
||||||
@@ -87,7 +94,7 @@ class FAQScreenState<T> extends BaseState<FAQScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override Widget build(BuildContext context) {
|
@override Widget build(BuildContext context) {
|
||||||
if (app == null) {
|
if (data == null) {
|
||||||
platform.invokeMethod('getFlavor').then((flavor) {
|
platform.invokeMethod('getFlavor').then((flavor) {
|
||||||
initPhoneAndUrl().then((_) {
|
initPhoneAndUrl().then((_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:checker/base/base_screen.dart';
|
||||||
import 'package:checker/db.dart';
|
import 'package:checker/db.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -13,14 +14,15 @@ import 'package:checker/base/base_state.dart';
|
|||||||
import 'package:checker/screens/purchase_success.dart';
|
import 'package:checker/screens/purchase_success.dart';
|
||||||
|
|
||||||
/// Экран проведения покупки.
|
/// Экран проведения покупки.
|
||||||
class PurchaseScreen extends StatefulWidget {
|
class PurchaseScreen extends BaseScreen {
|
||||||
PurchaseScreen(this.user, this.card);
|
|
||||||
|
PurchaseScreen(helper, app, this.user, this.card) : super(helper, app);
|
||||||
|
|
||||||
final String user;
|
final String user;
|
||||||
final String card;
|
final String card;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State createState() => new PurchaseScreenState<PurchaseScreen>(user, card);
|
State createState() => new PurchaseScreenState<PurchaseScreen>(helper, app, user, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||||
@@ -29,9 +31,11 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
/// (удаляет запрещенные символы до их отображаения).
|
/// (удаляет запрещенные символы до их отображаения).
|
||||||
TextEditingController controller = new TextEditingController();
|
TextEditingController controller = new TextEditingController();
|
||||||
|
|
||||||
PurchaseScreenState(String userString, String card) {
|
PurchaseScreenState(SqliteHelper helper, String app, String userString, String card) {
|
||||||
this.user = JSON.decode(userString);
|
this.user = JSON.decode(userString);
|
||||||
this.card = card;
|
this.card = card;
|
||||||
|
this.helper = helper;
|
||||||
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -62,18 +66,18 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
return new Column(children: <Widget>[
|
return new Column(children: <Widget>[
|
||||||
new Expanded(
|
new Expanded(
|
||||||
child: new ListView(children: <Widget>[
|
child: new ListView(children: <Widget>[
|
||||||
getValueWithDescription(StringsLocalization.buyer(),
|
getValueWithDescription(StringsLocalization.buyer(),
|
||||||
user['first_name'] == null ? '' : user['first_name']),
|
user['first_name'] == null ? '' : user['first_name']),
|
||||||
getValueWithDescription(StringsLocalization.card(), card),
|
getValueWithDescription(StringsLocalization.card(), card),
|
||||||
getValueWithDescription(StringsLocalization.reward(), loyalty),
|
getValueWithDescription(StringsLocalization.reward(), loyalty),
|
||||||
getHintLabel(),
|
getHintLabel(),
|
||||||
getInputField(),
|
getInputField(),
|
||||||
wrapButton(getScreenMargins(36.0), getCompleteButton()),
|
wrapButton(getScreenMargins(36.0), getCompleteButton()),
|
||||||
wrapButton(
|
wrapButton(
|
||||||
getScreenMargins(24.0),
|
getScreenMargins(24.0),
|
||||||
getScanButton(context, StringsLocalization.scan(),
|
getScanButton(context, StringsLocalization.scan(),
|
||||||
Resources.getPrimaryColor(app)))
|
Resources.getPrimaryColor(app)))
|
||||||
]))
|
]))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +189,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
child: new AlertDialog(
|
child: new AlertDialog(
|
||||||
title: new Text(StringsLocalization.confirmation()),
|
title: new Text(StringsLocalization.confirmation()),
|
||||||
content:
|
content:
|
||||||
new Text(StringsLocalization.confirmPurchase(val, currency)),
|
new Text(StringsLocalization.confirmPurchase(val, currency)),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
new FlatButton(
|
new FlatButton(
|
||||||
child: new Text(StringsLocalization.no()),
|
child: new Text(StringsLocalization.no()),
|
||||||
@@ -254,7 +258,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
this.loyalty = '${user['discount']}%';
|
this.loyalty = '${user['discount']}%';
|
||||||
} else {
|
} else {
|
||||||
double loyaltyVal = (double.parse(bonuses['amount_to_bonus'][1]) /
|
double loyaltyVal = (double.parse(bonuses['amount_to_bonus'][1]) /
|
||||||
bonuses['amount_to_bonus'][0]) * 100;
|
bonuses['amount_to_bonus'][0]) * 100;
|
||||||
this.loyalty = '${loyaltyVal.toStringAsFixed(0)}%';
|
this.loyalty = '${loyaltyVal.toStringAsFixed(0)}%';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ class MenuItem {
|
|||||||
|
|
||||||
class SettingsState extends BaseState<SettingsScreen> {
|
class SettingsState extends BaseState<SettingsScreen> {
|
||||||
|
|
||||||
List<MenuItem> menuItems;
|
List<MenuItem> menuItems = [
|
||||||
|
new MenuItem('', ''),
|
||||||
|
new MenuItem('', '')
|
||||||
|
];
|
||||||
|
|
||||||
bool returnToScanner;
|
bool returnToScanner;
|
||||||
|
|
||||||
@@ -39,22 +42,14 @@ class SettingsState extends BaseState<SettingsScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override Widget build(BuildContext ctx) {
|
@override Widget build(BuildContext ctx) {
|
||||||
if (menuItems == null) {
|
helper.getSettings().then((info) {
|
||||||
menuItems = [
|
setState(() {
|
||||||
new MenuItem('', ''),
|
menuItems[0].title = StringsLocalization.currency();
|
||||||
new MenuItem('', '')
|
menuItems[1].title = StringsLocalization.locale();
|
||||||
];
|
menuItems[0].selectedValue = info['currency'].toString();
|
||||||
helper.getSettings().then((info) {
|
menuItems[1].selectedValue = info['locale'] == null ? Intl.defaultLocale : info['locale'].toString();
|
||||||
setState(() {
|
|
||||||
menuItems[0].title = StringsLocalization.currency();
|
|
||||||
menuItems[1].title = StringsLocalization.locale();
|
|
||||||
menuItems[0].selectedValue = info['currency'].toString();
|
|
||||||
menuItems[1].selectedValue =
|
|
||||||
info['locale'] == null ? Intl.defaultLocale : info['locale']
|
|
||||||
.toString();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
return new WillPopScope(onWillPop: onWillPop, child: getMainWidget());
|
return new WillPopScope(onWillPop: onWillPop, child: getMainWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,16 +72,11 @@ class SettingsState extends BaseState<SettingsScreen> {
|
|||||||
|
|
||||||
List<Widget> getSettings() {
|
List<Widget> getSettings() {
|
||||||
List<Widget> widgets = new List();
|
List<Widget> widgets = new List();
|
||||||
if (menuItems != null) {
|
for (int i = 0; i < menuItems.length; i++) {
|
||||||
for (int i = 0; i < menuItems.length; i++) {
|
if (menuItems[i].selectedValue != '') {
|
||||||
if (menuItems[i].selectedValue != '') {
|
widgets.add(getSettingsItem(() => onPressed(menuItems.indexOf(menuItems[i])),
|
||||||
widgets.add(
|
menuItems[i].title,
|
||||||
getSettingsItem(() => onPressed(menuItems.indexOf(menuItems[i])),
|
i == 0 ? getCurrencyTitle(int.parse(menuItems[i].selectedValue)) : getLocaleTitle(menuItems[i].selectedValue)));
|
||||||
menuItems[i].title,
|
|
||||||
i == 0 ? getCurrencyTitle(
|
|
||||||
int.parse(menuItems[i].selectedValue)) : getLocaleTitle(
|
|
||||||
menuItems[i].selectedValue)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return widgets;
|
return widgets;
|
||||||
@@ -115,10 +105,8 @@ class SettingsState extends BaseState<SettingsScreen> {
|
|||||||
void onPressed(int position) {
|
void onPressed(int position) {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0 :
|
case 0 :
|
||||||
menuItems = null;
|
|
||||||
return pushRoute(context, new CurrenciesScreen(helper, app));
|
return pushRoute(context, new CurrenciesScreen(helper, app));
|
||||||
case 1 :
|
case 1 :
|
||||||
menuItems = null;
|
|
||||||
return pushRoute(context, new LanguagesScreen(helper, app));
|
return pushRoute(context, new LanguagesScreen(helper, app));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user