Android all done.
This commit is contained in:
@@ -101,13 +101,18 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
new Future.delayed(const Duration(milliseconds: 200), () {
|
||||
var route = new MaterialPageRoute<String>(builder: (BuildContext context) => new SettingsScreen(helper, app, false), fullscreenDialog: true);
|
||||
Navigator.of(context).push(route).then((token) {
|
||||
Navigator.of(context).pop(token);
|
||||
if (token != null) {
|
||||
Navigator.of(context).pop(token);
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
pushRoute(context, new FAQScreen(helper, app, false));
|
||||
new Future.delayed(const Duration(milliseconds: 200), () {
|
||||
var route = new MaterialPageRoute<String>(builder: (BuildContext context) => new FAQScreen(helper, app), fullscreenDialog: true);
|
||||
Navigator.of(context).push(route);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:checker/screens/faq.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import 'db.dart';
|
||||
import 'strings.dart';
|
||||
@@ -10,6 +11,8 @@ import 'strings.dart';
|
||||
// Канал для взаимодействия с кодом платформы.
|
||||
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
||||
|
||||
|
||||
// TODO: Избавиться от следующих двух методов
|
||||
pushRoute(BuildContext context, Widget widget) {
|
||||
var route =
|
||||
new MaterialPageRoute<Null>(builder: (BuildContext context) => widget, fullscreenDialog: true);
|
||||
@@ -19,12 +22,6 @@ pushRoute(BuildContext context, Widget widget) {
|
||||
});
|
||||
}
|
||||
|
||||
// Добавление route, с возможностью вернуться к предыдущему экрану.
|
||||
faq(SqliteHelper helper, String app, BuildContext context,
|
||||
bool returnToScanner) {
|
||||
pushRoute(context, new FAQScreen(helper, app, returnToScanner));
|
||||
}
|
||||
|
||||
getCurrencyTitle(int code) {
|
||||
switch (code) {
|
||||
case 643:
|
||||
@@ -52,3 +49,8 @@ getLocaleTitle(String code) {
|
||||
return 'Español';
|
||||
}
|
||||
}
|
||||
|
||||
// Добавил вызов, что-бы AOT компилер не выкинул либу.
|
||||
getImage() async {
|
||||
return await ImagePicker.pickImage();
|
||||
}
|
||||
|
||||
@@ -68,19 +68,14 @@ class EntryItem extends StatelessWidget {
|
||||
|
||||
class FAQScreen extends BaseScreen {
|
||||
|
||||
FAQScreen(SqliteHelper helper, String app,
|
||||
this.returnToScanner) : super(helper, app);
|
||||
FAQScreen(SqliteHelper helper, String app) : super(helper, app);
|
||||
|
||||
final bool returnToScanner;
|
||||
|
||||
@override State createState() => new FAQScreenState<FAQScreen>(returnToScanner, helper, app);
|
||||
@override State createState() => new FAQScreenState<FAQScreen>(helper, app);
|
||||
}
|
||||
|
||||
class FAQScreenState<T> extends BaseState<FAQScreen> {
|
||||
|
||||
FAQScreenState(this.returnToScanner, SqliteHelper helper, String app) : super(helper, app);
|
||||
|
||||
bool returnToScanner;
|
||||
FAQScreenState(SqliteHelper helper, String app) : super(helper, app);
|
||||
|
||||
List<Entry> data;
|
||||
|
||||
@@ -92,16 +87,14 @@ class FAQScreenState<T> extends BaseState<FAQScreen> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
initPhoneAndUrl().then((_) {
|
||||
super.initState();
|
||||
});
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
if (data == null) {
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
initPhoneAndUrl().then((_) {
|
||||
setState(() {
|
||||
app = flavor;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
return new Scaffold(appBar: getAppBar(), body: getScreenContent());
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
));
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.card(), card));
|
||||
|
||||
if (app != 'crypto') { // FIXME Заменить на crypto
|
||||
if (app != 'crypto') {
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.reward(), loyalty));
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
height: buttonHeight,
|
||||
child: new FlatButton(
|
||||
child: new Text(title, style: new TextStyle(color: textColor)),
|
||||
onPressed: () => Navigator.of(context).pop()),
|
||||
onPressed: () => restartScanner()),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border.all(
|
||||
color: Resources.getButtonColor(app), width: 1.0),
|
||||
@@ -437,4 +437,10 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
print('kifio ' + this.loyalty);
|
||||
print('bonus ' + this.bonus);
|
||||
}
|
||||
|
||||
restartScanner() {
|
||||
helper.getToken().then((token) {
|
||||
Navigator.of(context).pop(token);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
int bonusPlus = 0;
|
||||
int bonusMinus = 0;
|
||||
int currency;
|
||||
String token;
|
||||
bool showBonus;
|
||||
|
||||
bool isAutomaticallyImplyLeading() => false;
|
||||
@@ -51,15 +52,18 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
|
||||
if (currency == null) {
|
||||
helper.getCurrency().then((currency) {
|
||||
setState(() {
|
||||
this.currency = currency;
|
||||
});
|
||||
@override
|
||||
void initState() {
|
||||
helper.getCurrency().then((currency) {
|
||||
helper.getToken().then((token) {
|
||||
this.currency = currency;
|
||||
this.token = token;
|
||||
});
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
|
||||
if (this.details['sum_bonus'] is String) {
|
||||
String regexString = r'(\d+) начислено, (\d+).*';
|
||||
@@ -122,9 +126,8 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
return new EdgeInsets.only(bottom: bottom, left: side, right: side);
|
||||
}
|
||||
|
||||
getScanButton() async {
|
||||
getScanButton() {
|
||||
String title = StringsLocalization.scan();
|
||||
String token = await helper.getToken();
|
||||
return buildRaisedButton(title, () => Navigator.of(context).pop(token));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext ctx) {
|
||||
return getMainWidget();
|
||||
return new WillPopScope(onWillPop: () => onWillPop(), child: getMainWidget());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -130,4 +130,10 @@ class RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onWillPop() {
|
||||
if (Theme.of(context).platform != TargetPlatform.iOS) {
|
||||
platform.invokeMethod('finish');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
print('init state!');
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext ctx) {
|
||||
// TODO: Перенести в initStater
|
||||
helper.getSettings(true).then((info) {
|
||||
setState(() {
|
||||
menuItems[0].title = StringsLocalization.currency();
|
||||
@@ -93,7 +93,6 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
List<Widget> widgets = new List();
|
||||
for (int i = 0; i < menuItems.length; i++) {
|
||||
if (menuItems[i].selectedValue.toString() != '') {
|
||||
print('title : ${menuItems[i].title}');
|
||||
widgets.add(
|
||||
getSettingsItem(() => onPressed(menuItems.indexOf(menuItems[i])),
|
||||
menuItems[i].title,
|
||||
@@ -108,7 +107,6 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
case 0 :
|
||||
return getCurrencyTitle(int.parse(menuItems[position].selectedValue));
|
||||
case 1 :
|
||||
print('val : ${menuItems[position].selectedValue}');
|
||||
return getLocaleTitle(menuItems[position].selectedValue);
|
||||
default :
|
||||
return null;
|
||||
@@ -188,11 +186,11 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
helper.getToken().then((token) {
|
||||
getDeleteTokenRequest(token).then((response) {
|
||||
helper.clear().then((result) {
|
||||
Navigator.of(context).pop(null);
|
||||
Navigator.of(context).pop('');
|
||||
});
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
Navigator.of(context).pop(null);
|
||||
Navigator.of(context).pop('');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:checker/consts.dart';
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:checker/network.dart';
|
||||
import 'package:checker/resources.dart';
|
||||
import 'package:checker/screens/faq.dart';
|
||||
import 'package:checker/screens/finish_registration.dart';
|
||||
import 'package:checker/screens/purchase.dart';
|
||||
import 'package:checker/screens/registration.dart';
|
||||
@@ -17,6 +18,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
// FIXME: Сделать запуск всех экранов из одной точки через метод showNextScreen()
|
||||
class SplashScreen extends BaseScreen {
|
||||
|
||||
SplashScreen(SqliteHelper helper, String app) : super(helper, app);
|
||||
@@ -40,7 +42,7 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext ctx) {
|
||||
return a ? new Container(
|
||||
return !a ? new Container(
|
||||
decoration: new BoxDecoration(
|
||||
image: new DecorationImage(
|
||||
image: new ExactAssetImage(Resources.getSplash(null)),
|
||||
@@ -76,10 +78,15 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
var route = new MaterialPageRoute<String>(
|
||||
builder: (BuildContext context) => screen, fullscreenDialog: true);
|
||||
Navigator.of(context).push(route).then((token) {
|
||||
if (token != null) {
|
||||
if (token == '') {
|
||||
showNextScreen(new RegistrationScreen(helper, app));
|
||||
} else if (token != null) {
|
||||
_initAndStartScanner(context, app, token, helper);
|
||||
} else {
|
||||
showNextScreen(new RegistrationScreen(helper, app));
|
||||
print('Произошла непредусмотренная ошибка в логике приложения');
|
||||
helper.getToken().then((token) {
|
||||
_initAndStartScanner(context, app, token, helper);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -209,13 +216,23 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
}
|
||||
|
||||
} else if (call.method == 'faq') {
|
||||
faq(helper, app, context, true);
|
||||
} else if (call.method == 'settings') {
|
||||
new Future.delayed(const Duration(milliseconds: 200), () {
|
||||
var route = new MaterialPageRoute<Null>(
|
||||
builder: (BuildContext context) => new FAQScreen(helper, app), fullscreenDialog: true);
|
||||
Navigator.of(context).push(route).then((_) {
|
||||
_initAndStartScanner(context, app, token, helper);
|
||||
});
|
||||
});
|
||||
} else if (call.method == 'settings') {
|
||||
new Future.delayed(const Duration(milliseconds: 200), () {
|
||||
var route = new MaterialPageRoute<String>(
|
||||
builder: (BuildContext context) => new SettingsScreen(helper, app, true), fullscreenDialog: true);
|
||||
Navigator.of(context).push(route).then((_) {
|
||||
_initAndStartScanner(context, app, token, helper);
|
||||
Navigator.of(context).push(route).then((result) {
|
||||
if (result != null) {
|
||||
showNextScreen(new RegistrationScreen(helper, app));
|
||||
} else {
|
||||
_initAndStartScanner(context, app, token, helper);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user