Правки по меню, по локали, добавлены Евро и Тенге
This commit is contained in:
100
lib/common.dart
100
lib/common.dart
@@ -1,6 +1,6 @@
|
||||
import 'package:checker/screens/faq.dart';
|
||||
import 'package:checker/screens/purchase.dart';
|
||||
import 'package:checker/screens/registration.dart';
|
||||
import 'package:checker/screens/settings.dart';
|
||||
import 'package:checker/screens/splash.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -65,7 +65,9 @@ forceLogout(String token , BuildContext context) async {
|
||||
helper.open().then((_) {
|
||||
helper.clear().then((_) {
|
||||
helper.close().then((_) {
|
||||
Navigator.of(context).pop();
|
||||
while (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
pushRouteReplacement(context, new SplashScreen());
|
||||
});
|
||||
});
|
||||
@@ -78,50 +80,68 @@ forceLogout(String token , BuildContext context) async {
|
||||
/// Запуск спецефичной для каждой платформы части приложения - сканера.
|
||||
/// Может производиться с нескольких экранов (splash, finish_registration).
|
||||
startScanner(BuildContext context, String app, SqliteHelper helper) async {
|
||||
|
||||
String token = await helper.getToken();
|
||||
helper.close();
|
||||
// Канал ловит вызовы методов из "нативной" части приложения.
|
||||
// Могут быть вызваны либо logout либо faq, либо purchase.
|
||||
if (token != null) {
|
||||
platform.setMethodCallHandler((MethodCall call) async {
|
||||
|
||||
if (call.method == 'logout') {
|
||||
forceLogout(token, context);
|
||||
} else if (call.method == 'faq') {
|
||||
faq(context, true);
|
||||
} else {
|
||||
String userString = call.arguments[0];
|
||||
String card = call.arguments[1];
|
||||
var route = new MaterialPageRoute<Null>(builder: (BuildContext context) => new PurchaseScreen(userString, card));
|
||||
Navigator.of(context).pushReplacement(route);
|
||||
}
|
||||
if (helper == null) {
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_) {
|
||||
startScanner(context, app, helper);
|
||||
});
|
||||
} else {
|
||||
String token = await helper.getToken();
|
||||
helper.close();
|
||||
// Канал ловит вызовы методов из "нативной" части приложения.
|
||||
// Могут быть вызваны либо logout либо faq, либо purchase.
|
||||
if (token != null) {
|
||||
platform.setMethodCallHandler((MethodCall call) async {
|
||||
if (call.method == 'logout') {
|
||||
forceLogout(token, context);
|
||||
} else if (call.method == 'faq') {
|
||||
faq(context, true);
|
||||
} else if(call.method == 'settings') {
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_) {
|
||||
pushRoute(context, new SettingsScreen(helper, app, true));
|
||||
});
|
||||
} else {
|
||||
String userString = call.arguments[0];
|
||||
String card = call.arguments[1];
|
||||
var route = new MaterialPageRoute<Null>(
|
||||
builder: (BuildContext context) =>
|
||||
new PurchaseScreen(
|
||||
userString, card));
|
||||
while (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
Navigator.of(context).pushReplacement(route);
|
||||
}
|
||||
});
|
||||
|
||||
await platform.invokeMethod('startScanner', {
|
||||
'token' : token,
|
||||
'url': url,
|
||||
'appToken': appToken,
|
||||
'color': Resources.getPrimaryColor(app).value
|
||||
});
|
||||
await platform.invokeMethod('startScanner', {
|
||||
'token': token,
|
||||
'url': url,
|
||||
'appToken': appToken,
|
||||
'color': Resources
|
||||
.getPrimaryColor(app)
|
||||
.value
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Запуск диалога с двумя кнопками
|
||||
showYesNoDialog(BuildContext context, String title, String content, VoidCallback positiveCallback) {
|
||||
showDialog(context: context, child: new AlertDialog(
|
||||
title: new Text(title),
|
||||
content: new Text(content),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.yes()),
|
||||
onPressed: positiveCallback)]));
|
||||
showDialog(context: context, child: new AlertDialog(
|
||||
title: new Text(title),
|
||||
content: new Text(content),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.yes()),
|
||||
onPressed: positiveCallback)]));
|
||||
}
|
||||
|
||||
getCurrencyTitle(int code) {
|
||||
@@ -130,7 +150,7 @@ getCurrencyTitle(int code) {
|
||||
case 840: return StringsLocalization.nominativeDollar();
|
||||
case 980: return StringsLocalization.nominativeHryvna();
|
||||
case 978: return StringsLocalization.nominativeEuro();
|
||||
case 398: return StringsLocalization.nominativeEuro();
|
||||
case 398: return StringsLocalization.nominativeTenge();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user