Регистрация, проверка токена, обработка ошибок, сканирование

This commit is contained in:
Ivan Murashov
2017-07-21 22:35:28 +03:00
parent 013a75e464
commit 8cf5d4b028
10 changed files with 454 additions and 185 deletions

101
lib/purchase.dart Normal file
View File

@@ -0,0 +1,101 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'main.dart';
import 'dart:async';
import 'activate_token.dart';
/// Экран проведения покупки.
class PurchaseScreen extends StatefulWidget {
@override State createState() => new _PurchaseScreenState();
}
class _PurchaseScreenState extends State<PurchaseScreen> {
bool _loading = false;
@override Widget build(BuildContext context) {
return new Scaffold(appBar: _getAppBar(), body: _getScreen(context));
}
AppBar _getAppBar() {
return new AppBar(title: new Text("Проведение покупки"),
actions: <Widget>[new IconButton(icon: new Icon(Icons.help_outline), onPressed: () {})]);
}
Widget _getScreen(BuildContext context) {
return new Stack(children: <Widget>[_getScreenContent(), _getProgressIndicator()]);
}
Widget _getScreenContent() {
return new Container(height: 332.0,
child: new ListView(reverse: true, children: <Widget>[
new Column(children: <Widget>[
_getValueWithTitle('ФИО', 'Знаменитый Рокер Паук'),
_getValueWithTitle('Карта', 'B0399900702'),
_getValueWithTitle('Вознаграждение', '100%'),
_getButton(context),
_getButton(context)])
].reversed.toList()));
}
Widget _getProgressIndicator() {
return new Center(child: _loading ? new CircularProgressIndicator() : null);
}
Widget _getValueWithTitle(String title, String value) {
return 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 _getButton(BuildContext context) {
return new Container(margin: new EdgeInsets.only(top: 36.0), height: 42.0,
padding: new EdgeInsets.only(left: 40.0, right: 40.0),
child: new RaisedButton(child: new Text('ЗАРЕГИСТРИРОВАТЬ',
style: new TextStyle(color: Colors.white)),
onPressed: null,
color: primaryColor));
}
Widget _getCircularProgressIndicator() {
return new Center(child: new CircularProgressIndicator());
}
_register(BuildContext context) async {
// const platform = const MethodChannel('com.dinect.checker/instance_id');
// String url = intUrl + 'tokens/?_dmapptoken=' + intToken;
// String pos = await platform.invokeMethod('getInstanceID');
// print(pos);
// String userAgent = 'dm-checker-test v1.0.1';
// var body = {
// 'merchant_shop': merchantShop,
// 'pos': pos,
// 'description': userAgent + '-' + pos
// };
// print(url);
// for (var value in body.values) {
// print(value);
// }
// httpClient.post(url, body: body).then((response) {
// print(response.body);
// Map parsedMap = JSON.decode(response.body);
// token = parsedMap['token'];
// platform.invokeMethod('saveToken', {'token' : token}).then((value) {
// print(value.toString());
// });
// setState(() {
// loading = false;
// });
// pushRoute(context, new FinishRegistrationScreen());
// }).catchError((error) {
// print(error.toString());
// });
}
}