iOS zxing scanner, iOS localization
This commit is contained in:
@@ -69,10 +69,12 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
child: getMenuItem(help_png, StringsLocalization.help())
|
||||
));
|
||||
|
||||
menuItemList.add(new PopupMenuItem(
|
||||
value: 2,
|
||||
child: getMenuItem(exit_png, StringsLocalization.exit())
|
||||
));
|
||||
if (Theme.of(context).platform != TargetPlatform.iOS) {
|
||||
menuItemList.add(new PopupMenuItem(
|
||||
value: 2,
|
||||
child: getMenuItem(exit_png, StringsLocalization.exit())
|
||||
));
|
||||
}
|
||||
|
||||
return <Widget>[
|
||||
new PopupMenuButton<int>(
|
||||
@@ -87,7 +89,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
void onOptionsItemClick(int index) {
|
||||
switch (index) {
|
||||
case 0: {
|
||||
pushRoute(context, new SettingsScreen(helper, app, false));
|
||||
pushRoute(context, new SettingsScreen(helper, app, false));
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
|
||||
@@ -45,7 +45,7 @@ logout(BuildContext context, SqliteHelper helper) async {
|
||||
helper.clear().then((result) {
|
||||
// helper.close().then((_) {
|
||||
// Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
// Navigator.of(context).pop();
|
||||
pushRouteReplacement(context, new SplashScreen()); // Запускаем регистрацию
|
||||
// });
|
||||
});
|
||||
@@ -165,7 +165,7 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async {
|
||||
'token': token,
|
||||
'url': await platform.invokeMethod('getEndpoint'),
|
||||
'appToken': await platform.invokeMethod('getAppToken'),
|
||||
'locale': StringsLocalization.localeCode,
|
||||
'localeCode': StringsLocalization.localeCode,
|
||||
'color': Resources.getPrimaryColor(app).value.toString()
|
||||
});
|
||||
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:checker/screens/splash.dart';
|
||||
import 'package:checker/consts.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
||||
|
||||
/// Точка входа в приложение.
|
||||
|
||||
|
||||
///
|
||||
/// some changes
|
||||
|
||||
void main() {
|
||||
platform.invokeMethod('getAppTitle').then((title) {
|
||||
runApp(new Checker(appName: title));
|
||||
@@ -22,7 +15,6 @@ class Checker extends StatelessWidget {
|
||||
final String appName;
|
||||
|
||||
@override Widget build (BuildContext context) {
|
||||
print('app name = ${appName}');
|
||||
return new MaterialApp(
|
||||
title: appName,
|
||||
home: new SplashScreen()
|
||||
|
||||
@@ -37,7 +37,7 @@ getDeleteTokenRequest(String token) async {
|
||||
getLoyaltyRequest(String endpoint, String token) async {
|
||||
var headers = {
|
||||
'DM-Authorization': 'dmapptoken ${await getToken()}',
|
||||
'Authorization': 'dmtoken ${token}',
|
||||
'Authorization': 'dmtoken $token',
|
||||
'Accept-Language': StringsLocalization.localeCode
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ getPurchaseRequest(String endpoint, Map body, String token) async {
|
||||
|
||||
var headers = {
|
||||
'DM-Authorization': 'dmapptoken ${await getToken()}',
|
||||
'Authorization': 'dmtoken ${token}',
|
||||
'Authorization': 'dmtoken $token',
|
||||
'Accept-Language': StringsLocalization.localeCode
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ getCouponsRequest(String endpoint, String token) async {
|
||||
|
||||
var headers = {
|
||||
'DM-Authorization': 'dmapptoken ${await getToken()}',
|
||||
'Authorization': 'dmtoken ${token}',
|
||||
'Authorization': 'dmtoken $token',
|
||||
'Accept-Language': StringsLocalization.localeCode
|
||||
};
|
||||
|
||||
@@ -72,7 +72,7 @@ getUserByCard(String card, String token) async {
|
||||
|
||||
var headers = {
|
||||
'DM-Authorization': 'dmapptoken ${await getToken()}',
|
||||
'Authorization': 'dmtoken ${token}',
|
||||
'Authorization': 'dmtoken $token',
|
||||
'Accept-Language': StringsLocalization.localeCode
|
||||
};
|
||||
|
||||
@@ -87,7 +87,7 @@ getUserByPhone(String phone, String token) async {
|
||||
|
||||
var headers = {
|
||||
'DM-Authorization': 'dmapptoken ${await getToken()}',
|
||||
'Authorization': 'dmtoken ${token}',
|
||||
'Authorization': 'dmtoken $token',
|
||||
'Accept-Language': StringsLocalization.localeCode
|
||||
};
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
if (fractionalPart.length > 2) {
|
||||
fractionalPart = fractionalPart.substring(0, 2);
|
||||
}
|
||||
return '${integerPart}.${fractionalPart}';
|
||||
return '$integerPart.$fractionalPart';
|
||||
} catch (exception) {
|
||||
print(exception);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
menuItems[2].title = StringsLocalization.logout();
|
||||
menuItems[0].selectedValue = info['currency'].toString();
|
||||
menuItems[1].selectedValue =
|
||||
info['locale'] == null ? StringsLocalization.locale() : info['locale'];
|
||||
info['locale'] == null ? StringsLocalization.localeCode : info['locale'];
|
||||
menuItems[2].selectedValue =
|
||||
info['token'] == null ? '' : getTokenSuffix(info['token']);
|
||||
});
|
||||
@@ -83,6 +83,7 @@ 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,
|
||||
@@ -97,6 +98,7 @@ 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;
|
||||
|
||||
@@ -52,9 +52,6 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
helper.getSettings(false).then((settings) {
|
||||
if (settings == null) {
|
||||
createSettingsTable(locale);
|
||||
StringsLocalization.load(locale).then((locale) {
|
||||
print(locale);
|
||||
});
|
||||
} else {
|
||||
initLocale(locale, () {
|
||||
showNext();
|
||||
|
||||
@@ -8,17 +8,15 @@ class StringsLocalization {
|
||||
static String localeCode;
|
||||
static Map<String, String> strings = new Map<String, String>();
|
||||
|
||||
static Future load(String locale) async {
|
||||
localeCode = locale;
|
||||
|
||||
var document = xml.parse(await loadStrings(locale));
|
||||
strings.clear();
|
||||
document.findAllElements('string').forEach((node) {
|
||||
strings[node.attributes[0].value] = node.text.toString();
|
||||
});
|
||||
|
||||
return strings;
|
||||
|
||||
static Future load(String l) async {
|
||||
localeCode = l;
|
||||
var document = xml.parse(await loadStrings(l));
|
||||
strings.clear();
|
||||
document.findAllElements('string').forEach((node) {
|
||||
print("${node.attributes} : ${node.text.toString()}");
|
||||
strings[node.attributes[0].value] = node.text.toString();
|
||||
});
|
||||
return strings;
|
||||
}
|
||||
|
||||
static Future<String> loadStrings(String locale) async {
|
||||
|
||||
Reference in New Issue
Block a user