104 lines
3.9 KiB
Dart
104 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: 412.0,
|
||
child: new ListView(reverse: true, children: <Widget>[
|
||
new Column(children: <Widget>[
|
||
getValueWithTitle('ФИО', 'Знаменитый Рокер Паук'),
|
||
getValueWithTitle('Карта', 'B0399900702'),
|
||
getValueWithTitle('Вознаграждение', '100%'),
|
||
getHintLabel(),
|
||
getDecoratedTextWidget(),
|
||
buildButton(new EdgeInsets.only(top: 36.0, left: 70.0, right: 70.0), buildRaisedButton(context, 'ЗАВЕРШИТЬ ПОКУПКУ', () => _purchase(context))),
|
||
buildButton(new EdgeInsets.only(top: 24.0, left: 70.0, right: 70.0), buildFlatButton(context, 'СКАНИРОВАТЬ', primaryColor))])
|
||
].reversed.toList()));
|
||
}
|
||
|
||
Widget getValueWithTitle(String title, String value) {
|
||
return new Container(padding: new EdgeInsets.only(left: verticalMargin, right: verticalMargin, top: 18.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 buildButton(EdgeInsets margin, Widget widget) {
|
||
return new Container(margin: margin, height: 48.0, child: new Row(children: <Widget>[new Expanded(child: widget)]));
|
||
}
|
||
|
||
Widget buildRaisedButton(BuildContext context, String text, VoidCallback onPressed) {
|
||
return new RaisedButton(child: new Text(text,
|
||
style: new TextStyle(color: Colors.white)),
|
||
onPressed: onPressed,
|
||
color: primaryColor);
|
||
}
|
||
|
||
Widget buildFlatButton(BuildContext context, String title, Color textColor) {
|
||
return new Container(height: 48.0, child: new FlatButton(child: new Text(title,
|
||
style: new TextStyle(color: textColor)),
|
||
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 {
|
||
|
||
}
|
||
} |