Smoth screen changes. Step 1
This commit is contained in:
@@ -1,23 +1,99 @@
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:checker/screens/splash.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
||||
|
||||
void main() {
|
||||
platform.invokeMethod('getAppTitle').then((title) {
|
||||
runApp(new Checker(appName: title));
|
||||
main() {
|
||||
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
platform.invokeMethod('getAppTitle').then((title) {
|
||||
|
||||
String app = flavor; // dinect, autobonus
|
||||
String appName= title; // Dinect, Dinect (INT), Autobonus
|
||||
|
||||
SqliteHelper helper = new SqliteHelper();
|
||||
|
||||
helper.open().then((_) {
|
||||
helper.getLocale().then((locale) {
|
||||
if (locale == null) {
|
||||
initWithSystemValue(app, appName, helper);
|
||||
} else {
|
||||
start(app, appName, locale, helper);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class Checker extends StatelessWidget {
|
||||
Checker({this.appName});
|
||||
initWithSystemValue(String app, String name, SqliteHelper helper) {
|
||||
platform.invokeMethod('getLocale').then((locale) {
|
||||
helper.getSettings(false).then((settings) {
|
||||
if (settings == null) {
|
||||
createSettingsTable(app, name, locale, helper);
|
||||
} else {
|
||||
start(app, name, locale, helper);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
createSettingsTable(String app, String name, String locale, SqliteHelper helper) {
|
||||
platform.invokeMethod('getCurrency').then((currency) {
|
||||
helper.createAppInfo(currency);
|
||||
start(app, name, locale, helper);
|
||||
});
|
||||
}
|
||||
|
||||
start(String app, String name, String locale, SqliteHelper helper) {
|
||||
StringsLocalization.load(locale).then((_) {
|
||||
runApp(new Checker(app, name, locale, helper));
|
||||
});
|
||||
}
|
||||
|
||||
class Checker extends StatefulWidget {
|
||||
|
||||
/// Класс для работы с бд
|
||||
final SqliteHelper helper;
|
||||
|
||||
/// Тип сборки. Определяет, какие брать ресурсы (цвета, картинки)
|
||||
final String app;
|
||||
|
||||
/// Отображаемое в заголовке приложения названия (когда показывается список запущенных приложений)
|
||||
final String appName;
|
||||
|
||||
@override Widget build (BuildContext context) {
|
||||
/// Локаль приложения
|
||||
final String locale;
|
||||
|
||||
Checker(this.app, this.appName, this.locale, this.helper);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => new CheckerState(
|
||||
this.app,
|
||||
this.appName,
|
||||
this.locale,
|
||||
this.helper);
|
||||
}
|
||||
|
||||
class CheckerState extends State<Checker> {
|
||||
|
||||
SqliteHelper helper;
|
||||
String app;
|
||||
String appName;
|
||||
String locale;
|
||||
|
||||
String token;
|
||||
|
||||
CheckerState(this.app, this.appName, this.locale, this.helper);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: appName,
|
||||
home: new SplashScreen()
|
||||
home: new SplashScreen(helper, app)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user