Исправлены баги
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:checker/base/base_screen.dart';
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -13,14 +14,15 @@ import 'package:checker/base/base_state.dart';
|
||||
import 'package:checker/screens/purchase_success.dart';
|
||||
|
||||
/// Экран проведения покупки.
|
||||
class PurchaseScreen extends StatefulWidget {
|
||||
PurchaseScreen(this.user, this.card);
|
||||
class PurchaseScreen extends BaseScreen {
|
||||
|
||||
PurchaseScreen(helper, app, this.user, this.card) : super(helper, app);
|
||||
|
||||
final String user;
|
||||
final String card;
|
||||
|
||||
@override
|
||||
State createState() => new PurchaseScreenState<PurchaseScreen>(user, card);
|
||||
State createState() => new PurchaseScreenState<PurchaseScreen>(helper, app, user, card);
|
||||
}
|
||||
|
||||
class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
@@ -29,9 +31,11 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
/// (удаляет запрещенные символы до их отображаения).
|
||||
TextEditingController controller = new TextEditingController();
|
||||
|
||||
PurchaseScreenState(String userString, String card) {
|
||||
PurchaseScreenState(SqliteHelper helper, String app, String userString, String card) {
|
||||
this.user = JSON.decode(userString);
|
||||
this.card = card;
|
||||
this.helper = helper;
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -62,18 +66,18 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
return new Column(children: <Widget>[
|
||||
new Expanded(
|
||||
child: new ListView(children: <Widget>[
|
||||
getValueWithDescription(StringsLocalization.buyer(),
|
||||
user['first_name'] == null ? '' : user['first_name']),
|
||||
getValueWithDescription(StringsLocalization.card(), card),
|
||||
getValueWithDescription(StringsLocalization.reward(), loyalty),
|
||||
getHintLabel(),
|
||||
getInputField(),
|
||||
wrapButton(getScreenMargins(36.0), getCompleteButton()),
|
||||
wrapButton(
|
||||
getScreenMargins(24.0),
|
||||
getScanButton(context, StringsLocalization.scan(),
|
||||
Resources.getPrimaryColor(app)))
|
||||
]))
|
||||
getValueWithDescription(StringsLocalization.buyer(),
|
||||
user['first_name'] == null ? '' : user['first_name']),
|
||||
getValueWithDescription(StringsLocalization.card(), card),
|
||||
getValueWithDescription(StringsLocalization.reward(), loyalty),
|
||||
getHintLabel(),
|
||||
getInputField(),
|
||||
wrapButton(getScreenMargins(36.0), getCompleteButton()),
|
||||
wrapButton(
|
||||
getScreenMargins(24.0),
|
||||
getScanButton(context, StringsLocalization.scan(),
|
||||
Resources.getPrimaryColor(app)))
|
||||
]))
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -185,7 +189,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
child: new AlertDialog(
|
||||
title: new Text(StringsLocalization.confirmation()),
|
||||
content:
|
||||
new Text(StringsLocalization.confirmPurchase(val, currency)),
|
||||
new Text(StringsLocalization.confirmPurchase(val, currency)),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
@@ -254,7 +258,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
this.loyalty = '${user['discount']}%';
|
||||
} else {
|
||||
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)}%';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user