logout, индикатор загрузки на экране регистрации

This commit is contained in:
kifio
2017-07-21 08:40:10 +03:00
parent 0a397f675f
commit c9dba5bb08
10 changed files with 123 additions and 101 deletions

View File

@@ -12,6 +12,7 @@ class RegistrationScreen extends StatefulWidget {
class _RegistrationScreenState extends BaseState<RegistrationScreen> {
String _merchantID = "";
bool _loading = false;
@override Widget build(BuildContext context) {
return new Scaffold(appBar: _getAppBar(), body: _getScreen(context));
@@ -19,16 +20,14 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
AppBar _getAppBar() {
return new AppBar(title: new Text("Регистрация"),
backgroundColor: primaryColor, actions: <Widget>[
new IconButton(
icon: new Icon(Icons.help_outline),
tooltip: 'Air it',
onPressed: faq,
)
]);
actions: <Widget>[new IconButton(icon: new Icon(Icons.help_outline), onPressed: faq)]);
}
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 Center(child: new Column(children: <Widget>[
@@ -38,6 +37,10 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
].reversed.toList()));
}
Widget _getProgressIndicator() {
return new Center(child: _loading ? new CircularProgressIndicator() : null);
}
Widget _getLogo() {
return new Container(height: 192.0, width: 156.0,
child: new Image.asset(logo_png, height: 24.0, width: 156.0));
@@ -56,14 +59,6 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
onChanged: (text) => _handleUserInput(text));
}
void _handleUserInput(String text) {
if (text.length > 0) {
setState(() {
_merchantID = text;
});
}
}
Decoration _getDecoraionForInputField() {
return new BoxDecoration(color: Colors.white,
border: new Border.all(color: const Color(0xffcfd8dc), width: 1.0,),
@@ -71,19 +66,35 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
}
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),
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: _isValidMerchantID() ? () => _registerShop(context, _merchantID) : null,
color: primaryColor));
}
bool _isValidMerchantID() {
Widget _getCircularProgressIndicator() {
return new Center(child: new CircularProgressIndicator());
}
_isValidMerchantID() {
return _merchantID.length == 5;
}
void _registerShop(BuildContext context, String merchantShop) {
_register(context, merchantShop);
_handleUserInput(String text) {
if (text.length > 0) {
setState(() {
_merchantID = text;
});
}
}
_registerShop(BuildContext context, String merchantShop) {
setState(() {
loading = true;
_register(context, merchantShop);
});
}
_register(BuildContext context, String merchantShop) async {
@@ -113,6 +124,9 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
platform.invokeMethod('saveToken', {'token' : token}).then((value) {
print(value.toString());
});
setState(() {
loading = false;
});
pushRoute(context, new FinishRegistrationScreen());
}).catchError((error) {
print(error.toString());