purchase success info
This commit is contained in:
@@ -247,7 +247,9 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
sumTotal,
|
||||
user['first_name'] == null ? '' : user['first_name'],
|
||||
helper,
|
||||
app));
|
||||
app,
|
||||
parsedMap
|
||||
));
|
||||
}
|
||||
}).catchError((error) {
|
||||
purchaseInProgress = false;
|
||||
|
||||
@@ -8,28 +8,45 @@ import 'package:flutter/material.dart';
|
||||
/// Экран проведения покупки.
|
||||
class PurchaseSuccessScreen extends StatefulWidget {
|
||||
|
||||
PurchaseSuccessScreen(this.val, this.name, this.helper, this.app);
|
||||
PurchaseSuccessScreen(this.val, this.name, this.helper, this.app, this.details);
|
||||
|
||||
final String val;
|
||||
final String name;
|
||||
final String app;
|
||||
final SqliteHelper helper;
|
||||
final Map details;
|
||||
|
||||
@override State createState() =>
|
||||
new PurchaseSuccessScreenState(val, name, helper, app);
|
||||
new PurchaseSuccessScreenState(val, name, helper, app, details);
|
||||
}
|
||||
|
||||
class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
|
||||
PurchaseSuccessScreenState(String sum, String username, SqliteHelper helper,
|
||||
String app) {
|
||||
PurchaseSuccessScreenState(
|
||||
String sum, String username, SqliteHelper helper,
|
||||
String app, Map details
|
||||
){
|
||||
this.sum = sum;
|
||||
this.username = username;
|
||||
this.helper = helper;
|
||||
this.app = app;
|
||||
this.details = details;
|
||||
|
||||
String regexString = r'(\d+) начислено, (\d+).*';
|
||||
RegExp regExp = new RegExp(regexString);
|
||||
var matches = regExp.allMatches(this.details['sum_bonus']);
|
||||
if(matches.length != 0) {
|
||||
var match = matches.elementAt(0); // => extract the first (and only) match
|
||||
bonusPlus = int.parse(match.group(1));
|
||||
bonusMinus = int.parse(match.group(2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String sum, username;
|
||||
Map details;
|
||||
int bonusPlus = 0;
|
||||
int bonusMinus = 0;
|
||||
int currency;
|
||||
|
||||
@override String getTitle() {
|
||||
@@ -52,12 +69,27 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
}
|
||||
|
||||
@override Widget getScreenContent() {
|
||||
return new Column(children: <Widget>[
|
||||
getValueWithDescription(StringsLocalization.buyer(), username),
|
||||
getSuccessMessage(),
|
||||
new Expanded(child: new Center()),
|
||||
wrapButton(getScreenMargins(74.0), getScanButton())
|
||||
]);
|
||||
|
||||
|
||||
|
||||
List <Widget> widgetList = <Widget>[];
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.buyer(), username));
|
||||
widgetList.add(getSuccessMessage());
|
||||
if (bonusPlus > 0) {
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.bonusPlus(), bonusPlus.toString()));
|
||||
}
|
||||
if (bonusMinus > 0) {
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.bonusMinus(), bonusMinus.toString()));
|
||||
}
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.discountRate(), '${details['discount']}%'));
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.discountSum(), '${details['sum_discount']}'));
|
||||
widgetList.add(getCoupons());
|
||||
widgetList.add( new Expanded(child: new Center()));
|
||||
widgetList.add(wrapButton(getScreenMargins(74.0), getScanButton()));
|
||||
|
||||
return new Column(
|
||||
children: widgetList
|
||||
);
|
||||
}
|
||||
|
||||
getScreenMargins(double bottom) {
|
||||
@@ -70,15 +102,97 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
return buildRaisedButton(title, () => startScanner(context, app, helper));
|
||||
}
|
||||
|
||||
|
||||
ExpansionPanelHeaderBuilder get headerBuilder {
|
||||
return (BuildContext context, bool isExpanded) {
|
||||
return new Text('Purchase details');
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getCoupons() {
|
||||
EdgeInsets margin = new EdgeInsets.only(left: 20.0, right: 20.0);
|
||||
TextStyle titleStyle = Theme.of(context).textTheme.button.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: faqTitlesColor
|
||||
);
|
||||
|
||||
final List<Widget> detailsRows = <Widget>[];
|
||||
|
||||
// this.details.forEach((key, value) => detailsRows.add(
|
||||
// new Text(key)
|
||||
// new Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: <Widget>[
|
||||
// new Text('1'),
|
||||
// new Text('2'),
|
||||
//
|
||||
// new Container(
|
||||
// margin: const EdgeInsets.only(right: 16.0),
|
||||
// child: new CircleAvatar(child: new Text('D')),
|
||||
// ),
|
||||
// new Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: <Widget>[
|
||||
// new Text(key, style: Theme.of(context).textTheme.subhead),
|
||||
// new Container(
|
||||
// margin: const EdgeInsets.only(top: 0.5),
|
||||
// child: new Text(key)
|
||||
// )
|
||||
// ]
|
||||
// )
|
||||
// ],
|
||||
// )
|
||||
// ));
|
||||
|
||||
print(detailsRows.length);
|
||||
|
||||
return new Container(
|
||||
margin: margin,
|
||||
child: new Card(
|
||||
child: new ExpansionTile(
|
||||
//key: new PageStorageKey<Entry>(root),
|
||||
title: new Text(
|
||||
'Coupons',
|
||||
style: titleStyle
|
||||
),
|
||||
children: [
|
||||
new Container(
|
||||
margin: margin,
|
||||
padding: new EdgeInsets.only(top: 12.0, bottom: 20.0),
|
||||
child: new Text('Coupons'),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(
|
||||
top: new BorderSide(
|
||||
color: greyTextColor,
|
||||
width: 0.5
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getSuccessMessage() {
|
||||
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)))))
|
||||
]);
|
||||
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
|
||||
)
|
||||
)
|
||||
)
|
||||
))
|
||||
]);
|
||||
}
|
||||
|
||||
getMessageTitle() {
|
||||
@@ -89,4 +203,4 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user