109 lines
3.9 KiB
Dart
109 lines
3.9 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:flutter/services.dart';
|
||
import 'dart:convert';
|
||
import 'dart:async';
|
||
|
||
import 'main.dart';
|
||
import 'base_state.dart';
|
||
import 'purchase_success.dart';
|
||
|
||
/// Экран проведения покупки.
|
||
class PurchaseScreen extends StatefulWidget {
|
||
@override State createState() => new PurchaseScreenState<PurchaseScreen>();
|
||
}
|
||
|
||
class PurchaseScreenState<T> extends BaseState<T> {
|
||
|
||
String _sum = "1234.00";
|
||
|
||
@override String getTitle() {
|
||
return "Проведение покупки";
|
||
}
|
||
|
||
@override getHint() {
|
||
return 'Сумма';
|
||
}
|
||
|
||
@overide getMenuButtons(BuildContext context) {
|
||
return <Widget>[
|
||
new IconButton(icon: new Icon(Icons.help_outline), onPressed: () {}),
|
||
new IconButton(icon: new Image.asset(logout_png, height: 20.0, width: 20.0), onPressed: () => logout(context))
|
||
];
|
||
}
|
||
|
||
@override Widget getScreenContent() {
|
||
return new Container(height: 398.0,
|
||
child: new ListView(reverse: true, children: <Widget>[
|
||
new Column(children: <Widget>[
|
||
getValueWithTitle('ФИО', 'Знаменитый Рокер Паук'),
|
||
getValueWithTitle('Карта', 'B0399900702'),
|
||
getValueWithTitle('Вознаграждение', '100%'),
|
||
getHintLabel(),
|
||
getDecoratedTextWidget(),
|
||
getApprovePurchaseButton(context),
|
||
buildScanButton(context)])
|
||
].reversed.toList()));
|
||
}
|
||
|
||
Widget getValueWithTitle(String title, String value) {
|
||
return new Container(padding: new EdgeInsets.only(left: verticalMargin, right: verticalMargin, top: 12.0),
|
||
child: new Column(children: <Widget>[
|
||
new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[new Text(title, textAlign: TextAlign.left, style: new TextStyle(color: greyTextColor, fontSize: 14.0))]),
|
||
new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[new Text(value, textAlign: TextAlign.left, style: new TextStyle(color: Colors.black, fontSize: 20.0))])
|
||
]));
|
||
}
|
||
|
||
Widget getApprovePurchaseButton(BuildContext context) {
|
||
return new Container(margin: new EdgeInsets.only(top: 36.0), height: 44.0,
|
||
child: new RaisedButton(child: new Text('ЗАВЕРШИТЬ ПОКУПКУ',
|
||
style: new TextStyle(color: Colors.white)),
|
||
onPressed: () => _purchase(context),
|
||
color: primaryColor));
|
||
}
|
||
|
||
Widget buildScanButton(BuildContext context) {
|
||
return new Container(margin: new EdgeInsets.only(top: 24.0, left: 70.0, right: 70.0), child: _getScanButtonRow(context));
|
||
}
|
||
|
||
Widget _getScanButtonRow(BuildContext context) {
|
||
return new Row(children: <Widget>[new Expanded(child: _getScanButton(context))]);
|
||
}
|
||
|
||
Widget _getScanButton(BuildContext context) {
|
||
return new Container(height: 44.0, child: new FlatButton(child: new Text('СКАНИРОВАТЬ',
|
||
style: new TextStyle(color: primaryColor)),
|
||
onPressed: () => startScanner(context)),
|
||
decoration: _getDecoraionForScanButton());
|
||
}
|
||
|
||
_getDecoraionForScanButton() {
|
||
return new BoxDecoration(
|
||
border: new Border.all(color: primaryColor, width: 1.0),
|
||
borderRadius: new BorderRadius.all(new Radius.circular(4.0)));
|
||
}
|
||
|
||
_purchase(BuildContext context) {
|
||
showDialog(context: context, child: new AlertDialog(
|
||
title: new Text('Подтверждение'),
|
||
content: new Text('Вы подтверждаете покупку на ${_sum} руб?'),
|
||
actions: <Widget>[
|
||
new FlatButton(
|
||
child: new Text('Нет'),
|
||
onPressed: () {
|
||
Navigator.of(context).pop();
|
||
},
|
||
),
|
||
new FlatButton(
|
||
child: new Text('Дат'),
|
||
onPressed: () {
|
||
pushRoute(context, new PurchaseSuccessScreen());
|
||
},
|
||
)
|
||
]));
|
||
print('purchase');
|
||
}
|
||
|
||
_register(BuildContext context) async {
|
||
|
||
}
|
||
} |