Исправления, автоклуб

This commit is contained in:
Ivan Murashov
2017-07-28 18:36:51 +03:00
parent e53ceb9ef0
commit 7207c6e247
16 changed files with 203 additions and 171 deletions

View File

@@ -18,27 +18,28 @@ class SplashScreen extends StatelessWidget {
showNextScreen(context);
});
return new Stack(children: <Widget>[getBackgroundContainer(), getLogo(),
return new Stack(children: <Widget>[getSplashBackground(), getLogo(),
new Align(alignment: FractionalOffset.bottomRight, child:
new Container(margin: new EdgeInsets.only(right: 11.0, bottom: 5.0), child: new Image.asset(powered_by_dinect_splash_png, height: 16.0, width: 122.0)))]);
new Container(margin: new EdgeInsets.only(right: 11.0, bottom: 5.0), child:
new Image.asset(powered_by_dinect_splash_png, height: 16.0, width: 122.0)))]);
}
// Возвращает столбец с логотипом приложения и текстом под ним.
// Столбец занимает не все доступное пространство, а необходимый минимум в центре экрана.
getLogo() {
return new Center(child: new Column(mainAxisSize: MainAxisSize.min,
children: <Widget>[new Image.asset(logo_png, height: 112.0, width: 252.0),
new Image.asset(splash_text_png, height: 40.0, width: 240.0)]));
}
getBackgroundContainer() {
const margin = 48.0;
return new Container(padding: new EdgeInsets.only(left: margin, right: margin), decoration: getSplashBackground());
}
// Возвращает контейнер, который содержит decoration с фоновым изображением.
getSplashBackground() {
return new BoxDecoration(image: new DecorationImage(image: new ExactAssetImage(splash_png), fit: BoxFit.cover));
return new Container(decoration:
new BoxDecoration(image:
new DecorationImage(image: new ExactAssetImage(splash_png), fit: BoxFit.cover)));
}
/// Запуск следующего экрана приложения.
// Запуск следующего экрана приложения.
showNextScreen(BuildContext context) async {
token = await platform.invokeMethod('getToken');
@@ -49,12 +50,14 @@ class SplashScreen extends StatelessWidget {
if (token == null) {
pushRoute(context, new RegistrationScreen());
} else {
checkTokenStatus(token).then((statusResponse) {
handleStatusResponse(context, statusResponse);
}).catchError((error) {
print(error.toString());
return false;
});
if (await platform.invokeMethod('isOnline')) {
checkTokenStatus(token).then((statusResponse) {
handleStatusResponse(context, statusResponse);
}).catchError((error) {
print(error.toString());
return false;
});
}
}
}
@@ -78,25 +81,25 @@ class SplashScreen extends StatelessWidget {
if (active) {
startScanner(context);
} else {
createToken(await platform.invokeMethod('getMerchantID'), await platform.invokeMethod('getPosID')).then((response) {
print('response.body: ${response.body}');
if (response.statusCode == 409) {
pushRoute(context, new FinishRegistrationScreen());
} else if (response.statusCode == 201) {
platform.invokeMethod('removeKeys').then((result) {
Map parsedMap = JSON.decode(result);
String t = parsedMap['token'];
deleteToken(t).then((response) {
print(response.body);
Navigator.of(context).pop(); // Убираем текущий route
pushRoute(context, new RegistrationScreen()); // Запускаем регистрацию
}).catchError((error) {
print(error.toString());
if (await platform.invokeMethod('isOnline')) {
createToken(await platform.invokeMethod('getMerchantID'), await platform.invokeMethod('getPosID')).then((response) {
if (response.statusCode == 409) {
pushRoute(context, new FinishRegistrationScreen());
} else if (response.statusCode == 201) {
platform.invokeMethod('removeKeys').then((result) {
Map parsedMap = JSON.decode(result);
String t = parsedMap['token'];
deleteToken(t).then((response) {
print(response.body);
Navigator.of(context).pop(); // Убираем текущий route
pushRoute(context, new RegistrationScreen()); // Запускаем регистрацию
}).catchError((error) {
print(error.toString());
});
});
});
}
}).catchError((error) => print(error.toString()));
}
}).catchError((error) => print(error.toString()));
}
}
}
}