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 { 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: [new IconButton(icon: new Icon(Icons.help_outline), onPressed: () {})]); } Widget _getScreen(BuildContext context) { return new Stack(children: [_getScreenContent(), _getProgressIndicator()]); } Widget _getScreenContent() { return new Container(height: 332.0, child: new ListView(reverse: true, children: [ new Column(children: [ _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: [ new Row(crossAxisAlignment: CrossAxisAlignment.start, children: [new Text(title, textAlign: TextAlign.left, style: new TextStyle(color: greyTextColor, fontSize: 14.0))]), new Row(crossAxisAlignment: CrossAxisAlignment.start, children: [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()); // }); } }