Merge branch 'RG-3434' into sqflite

This commit is contained in:
Ivan Murashov
2017-09-07 16:03:15 +03:00
30 changed files with 361 additions and 133 deletions

View File

@@ -1,50 +1,73 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:intl/intl.dart';
import 'dart:async';
import 'dart:convert';
import 'dart:async';
import 'common.dart';
import 'network.dart';
import 'consts.dart';
import 'registration.dart';
import 'finish_registration.dart';
import 'db.dart';
import 'resources.dart';
import 'base_state.dart';
class SplashScreen extends StatelessWidget {
class SplashScreen extends StatefulWidget {
@override State createState() => new _SplashScreenState();
}
class _SplashScreenState extends BaseState<SplashScreen> {
@override
Widget build(BuildContext context) {
// Появляется splash screen, проверяется токен.
Widget getScreenContent() {
return app == null
? getBackground()
: new Stack(
children: <Widget>[
getBackground(),
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 Future.delayed(const Duration(milliseconds: 500), () {
platform.invokeMethod('getLocale').then((locale) {
Intl.defaultLocale = locale;
print(Intl.defaultLocale);
showNextScreen(context);
});
@override Widget getMainWidget() {
return getScreenContent();
}
@override
String getTitle() {
return null;
}
@override void onStart() {
new Future.delayed(const Duration(milliseconds: 1000), () {
showNextScreen(context);
});
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)))]);
}
/// Возвращает столбец с логотипом приложения и текстом под ним.
/// Столбец занимает не все доступное пространство, а необходимый минимум в центре экрана.
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)]));
}
/// Возвращает контейнер, который содержит decoration с фоновым изображением.
getSplashBackground() {
return new Container(decoration:
new BoxDecoration(image:
new DecorationImage(image: new ExactAssetImage(splash_png), fit: BoxFit.cover)));
return new Center(
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Image.asset(
Resources.getLogo(app),
height: 112.0,
width: 252.0),
new Image.asset(
splash_text_png,
height: 40.0,
width: 240.0)]));
}
/// Запуск следующего экрана приложения.
@@ -92,7 +115,7 @@ class SplashScreen extends StatelessWidget {
bool active = status['active'] == null ? false : status['active'];
if (active) {
startScanner(helper, context);
startScanner(context, app, helper);
} else {
if (await platform.invokeMethod('isOnline')) {
_createToken(context, helper);