Начал добавлять запросы на регистрацию, валидацию, удаление токена кассы

This commit is contained in:
Ivan Murashov
2017-07-17 19:02:50 +03:00
parent a14f521b1f
commit 79a16fb81f
11 changed files with 163 additions and 52 deletions

View File

@@ -10,14 +10,15 @@ class RegistrationScreen extends StatefulWidget {
class _RegistrationScreenState extends BaseState<RegistrationScreen> {
static const platform = const MethodChannel('com.dinnect.checker/scanner');
static const platform = const MethodChannel('com.dinnect.checker');
String _merchantID = "";
String _posNumber = "";
@override Widget build(BuildContext context) {
return new Scaffold(appBar: _getAppBar(), body: _getScreen());
}
faq() {}
AppBar _getAppBar() {
return new AppBar(title: new Text("Регистрация магазина"),
backgroundColor: const Color(0xff4272e7), actions: <Widget>[
@@ -77,7 +78,15 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
return new TextField(decoration: new InputDecoration(hintText: hint,
hideDivider: true,
hintStyle: new TextStyle(color: const Color(0xffa5a5a5),
fontSize: 16.0)));
fontSize: 16.0)), onChanged: (text) => _handleUserInput(text) );
}
void _handleUserInput(String text) {
if (text.length > 0) {
setState(() { //new
_merchantID = text;
});
}
}
Decoration _getDecoraionForInputField() {
@@ -92,9 +101,31 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
child: new Container(height: 64.0, padding: new EdgeInsets.all(8.0),
child: new RaisedButton(child: new Text('ЗАРЕГИСТРИРОВАТЬ',
style: new TextStyle(color: Colors.white)),
onPressed: null, disabledColor: const Color(0xffbfbfbf))));
onPressed: _merchantID.length == 0
? null
: () => _register(_merchantID),
disabledColor: const Color(0xffbfbfbf))));
}
doStuff() {}
void _register(String merchantShop) {
_registerToken(merchantShop);
}
Future<Null> _registerToken(String merchantShop) async {
String pos = await platform.invokeMethod('getInstanceID');
String userAgent = 'dm-checker-test v1.0.1';
var body = {
'merchant_shop' : merchantShop,
'pos' : pos,
'description' : userAgent + '-' + pos
};
httpClient.post(intUrl, body: body).then((response) {
print(response);
}).catchError((error) {
print(error);
});
}
}