Локаль можно задать на этапе сборки
This commit is contained in:
@@ -1,217 +0,0 @@
|
|||||||
{
|
|
||||||
"auto_complete":
|
|
||||||
{
|
|
||||||
"selected_items":
|
|
||||||
[
|
|
||||||
[
|
|
||||||
"e",
|
|
||||||
"else"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"pre",
|
|
||||||
"previewing"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"purc",
|
|
||||||
"_purchase"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"buffers":
|
|
||||||
[
|
|
||||||
],
|
|
||||||
"build_system": "",
|
|
||||||
"build_system_choices":
|
|
||||||
[
|
|
||||||
],
|
|
||||||
"build_varint": "",
|
|
||||||
"command_palette":
|
|
||||||
{
|
|
||||||
"height": 359.0,
|
|
||||||
"last_filter": "packa",
|
|
||||||
"selected_items":
|
|
||||||
[
|
|
||||||
[
|
|
||||||
"packa",
|
|
||||||
"Package Control: Install Package"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"pac",
|
|
||||||
"Install Package Control"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"width": 485.0
|
|
||||||
},
|
|
||||||
"console":
|
|
||||||
{
|
|
||||||
"height": 0.0,
|
|
||||||
"history":
|
|
||||||
[
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"distraction_free":
|
|
||||||
{
|
|
||||||
"menu_visible": true,
|
|
||||||
"show_minimap": false,
|
|
||||||
"show_open_files": false,
|
|
||||||
"show_tabs": false,
|
|
||||||
"side_bar_visible": false,
|
|
||||||
"status_bar_visible": false
|
|
||||||
},
|
|
||||||
"file_history":
|
|
||||||
[
|
|
||||||
"/Users/kifio/FlutterProjects/checker/lib/consts.dart",
|
|
||||||
"/Users/kifio/FlutterProjects/checker/lib/activate_token.dart",
|
|
||||||
"/Users/kifio/FlutterProjects/checker/lib/registration.dart",
|
|
||||||
"/Users/kifio/FlutterProjects/checker/lib/purchase_success.dart",
|
|
||||||
"/Users/kifio/FlutterProjects/checker/lib/purchase.dart",
|
|
||||||
"/Users/kifio/FlutterProjects/checker/lib/main.dart",
|
|
||||||
"/Users/kifio/FlutterProjects/checker/lib/faq.dart",
|
|
||||||
"/home/kifio/ShitCoding/checker/lib/main.dart",
|
|
||||||
"/home/kifio/ShitCoding/checker/lib/base_state.dart",
|
|
||||||
"/home/kifio/ShitCoding/checker/lib/splash.dart",
|
|
||||||
"/home/kifio/ShitCoding/checker/lib/registration.dart",
|
|
||||||
"/home/kifio/ShitCoding/checker/lib/activate_token.dart"
|
|
||||||
],
|
|
||||||
"find":
|
|
||||||
{
|
|
||||||
"height": 23.0
|
|
||||||
},
|
|
||||||
"find_in_files":
|
|
||||||
{
|
|
||||||
"height": 93.0,
|
|
||||||
"where_history":
|
|
||||||
[
|
|
||||||
""
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"find_state":
|
|
||||||
{
|
|
||||||
"case_sensitive": true,
|
|
||||||
"find_history":
|
|
||||||
[
|
|
||||||
"intToken",
|
|
||||||
"http://pos-api-autoclub.dinect.com/20130701/",
|
|
||||||
"intUrl",
|
|
||||||
"async",
|
|
||||||
"common",
|
|
||||||
" \treturn new Text('Покупка на сумму 1234.00 руб. проведена', style: new TextStyle(color: tokenActiveTextColor, decorationColor: const Color(0x8ae28aff)));\n",
|
|
||||||
"getProgressIndicator",
|
|
||||||
"direc",
|
|
||||||
"_loading",
|
|
||||||
"_merchantID",
|
|
||||||
" \n",
|
|
||||||
"getPaddingForTextField",
|
|
||||||
"horiz",
|
|
||||||
"horizontaMargin",
|
|
||||||
"28.0",
|
|
||||||
"merchantID"
|
|
||||||
],
|
|
||||||
"highlight": true,
|
|
||||||
"in_selection": false,
|
|
||||||
"preserve_case": false,
|
|
||||||
"regex": false,
|
|
||||||
"replace_history":
|
|
||||||
[
|
|
||||||
"loading",
|
|
||||||
"textFieldValue",
|
|
||||||
"verticalMargin",
|
|
||||||
"_merchantID"
|
|
||||||
],
|
|
||||||
"reverse": false,
|
|
||||||
"show_context": true,
|
|
||||||
"use_buffer2": true,
|
|
||||||
"whole_word": false,
|
|
||||||
"wrap": true
|
|
||||||
},
|
|
||||||
"groups":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"sheets":
|
|
||||||
[
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"incremental_find":
|
|
||||||
{
|
|
||||||
"height": 23.0
|
|
||||||
},
|
|
||||||
"input":
|
|
||||||
{
|
|
||||||
"height": 33.0
|
|
||||||
},
|
|
||||||
"layout":
|
|
||||||
{
|
|
||||||
"cells":
|
|
||||||
[
|
|
||||||
[
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"cols":
|
|
||||||
[
|
|
||||||
0.0,
|
|
||||||
1.0
|
|
||||||
],
|
|
||||||
"rows":
|
|
||||||
[
|
|
||||||
0.0,
|
|
||||||
1.0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"menu_visible": true,
|
|
||||||
"output.find_results":
|
|
||||||
{
|
|
||||||
"height": 0.0
|
|
||||||
},
|
|
||||||
"pinned_build_system": "",
|
|
||||||
"project": "AndroidManifest.sublime-project",
|
|
||||||
"replace":
|
|
||||||
{
|
|
||||||
"height": 42.0
|
|
||||||
},
|
|
||||||
"save_all_on_build": true,
|
|
||||||
"select_file":
|
|
||||||
{
|
|
||||||
"height": 0.0,
|
|
||||||
"last_filter": "",
|
|
||||||
"selected_items":
|
|
||||||
[
|
|
||||||
],
|
|
||||||
"width": 0.0
|
|
||||||
},
|
|
||||||
"select_project":
|
|
||||||
{
|
|
||||||
"height": 0.0,
|
|
||||||
"last_filter": "",
|
|
||||||
"selected_items":
|
|
||||||
[
|
|
||||||
],
|
|
||||||
"width": 0.0
|
|
||||||
},
|
|
||||||
"select_symbol":
|
|
||||||
{
|
|
||||||
"height": 0.0,
|
|
||||||
"last_filter": "",
|
|
||||||
"selected_items":
|
|
||||||
[
|
|
||||||
],
|
|
||||||
"width": 0.0
|
|
||||||
},
|
|
||||||
"selected_group": 0,
|
|
||||||
"settings":
|
|
||||||
{
|
|
||||||
},
|
|
||||||
"show_minimap": true,
|
|
||||||
"show_open_files": false,
|
|
||||||
"show_tabs": true,
|
|
||||||
"side_bar_visible": true,
|
|
||||||
"side_bar_width": 241.0,
|
|
||||||
"status_bar_visible": true,
|
|
||||||
"template_settings":
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.dinect.checker"
|
package="com.dinect.checker"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="0.6">
|
android:versionName="1.0.1">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="16"
|
android:minSdkVersion="16"
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import android.view.Window;
|
|||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.dinect.net.ApiClient;
|
import com.dinect.checker.net.ApiClient;
|
||||||
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class MainActivity extends FlutterActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
GeneratedPluginRegistrant.registerWith(this);
|
GeneratedPluginRegistrant.registerWith(this);
|
||||||
loadLocale(this);
|
initLocale(this);
|
||||||
mPreferences = getPreferences(Context.MODE_PRIVATE);
|
mPreferences = getPreferences(Context.MODE_PRIVATE);
|
||||||
|
|
||||||
Log.d(TAG, "application prefs:");
|
Log.d(TAG, "application prefs:");
|
||||||
@@ -74,6 +74,9 @@ public class MainActivity extends FlutterActivity {
|
|||||||
Map merchantIDArguments = call.arguments();
|
Map merchantIDArguments = call.arguments();
|
||||||
mPreferences.edit().putString(PREF_POS_MERCHANT_ID, (String) merchantIDArguments.get("merchantID")).apply();
|
mPreferences.edit().putString(PREF_POS_MERCHANT_ID, (String) merchantIDArguments.get("merchantID")).apply();
|
||||||
break;
|
break;
|
||||||
|
case "getLocale":
|
||||||
|
result.success(BuildConfig.locale);
|
||||||
|
break;
|
||||||
case "getMerchantID":
|
case "getMerchantID":
|
||||||
result.success(mPreferences.getString(PREF_POS_MERCHANT_ID, null));
|
result.success(mPreferences.getString(PREF_POS_MERCHANT_ID, null));
|
||||||
break;
|
break;
|
||||||
@@ -146,7 +149,7 @@ public class MainActivity extends FlutterActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadLocale(Context context) {
|
public static void initLocale(Context context) {
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
Configuration configuration = new Configuration(res.getConfiguration());
|
Configuration configuration = new Configuration(res.getConfiguration());
|
||||||
switch (BuildConfig.locale) {
|
switch (BuildConfig.locale) {
|
||||||
@@ -169,6 +172,10 @@ public class MainActivity extends FlutterActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getLocale() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void handleItemClick() {
|
public void handleItemClick() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import android.support.annotation.NonNull;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import com.dinect.net.ApiClient;
|
import com.dinect.checker.net.ApiClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by anonymous on 03.08.17.
|
* Created by anonymous on 03.08.17.
|
||||||
@@ -45,7 +45,7 @@ public final class NetworkThread extends Thread {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (null != activity) {
|
if (null != activity) {
|
||||||
final Pair<String, String> response = client.findUser(card);
|
final Pair<String, String> response = client.findUser(activity, card);
|
||||||
Log.d(TAG, "network request done with result: " + response.first);
|
Log.d(TAG, "network request done with result: " + response.first);
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.net.NetworkInfo;
|
|||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
private Utils() {
|
private Utils() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOnline(Context context) {
|
public static boolean isOnline(Context context) {
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.dinect.net;
|
package com.dinect.checker.net;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
@@ -22,6 +23,7 @@ import android.util.Pair;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
import java.lang.String;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -30,6 +32,8 @@ import okhttp3.OkHttpClient;
|
|||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
import com.dinect.checker.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by anonymous
|
* Created by anonymous
|
||||||
*/
|
*/
|
||||||
@@ -41,8 +45,6 @@ public final class ApiClient {
|
|||||||
private static final int TIMEOUT_CONNECTION = 3;
|
private static final int TIMEOUT_CONNECTION = 3;
|
||||||
private static final int TIMEOUT_READ = 3;
|
private static final int TIMEOUT_READ = 3;
|
||||||
private static final int TIMEOUT_WRITE = 3;
|
private static final int TIMEOUT_WRITE = 3;
|
||||||
private static final String IDENTIFIER_NOT_FOUND = "Идентификатор {card} не найден.";
|
|
||||||
|
|
||||||
|
|
||||||
public final String endpoint;
|
public final String endpoint;
|
||||||
public final String appToken;
|
public final String appToken;
|
||||||
@@ -76,7 +78,7 @@ public final class ApiClient {
|
|||||||
* @param card card/foreigncarf number
|
* @param card card/foreigncarf number
|
||||||
* @return (null, error) on fail or (card, user) info on success
|
* @return (null, error) on fail or (card, user) info on success
|
||||||
*/
|
*/
|
||||||
public Pair<String, String> findUser(final @NonNull String card) {
|
public Pair<String, String> findUser(Context ctx, final @NonNull String card) {
|
||||||
|
|
||||||
final Request.Builder builder = new Request.Builder();
|
final Request.Builder builder = new Request.Builder();
|
||||||
final Request request;
|
final Request request;
|
||||||
@@ -91,7 +93,7 @@ public final class ApiClient {
|
|||||||
try {
|
try {
|
||||||
final Response response = http.newCall(request).execute();
|
final Response response = http.newCall(request).execute();
|
||||||
final String body = response.body().string();
|
final String body = response.body().string();
|
||||||
final String NOT_FOUND_MESSAGE = IDENTIFIER_NOT_FOUND.replace("{card}", card);
|
final String NOT_FOUND_MESSAGE = String.format(ctx.getString(R.string.identifier_not_found, card));
|
||||||
switch (response.code()) {
|
switch (response.code()) {
|
||||||
case 200:
|
case 200:
|
||||||
final JSONArray users = new JSONArray(body);
|
final JSONArray users = new JSONArray(body);
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.dinect.net;
|
package com.dinect.checker.net;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
12
android/app/src/main/res/values-ru/strings.xml
Normal file
12
android/app/src/main/res/values-ru/strings.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">AutoBonus</string>
|
||||||
|
<string name="scanner_title">Сканер карты</string>
|
||||||
|
<string name="scan">Сканировать</string>
|
||||||
|
<string name="faq">FAQ</string>
|
||||||
|
<string name="logout">Выход</string>
|
||||||
|
<string name="logout_title">Подтверждение</string>
|
||||||
|
<string name="logout_text">Вы действительно хотите выйти и ввести другой номер магазина?</string>
|
||||||
|
<string name="logout_yes">Да</string>
|
||||||
|
<string name="logout_no">Нет</string>
|
||||||
|
<string name="identifier_not_found">"Идентификатор %s не найден"</string>
|
||||||
|
</resources>
|
||||||
12
android/app/src/main/res/values-ua/strings.xml
Normal file
12
android/app/src/main/res/values-ua/strings.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">AutoBonus</string>
|
||||||
|
<string name="scanner_title">Сканер карти</string>
|
||||||
|
<string name="scan">Сканувати</string>
|
||||||
|
<string name="faq">FAQ</string>
|
||||||
|
<string name="logout">Вихід</string>
|
||||||
|
<string name="logout_title">Підтвердження</string>
|
||||||
|
<string name="logout_text">Ви дійсно хочете вийти і ввести інший номер магазину?</string>
|
||||||
|
<string name="logout_yes">Так</string>
|
||||||
|
<string name="logout_no">Ні</string>
|
||||||
|
<string name="identifier_not_found">"Ідентифікатор %s не знайден"</string>
|
||||||
|
</resources>
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">AutoBonus</string>
|
<string name="app_name">AutoBonus</string>
|
||||||
<string name="scanner_title">Сканнер карты</string>
|
<string name="scanner_title">Card Scanner</string>
|
||||||
<string name="scan">Сканировать</string>
|
<string name="scan">Scan</string>
|
||||||
<string name="faq">FAQ</string>
|
<string name="faq">FAQ</string>
|
||||||
<string name="logout">Выход</string>
|
<string name="logout">Logout</string>
|
||||||
<string name="logout_title">Подтверждение</string>
|
<string name="logout_title">Сonfirmation</string>
|
||||||
<string name="logout_text">Вы действительно хотите выйти и ввести другой номер магазина?</string>
|
<string name="logout_text">Do you really want to log out and enter a different store number?</string>
|
||||||
<string name="logout_yes">Да</string>
|
<string name="logout_yes">Yes</string>
|
||||||
<string name="logout_no">Нет</string>
|
<string name="logout_no">No</string>
|
||||||
|
<string name="identifier_not_found">"Identifier %s is not found"</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -18,28 +18,26 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
|||||||
/// Введенное пользователем значение.
|
/// Введенное пользователем значение.
|
||||||
String textFieldValue = '';
|
String textFieldValue = '';
|
||||||
|
|
||||||
Strings s;
|
|
||||||
|
|
||||||
@override Widget build(BuildContext ctx) {
|
@override Widget build(BuildContext ctx) {
|
||||||
return new Scaffold(appBar: getAppBar(ctx),
|
return new Scaffold(appBar: getAppBar(),
|
||||||
body: new Stack(children: <Widget>[
|
body: new Stack(children: <Widget>[
|
||||||
getScreenContent(ctx),
|
getScreenContent(),
|
||||||
new Center(child: loading ? new CircularProgressIndicator() : null)
|
new Center(child: loading ? new CircularProgressIndicator() : null)
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Возвращает контейнер с всеми виджетами экрана.
|
/// Возвращает контейнер с всеми виджетами экрана.
|
||||||
Widget getScreenContent(BuildContext ctx);
|
Widget getScreenContent();
|
||||||
|
|
||||||
/// Возвращает заголовок для AppBar
|
/// Возвращает заголовок для AppBar
|
||||||
String getTitle(BuildContext ctx);
|
String getTitle();
|
||||||
|
|
||||||
AppBar getAppBar(BuildContext ctx) {
|
AppBar getAppBar() {
|
||||||
return new AppBar(title: new Text(getTitle(ctx), style: new TextStyle(fontSize: 18.0)),
|
return new AppBar(title: new Text(getTitle(), style: new TextStyle(fontSize: 18.0)),
|
||||||
backgroundColor: primaryColor, actions: getMenuButtons(ctx));
|
backgroundColor: primaryColor, actions: getMenuButtons());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getMenuButtons(BuildContext context) {
|
List<Widget> getMenuButtons() {
|
||||||
return <Widget>[getFaqButton()];
|
return <Widget>[getFaqButton()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,28 +50,28 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Возврвщает контейнер, внутри которого Text с подсказкой.
|
/// Возврвщает контейнер, внутри которого Text с подсказкой.
|
||||||
Widget getHintLabel(BuildContext ctx) {
|
Widget getHintLabel() {
|
||||||
double horizontalMargin = 8.0;
|
double horizontalMargin = 8.0;
|
||||||
return new Container(margin: new EdgeInsets.only(top: horizontalMargin, bottom: horizontalMargin, left: verticalMargin, right: verticalMargin),
|
return new Container(margin: new EdgeInsets.only(top: horizontalMargin, bottom: horizontalMargin, left: verticalMargin, right: verticalMargin),
|
||||||
child: new Row(crossAxisAlignment: CrossAxisAlignment.start,
|
child: new Row(crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[new Text(getHintString(ctx), textAlign: TextAlign.left,
|
children: <Widget>[new Text(getHintString(), textAlign: TextAlign.left,
|
||||||
style: new TextStyle(fontWeight: FontWeight.w300, color: error == null ? greyTextColor : primaryColor, fontSize: 14.0))]));
|
style: new TextStyle(fontWeight: FontWeight.w300, color: error == null ? greyTextColor : primaryColor, fontSize: 14.0))]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Возвращает подсказку, либо ошибку, если введенные в поле ввода данные неверны.
|
/// Возвращает подсказку, либо ошибку, если введенные в поле ввода данные неверны.
|
||||||
String getHintString(BuildContext ctx) {
|
String getHintString() {
|
||||||
if (textFieldValue.length == 0 && error == null) {
|
if (textFieldValue.length == 0 && error == null) {
|
||||||
return ' ';
|
return ' ';
|
||||||
} else if (error != null) {
|
} else if (error != null) {
|
||||||
return error;
|
return error;
|
||||||
} else {
|
} else {
|
||||||
return getHint(ctx);
|
return getHint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Возвращает текст подсказки для поля ввода.
|
/// Возвращает текст подсказки для поля ввода.
|
||||||
/// Должен быть переопределен на экранах, на которых есть поле ввода.
|
/// Должен быть переопределен на экранах, на которых есть поле ввода.
|
||||||
String getHint(BuildContext ctx) {
|
String getHint() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,14 +83,17 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Метод возвращает контейнер с полем ввода внутри.
|
/// Метод возвращает контейнер с полем ввода внутри.
|
||||||
Widget getInputField(BuildContext ctx) {
|
Widget getInputField() {
|
||||||
return new Container(margin: new EdgeInsets.only(left: verticalMargin, right: verticalMargin),
|
return new Container(margin: new EdgeInsets.only(left: verticalMargin, right: verticalMargin),
|
||||||
padding: getInputFieldContainerPadding(),
|
padding: getInputFieldContainerPadding(),
|
||||||
decoration: getInputFieldContainerDecoration(),
|
decoration: getInputFieldContainerDecoration(),
|
||||||
child: new TextField(keyboardType: TextInputType.number,
|
child: getTextWidget());
|
||||||
decoration: new InputDecoration.collapsed(hintText: getHint(ctx),
|
}
|
||||||
hintStyle: new TextStyle(color: greyTextColor, fontSize: 16.0)),
|
|
||||||
onChanged: (text) => handleUserInput(text)));
|
/// Возвращает поле ввода.
|
||||||
|
/// Переопределяется для использования на экранах регистрации и проведения покупки.
|
||||||
|
Widget getTextWidget() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Возвращат паддинги для поля ввода.
|
/// Возвращат паддинги для поля ввода.
|
||||||
@@ -113,7 +114,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Возвращает выпуклую залитую фирменным цветом кнопку
|
/// Возвращает выпуклую залитую фирменным цветом кнопку
|
||||||
Widget buildRaisedButton(BuildContext context, String text, VoidCallback onPressed) {
|
Widget buildRaisedButton(String text, VoidCallback onPressed) {
|
||||||
return new RaisedButton(child: new Text(text,
|
return new RaisedButton(child: new Text(text,
|
||||||
style: new TextStyle(color: Colors.white)),
|
style: new TextStyle(color: Colors.white)),
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
@@ -138,7 +139,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
|||||||
|
|
||||||
/// Возвращает список, единственный элемент которого - Text с заголовком для текстового поля.
|
/// Возвращает список, единственный элемент которого - Text с заголовком для текстового поля.
|
||||||
List<Widget> getDescriptionWidget(String title) {
|
List<Widget> getDescriptionWidget(String title) {
|
||||||
return <Widget>[new Text(title, textAlign: TextAlign.left, style: new TextStyle(color: greyTextColor, fontSize: 14.0))]
|
return <Widget>[new Text(title, textAlign: TextAlign.left, style: new TextStyle(color: greyTextColor, fontSize: 14.0))];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Возвращает список, единственный элемент которого - Text с информацией (размер скидки, сумма проведенной покупки).
|
/// Возвращает список, единственный элемент которого - Text с информацией (размер скидки, сумма проведенной покупки).
|
||||||
@@ -147,7 +148,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Возвращает кнопку, обернутую набором специфичных контейнеров.
|
/// Возвращает кнопку, обернутую набором специфичных контейнеров.
|
||||||
Widget buildButton(EdgeInsets margin, Widget widget) {
|
Widget wrapButton(EdgeInsets margin, Widget widget) {
|
||||||
return new Container(margin: margin, height: buttonHeight, child: new Row(children: <Widget>[new Expanded(child: widget)]));
|
return new Container(margin: margin, height: buttonHeight, child: new Row(children: <Widget>[new Expanded(child: widget)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ import 'strings.dart';
|
|||||||
// Канал для взаимодействия с кодом платформы.
|
// Канал для взаимодействия с кодом платформы.
|
||||||
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
||||||
|
|
||||||
/// Токен кассы. Инициализируется при регистрации.
|
|
||||||
String token;
|
|
||||||
|
|
||||||
// Метод обеспечивает замену текущего объекта route новым.
|
// Метод обеспечивает замену текущего объекта route новым.
|
||||||
pushRoute(BuildContext context, Widget widget) {
|
pushRoute(BuildContext context, Widget widget) {
|
||||||
var route = new MaterialPageRoute<Null>(builder: (BuildContext context) => widget);
|
var route = new MaterialPageRoute<Null>(builder: (BuildContext context) => widget);
|
||||||
@@ -27,8 +24,8 @@ faq(BuildContext context, bool returnToScanner) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// В методе отправляется запрос на удаление токена кассы, очищаются SharedPreferences приложения.
|
// В методе отправляется запрос на удаление токена кассы, очищаются SharedPreferences приложения.
|
||||||
logout(BuildContext context) {
|
logout(BuildContext context) async {
|
||||||
|
String token = await platform.invokeMethod('getToken');
|
||||||
VoidCallback positiveCalback = () {
|
VoidCallback positiveCalback = () {
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
deleteToken(token).then((response) {
|
deleteToken(token).then((response) {
|
||||||
@@ -47,11 +44,11 @@ logout(BuildContext context) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
showYesNoDialog(context, Strings.of(context).confirmation(), Strings.of(context).askChangeStore(), positiveCalback);
|
showYesNoDialog(context, StringsLocalization.confirmation(), StringsLocalization.askChangeStore(), positiveCalback);
|
||||||
}
|
}
|
||||||
|
|
||||||
forceLogout(BuildContext context) {
|
forceLogout(BuildContext context) async {
|
||||||
|
String token = await platform.invokeMethod('getToken');
|
||||||
deleteToken(token).then((response) {
|
deleteToken(token).then((response) {
|
||||||
print(response.body);
|
print(response.body);
|
||||||
platform.invokeMethod('removeKeys').then((result) {
|
platform.invokeMethod('removeKeys').then((result) {
|
||||||
@@ -67,6 +64,7 @@ forceLogout(BuildContext context) {
|
|||||||
/// Может производиться с нескольких экранов (splash, finish_registration).
|
/// Может производиться с нескольких экранов (splash, finish_registration).
|
||||||
startScanner(BuildContext context) async {
|
startScanner(BuildContext context) async {
|
||||||
|
|
||||||
|
String token = await platform.invokeMethod('getToken');
|
||||||
// Канал ловит вызовы методов из "нативной" части приложения.
|
// Канал ловит вызовы методов из "нативной" части приложения.
|
||||||
// Могут быть вызваны либо logaut либо faq, либо purchase.
|
// Могут быть вызваны либо logaut либо faq, либо purchase.
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
@@ -101,12 +99,12 @@ showYesNoDialog(BuildContext context, String title, String content, VoidCallback
|
|||||||
content: new Text(content),
|
content: new Text(content),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
new FlatButton(
|
new FlatButton(
|
||||||
child: new Text(Strings.of(context).no()),
|
child: new Text(StringsLocalization.no()),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
new FlatButton(
|
new FlatButton(
|
||||||
child: new Text(Strings.of(context).yes()),
|
child: new Text(StringsLocalization.yes()),
|
||||||
onPressed: positiveCallback)]));
|
onPressed: positiveCallback)]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class FAQScreenState<T> extends BaseState<FAQScreen> {
|
|||||||
return "FAQ";
|
return "FAQ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@override getMenuButtons(BuildContext context) {
|
@override getMenuButtons() {
|
||||||
return <Widget>[getLogoutButton()];
|
return <Widget>[getLogoutButton()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override String getTitle() {
|
@override String getTitle() {
|
||||||
return Strings.of(context).registration();
|
return StringsLocalization.registration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override getHint() {
|
@override getHint() {
|
||||||
return Strings.of(context).idStore();
|
return StringsLocalization.idStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override Widget getScreenContent() {
|
@override Widget getScreenContent() {
|
||||||
@@ -37,9 +37,9 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
|||||||
getHintLabel(),
|
getHintLabel(),
|
||||||
getInputField(),
|
getInputField(),
|
||||||
getMessage(),
|
getMessage(),
|
||||||
buildRaisedButton(context, _tokenActive
|
buildRaisedButton(_tokenActive
|
||||||
? Strings.of(context).completeRegistration()
|
? StringsLocalization.completeRegistration()
|
||||||
: Strings.of(context).refreshActivationStatus(), () => handleTap())
|
: StringsLocalization.refreshActivationStatus(), () => handleTap())
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +50,7 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
|||||||
startScanner(context);
|
startScanner(context);
|
||||||
} else {
|
} else {
|
||||||
if (await platform.invokeMethod('isOnline')) {
|
if (await platform.invokeMethod('isOnline')) {
|
||||||
|
String token = await platform.invokeMethod('getToken');
|
||||||
checkTokenStatus(token).then((response) {
|
checkTokenStatus(token).then((response) {
|
||||||
|
|
||||||
print(response.body);
|
print(response.body);
|
||||||
@@ -68,8 +69,9 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override Widget getTextWidget() {
|
@override getTextWidget() {
|
||||||
return new Row(children: <Widget>[new Text(_merchantID != null ? _merchantID : '', style: new TextStyle(color: Colors.black, fontSize: 16.0))]);
|
return new Row(children: <Widget>[new Text(_merchantID != null ? _merchantID : '',
|
||||||
|
style: new TextStyle(color: Colors.black, fontSize: 16.0))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Достаем сохраненный в SharedPreferences merchantID.
|
/// Достаем сохраненный в SharedPreferences merchantID.
|
||||||
@@ -84,7 +86,7 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
|||||||
|
|
||||||
/// Метод возвращает контейнер с текстом сообщения и бэкграундом.
|
/// Метод возвращает контейнер с текстом сообщения и бэкграундом.
|
||||||
getMessage() {
|
getMessage() {
|
||||||
return new Container(height: _tokenActive ? 72.0 : 108.0, decoration: _getDecoraionForMessageField(),
|
return new Container(height: _tokenActive ? 72.0 : 108.0, decoration: _getDecorationForMessageField(),
|
||||||
margin: new EdgeInsets.only(top: 20.0, left: 12.0, right: 12.0),
|
margin: new EdgeInsets.only(top: 20.0, left: 12.0, right: 12.0),
|
||||||
padding: new EdgeInsets.only(bottom: 22.0, left: 14.0, right: 14.0),
|
padding: new EdgeInsets.only(bottom: 22.0, left: 14.0, right: 14.0),
|
||||||
child: new Center(child: getMessageTextWidget()));
|
child: new Center(child: getMessageTextWidget()));
|
||||||
@@ -100,13 +102,14 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
|||||||
/// Получаем текст сообщения, в зависимости от статуса активации.
|
/// Получаем текст сообщения, в зависимости от статуса активации.
|
||||||
getMessageString() {
|
getMessageString() {
|
||||||
return _tokenActive
|
return _tokenActive
|
||||||
? Strings.of(context).completeRegistration()
|
? StringsLocalization.completeRegistration()
|
||||||
: Strings.of(context).refreshActivationStatus();
|
: StringsLocalization.refreshActivationStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Фоновое изображение для сообщения.
|
/// Фоновое изображение для сообщения.
|
||||||
Decoration _getDecoraionForMessageField() {
|
Decoration _getDecorationForMessageField() {
|
||||||
return new BoxDecoration(image: new DecorationImage(
|
return new BoxDecoration(image: new DecorationImage(
|
||||||
image: new ExactAssetImage(_tokenActive ? active_token_bg_png : activate_token_bg_png), fit: _tokenActive ? BoxFit.fitWidth : BoxFit.fill));
|
image: new ExactAssetImage(_tokenActive ? active_token_bg_png : activate_token_bg_png),
|
||||||
|
fit: _tokenActive ? BoxFit.fitWidth : BoxFit.fill));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||||
static _notInlinedMessages(_) => {
|
static _notInlinedMessages(_) => {
|
||||||
"ID_Store" : MessageLookupByLibrary.simpleMessage("DIN Store"),
|
"ID_Store" : MessageLookupByLibrary.simpleMessage("DIN Store"),
|
||||||
"ID_not_found" : MessageLookupByLibrary.simpleMessage("Identifier N is not found"),
|
"ID_not_found" : MessageLookupByLibrary.simpleMessage("Identifier %s is not found"),
|
||||||
"app_activ" : MessageLookupByLibrary.simpleMessage("The application is activated"),
|
"app_activ" : MessageLookupByLibrary.simpleMessage("The application is activated"),
|
||||||
"ask_change_store" : MessageLookupByLibrary.simpleMessage("Do you really want to log out and enter a different store number?"),
|
"ask_change_store" : MessageLookupByLibrary.simpleMessage("Do you really want to log out and enter a different store number?"),
|
||||||
"buyer" : MessageLookupByLibrary.simpleMessage("Buyer"),
|
"buyer" : MessageLookupByLibrary.simpleMessage("Buyer"),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||||
static _notInlinedMessages(_) => {
|
static _notInlinedMessages(_) => {
|
||||||
"ID_Store" : MessageLookupByLibrary.simpleMessage("DIN del negocio "),
|
"ID_Store" : MessageLookupByLibrary.simpleMessage("DIN del negocio "),
|
||||||
"ID_not_found" : MessageLookupByLibrary.simpleMessage("ID N no está encontrado"),
|
"ID_not_found" : MessageLookupByLibrary.simpleMessage("ID %s no está encontrado"),
|
||||||
"app_activ" : MessageLookupByLibrary.simpleMessage("Aplicación está activada"),
|
"app_activ" : MessageLookupByLibrary.simpleMessage("Aplicación está activada"),
|
||||||
"ask_change_store" : MessageLookupByLibrary.simpleMessage("¿Os realmente quiereis acabarse una sesión y dar otro DIN del negocio?"),
|
"ask_change_store" : MessageLookupByLibrary.simpleMessage("¿Os realmente quiereis acabarse una sesión y dar otro DIN del negocio?"),
|
||||||
"buyer" : MessageLookupByLibrary.simpleMessage("El comprador"),
|
"buyer" : MessageLookupByLibrary.simpleMessage("El comprador"),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||||
static _notInlinedMessages(_) => {
|
static _notInlinedMessages(_) => {
|
||||||
"ID_Store" : MessageLookupByLibrary.simpleMessage("DIN магазина"),
|
"ID_Store" : MessageLookupByLibrary.simpleMessage("DIN магазина"),
|
||||||
"ID_not_found" : MessageLookupByLibrary.simpleMessage("Идентификатор N не найден"),
|
"ID_not_found" : MessageLookupByLibrary.simpleMessage("Идентификатор %s не найден"),
|
||||||
"app_activ" : MessageLookupByLibrary.simpleMessage("Приложение активировано"),
|
"app_activ" : MessageLookupByLibrary.simpleMessage("Приложение активировано"),
|
||||||
"ask_change_store" : MessageLookupByLibrary.simpleMessage("Вы действительно хотите выйти и ввести другой номер магазина?"),
|
"ask_change_store" : MessageLookupByLibrary.simpleMessage("Вы действительно хотите выйти и ввести другой номер магазина?"),
|
||||||
"buyer" : MessageLookupByLibrary.simpleMessage("Покупатель"),
|
"buyer" : MessageLookupByLibrary.simpleMessage("Покупатель"),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||||
static _notInlinedMessages(_) => {
|
static _notInlinedMessages(_) => {
|
||||||
"ID_Store" : MessageLookupByLibrary.simpleMessage("DIN магазину"),
|
"ID_Store" : MessageLookupByLibrary.simpleMessage("DIN магазину"),
|
||||||
"ID_not_found" : MessageLookupByLibrary.simpleMessage("Ідентифікатор N не знайден"),
|
"ID_not_found" : MessageLookupByLibrary.simpleMessage("Ідентифікатор %s не знайден"),
|
||||||
"app_activ" : MessageLookupByLibrary.simpleMessage("Додаток активований"),
|
"app_activ" : MessageLookupByLibrary.simpleMessage("Додаток активований"),
|
||||||
"ask_change_store" : MessageLookupByLibrary.simpleMessage("Ви дійсно хочете вийти і ввести інший номер магазину"),
|
"ask_change_store" : MessageLookupByLibrary.simpleMessage("Ви дійсно хочете вийти і ввести інший номер магазину"),
|
||||||
"buyer" : MessageLookupByLibrary.simpleMessage("Покупець"),
|
"buyer" : MessageLookupByLibrary.simpleMessage("Покупець"),
|
||||||
|
|||||||
@@ -2,8 +2,23 @@ import 'package:flutter/material.dart';
|
|||||||
import 'splash.dart';
|
import 'splash.dart';
|
||||||
import 'consts.dart';
|
import 'consts.dart';
|
||||||
import 'strings.dart';
|
import 'strings.dart';
|
||||||
|
import 'common.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
class StringsLocalizationDelegate extends LocalizationsDelegate<StringsLocalization> {
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<StringsLocalization> load(Locale locale) async {
|
||||||
|
return StringsLocalization.load(await platform.invokeMethod("getLocale"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldReload(LocalizationsDelegate<StringsLocalization> old) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// Точка входа в приложение.
|
/// Точка входа в приложение.
|
||||||
void main() {
|
void main() {
|
||||||
runApp(new Checker());
|
runApp(new Checker());
|
||||||
@@ -18,7 +33,12 @@ class CheckerState extends State<Checker> {
|
|||||||
@override Widget build(BuildContext context) {
|
@override Widget build(BuildContext context) {
|
||||||
return new MaterialApp(
|
return new MaterialApp(
|
||||||
title: appName,
|
title: appName,
|
||||||
home: new SplashScreen()
|
home: new SplashScreen(),
|
||||||
|
localizationsDelegates: getLocalizationsDelegate()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLocalizationsDelegate() {
|
||||||
|
return <StringsLocalizationDelegate>[new StringsLocalizationDelegate()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,24 +31,24 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
PurchaseScreenState(String userString, String card) {
|
PurchaseScreenState(String userString, String card) {
|
||||||
this.user = JSON.decode(userString);
|
this.user = JSON.decode(userString);
|
||||||
this.card = card;
|
this.card = card;
|
||||||
getLoyality(user['loyalty_url']);
|
getLoyalty(user['loyalty_url']);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool purchaseInProgress = false;
|
bool purchaseInProgress = false;
|
||||||
Map user;
|
Map user;
|
||||||
String card = '';
|
String card = '';
|
||||||
String loyality = '';
|
String loyalty = '';
|
||||||
|
|
||||||
@override Widget getScreenContent() {
|
@override Widget getScreenContent() {
|
||||||
return new Column(
|
return new Column(
|
||||||
children: <Widget>[new Expanded(child: new ListView(children: <Widget>[
|
children: <Widget>[new Expanded(child: new ListView(children: <Widget>[
|
||||||
getValueWithDescription(Strings.of(context).userName(), user['first_name'] == null ? '' : user['first_name']),
|
getValueWithDescription(StringsLocalization.userName(), user['first_name'] == null ? '' : user['first_name']),
|
||||||
getValueWithDescription(Strings.of(context).card(), card),
|
getValueWithDescription(StringsLocalization.card(), card),
|
||||||
getValueWithDescription(Strings.of(context).reward(), loyality),
|
getValueWithDescription(StringsLocalization.reward(), loyalty),
|
||||||
getHintLabel(),
|
getHintLabel(),
|
||||||
getInputField(),
|
getInputField(),
|
||||||
buildButton(getScreenMargins(36.0), getCompleteButton()),
|
wrapButton(getScreenMargins(36.0), getCompleteButton()),
|
||||||
buildButton(getScreenMargins(24.0), getScanButton(context, Strings.of(context).scan(), primaryColor))
|
wrapButton(getScreenMargins(24.0), getScanButton(context, StringsLocalization.scan(), primaryColor))
|
||||||
]))]);
|
]))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +58,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCompleteButton() {
|
getCompleteButton() {
|
||||||
String title = Strings.of(context).completePurchase();
|
return buildRaisedButton(StringsLocalization.completePurchase(), () => onPurchaseClick());
|
||||||
return buildRaisedButton(context, title, () => onPurchaseClick(context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getScanButton(BuildContext context, String title, Color textColor) {
|
Widget getScanButton(BuildContext context, String title, Color textColor) {
|
||||||
@@ -76,21 +75,17 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override String getTitle() {
|
@override String getTitle() {
|
||||||
return Strings.of(context).carryingPurchase();
|
return StringsLocalization.carryingPurchase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override getHint() {
|
@override getHint() {
|
||||||
return Strings.of(context).sum();
|
return StringsLocalization.sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override getMenuButtons(BuildContext context) {
|
@override getMenuButtons() {
|
||||||
return <Widget>[getFaqButton(), getLogoutButton()];
|
return <Widget>[getFaqButton(), getLogoutButton()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override Color getTextFilledBackground() {
|
|
||||||
return Colors.white;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override getTextWidget() {
|
@override getTextWidget() {
|
||||||
return new TextField(
|
return new TextField(
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
@@ -109,10 +104,12 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLoyality(String url) async {
|
getLoyalty(String url) async {
|
||||||
|
|
||||||
if (await platform.invokeMethod('isOnline')) {
|
if (await platform.invokeMethod('isOnline')) {
|
||||||
|
|
||||||
|
String token = await platform.invokeMethod('getToken');
|
||||||
|
|
||||||
var headers = {
|
var headers = {
|
||||||
'DM-Authorization': 'dmapptoken $appToken',
|
'DM-Authorization': 'dmapptoken $appToken',
|
||||||
'Authorization': 'dmtoken ${token}'
|
'Authorization': 'dmtoken ${token}'
|
||||||
@@ -126,11 +123,11 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
String type = bonuses['type'];
|
String type = bonuses['type'];
|
||||||
setState(() {
|
setState(() {
|
||||||
if (type == 'amount') {
|
if (type == 'amount') {
|
||||||
this.loyality = '${user['discount']}%';
|
this.loyalty = '${user['discount']}%';
|
||||||
} else {
|
} else {
|
||||||
List amountToBonus = bonuses['amount_to_bonus'];
|
List amountToBonus = bonuses['amount_to_bonus'];
|
||||||
double loyalityVal = (double.parse(amountToBonus[1]) / amountToBonus[0]) * 100;
|
double loyalityVal = (double.parse(amountToBonus[1]) / amountToBonus[0]) * 100;
|
||||||
this.loyality = '${loyalityVal.toStringAsFixed(0)}%';
|
this.loyalty = '${loyalityVal.toStringAsFixed(0)}%';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
@@ -175,20 +172,20 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
return sumTotal.toStringAsFixed(2);
|
return sumTotal.toStringAsFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPurchaseClick(BuildContext context) {
|
onPurchaseClick() {
|
||||||
String val = _parseSum(controller.text);
|
String val = _parseSum(controller.text);
|
||||||
showDialog(context: context, child: new AlertDialog(
|
showDialog(context: context, child: new AlertDialog(
|
||||||
title: new Text(Strings.of(context).confirmation()),
|
title: new Text(StringsLocalization.confirmation()),
|
||||||
content: new Text(getContentMessage(val)),
|
content: new Text(StringsLocalization.confirmPurchase(val)),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
new FlatButton(
|
new FlatButton(
|
||||||
child: new Text(Strings.of(context).no()),
|
child: new Text(StringsLocalization.no()),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
new FlatButton(
|
new FlatButton(
|
||||||
child: new Text(Strings.of(context).yes()),
|
child: new Text(StringsLocalization.yes()),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
purchase(val);
|
purchase(val);
|
||||||
},
|
},
|
||||||
@@ -196,14 +193,12 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
getContentMessage(String val) {
|
|
||||||
return Strings.of(context).confirmPurchase();
|
|
||||||
}
|
|
||||||
|
|
||||||
purchase(String sumTotal) async {
|
purchase(String sumTotal) async {
|
||||||
if (await platform.invokeMethod('isOnline')) {
|
if (await platform.invokeMethod('isOnline')) {
|
||||||
if (!purchaseInProgress) {
|
if (!purchaseInProgress) {
|
||||||
purchaseInProgress = true;
|
purchaseInProgress = true;
|
||||||
|
|
||||||
|
String token = await platform.invokeMethod('getToken');
|
||||||
platform.invokeMethod('getDocID').then((result) {
|
platform.invokeMethod('getDocID').then((result) {
|
||||||
|
|
||||||
String url = user['purchases_url'];
|
String url = user['purchases_url'];
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
|||||||
String sum;
|
String sum;
|
||||||
String username;
|
String username;
|
||||||
|
|
||||||
@override getMenuButtons(BuildContext context) {
|
@override getMenuButtons() {
|
||||||
return <Widget>[getFaqButton(), getLogoutButton()];
|
return <Widget>[getFaqButton(), getLogoutButton()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override String getTitle() {
|
@override String getTitle() {
|
||||||
return Strings.of(context).carryingPurchase();
|
return StringsLocalization.carryingPurchase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override String getHint() {
|
@override String getHint() {
|
||||||
@@ -36,10 +36,10 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
|||||||
|
|
||||||
@override Widget getScreenContent() {
|
@override Widget getScreenContent() {
|
||||||
return new Column(children: <Widget>[
|
return new Column(children: <Widget>[
|
||||||
getValueWithDescription(Strings.of(context).buyer(), username),
|
getValueWithDescription(StringsLocalization.buyer(), username),
|
||||||
getSuccessMessage(),
|
getSuccessMessage(),
|
||||||
new Expanded(child: new Center()),
|
new Expanded(child: new Center()),
|
||||||
buildButton(getScreenMargins(74.0), getScanButton())
|
wrapButton(getScreenMargins(74.0), getScanButton())
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,8 +49,8 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getScanButton() {
|
getScanButton() {
|
||||||
String title = Strings.of(context).scan();
|
String title = StringsLocalization.scan();
|
||||||
return buildRaisedButton(context, title, () => startScanner(context));
|
return buildRaisedButton(title, () => startScanner(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
getSuccessMessage() {
|
getSuccessMessage() {
|
||||||
@@ -61,7 +61,7 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMessageTitle() {
|
getMessageTitle() {
|
||||||
return Strings.of(context).purchaseCompleted(sum);
|
return StringsLocalization.purchaseCompleted(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'dart:convert'; // Пакет для обработки json с ответом от сервера.
|
import 'dart:convert'; // Пакет для обработки json с ответом от сервера.
|
||||||
|
|
||||||
import 'package:checker/common.dart';
|
import 'package:checker/common.dart';
|
||||||
|
import 'package:checker/consts.dart';
|
||||||
import 'package:checker/network.dart';
|
import 'package:checker/network.dart';
|
||||||
import 'package:checker/base_state.dart';
|
import 'package:checker/base_state.dart';
|
||||||
import 'package:checker/strings.dart';
|
import 'package:checker/strings.dart';
|
||||||
@@ -14,36 +15,42 @@ class RegistrationScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||||
|
|
||||||
@override String getTitle(BuildContext ctx) {
|
@override String getTitle() {
|
||||||
return "registration";
|
return StringsLocalization.registration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override getHint(BuildContext ctx) {
|
@override getHint() {
|
||||||
return "idStore()";
|
return StringsLocalization.idStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Список виджетов, автоматически прокручиваемый вверх при открытии клавиатуры.
|
/// Список виджетов, автоматически прокручиваемый вверх при открытии клавиатуры.
|
||||||
@override Widget getScreenContent(BuildContext ctx) {
|
@override Widget getScreenContent() {
|
||||||
print(new Strings().registration());
|
|
||||||
return new Container(
|
return new Container(
|
||||||
child: new ListView(children: <Widget>[
|
child: new ListView(children: <Widget>[
|
||||||
new Column(children: <Widget>[
|
new Column(children: <Widget>[
|
||||||
getLogo(),
|
getLogo(),
|
||||||
getHintLabel(ctx),
|
getHintLabel(),
|
||||||
getInputField(ctx),
|
getInputField(),
|
||||||
getButton(ctx)])
|
getButton()])
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override getTextWidget() {
|
||||||
|
return new TextField(keyboardType: TextInputType.number,
|
||||||
|
decoration: new InputDecoration.collapsed(hintText: getHint(),
|
||||||
|
hintStyle: new TextStyle(color: greyTextColor, fontSize: 16.0)),
|
||||||
|
onChanged: (text) => handleUserInput(text));
|
||||||
|
}
|
||||||
|
|
||||||
/// Возвращает кнопку регистрации.
|
/// Возвращает кнопку регистрации.
|
||||||
getButton(BuildContext ctx) {
|
getButton() {
|
||||||
return new Container(margin: new EdgeInsets.only(top: 36.0), child:
|
return new Container(margin: new EdgeInsets.only(top: 36.0), child:
|
||||||
buildRaisedButton(ctx, "signUp()", getOnPressed(ctx)));
|
buildRaisedButton(StringsLocalization.signUp(), getOnPressed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Возвращает обработчик нажатий на кнопку регистрации.
|
// Возвращает обработчик нажатий на кнопку регистрации.
|
||||||
getOnPressed(BuildContext ctx) {
|
getOnPressed() {
|
||||||
return _isValidMerchantID() && !loading ? () => _registerShop(ctx) : null;
|
return _isValidMerchantID() && !loading ? () => _registerShop() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Токен кассы - это DIN код. DIN код - это специальный код динекта, максимальная его длина - 25 символов.
|
/// Токен кассы - это DIN код. DIN код - это специальный код динекта, максимальная его длина - 25 символов.
|
||||||
@@ -53,15 +60,15 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Показать progressBar, запросить токен.
|
/// Показать progressBar, запросить токен.
|
||||||
_registerShop(BuildContext ctx) {
|
_registerShop() {
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = true;
|
loading = true;
|
||||||
_register(ctx);
|
_register();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Получение от платформы id установки, формирование запроса на получение токена, сохранение токена.
|
/// Получение от платформы id установки, формирование запроса на получение токена, сохранение токена.
|
||||||
_register(BuildContext ctx) async {
|
_register() async {
|
||||||
if (await platform.invokeMethod('isOnline')) {
|
if (await platform.invokeMethod('isOnline')) {
|
||||||
createToken(textFieldValue, await platform.invokeMethod('getPosID')).then((response) {
|
createToken(textFieldValue, await platform.invokeMethod('getPosID')).then((response) {
|
||||||
|
|
||||||
@@ -71,12 +78,13 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
print(response.body);
|
print(response.body);
|
||||||
|
|
||||||
Map parsedMap = JSON.decode(response.body);
|
Map parsedMap = JSON.decode(response.body);
|
||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
token = parsedMap['token'];
|
String token = parsedMap['token'];
|
||||||
platform.invokeMethod('saveToken', {'token' : token});
|
platform.invokeMethod('saveToken', {'token' : token});
|
||||||
platform.invokeMethod('saveMerchantID', {'merchantID' : textFieldValue});
|
platform.invokeMethod('saveMerchantID', {'merchantID' : textFieldValue});
|
||||||
pushRoute(ctx, new FinishRegistrationScreen());
|
pushRoute(context, new FinishRegistrationScreen());
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
error = parsedMap['errors'][0];
|
error = parsedMap['errors'][0];
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
@@ -16,14 +17,14 @@ class SplashScreen extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Появляется splash screen, проверяется токен.
|
// Появляется splash screen, проверяется токен.
|
||||||
|
|
||||||
Strings s = new Strings();
|
new Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
s.load("ru").then((_) {
|
platform.invokeMethod("getLocale").then((locale) {
|
||||||
showNextScreen(context);
|
Intl.defaultLocale = locale;
|
||||||
|
print(Intl.defaultLocale);
|
||||||
|
showNextScreen(context);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// new Future.delayed(const Duration(milliseconds: 500), () {
|
|
||||||
// });
|
|
||||||
|
|
||||||
return new Stack(children: <Widget>[getSplashBackground(), getLogo(),
|
return new Stack(children: <Widget>[getSplashBackground(), getLogo(),
|
||||||
new Align(alignment: FractionalOffset.bottomRight, child:
|
new Align(alignment: FractionalOffset.bottomRight, child:
|
||||||
new Container(margin: new EdgeInsets.only(right: 11.0, bottom: 5.0), child:
|
new Container(margin: new EdgeInsets.only(right: 11.0, bottom: 5.0), child:
|
||||||
@@ -48,7 +49,7 @@ class SplashScreen extends StatelessWidget {
|
|||||||
/// Запуск следующего экрана приложения.
|
/// Запуск следующего экрана приложения.
|
||||||
showNextScreen(BuildContext context) async {
|
showNextScreen(BuildContext context) async {
|
||||||
|
|
||||||
token = await platform.invokeMethod('getToken');
|
String token = await platform.invokeMethod('getToken');
|
||||||
|
|
||||||
// В случае, если в приложении отсутствует токен,
|
// В случае, если в приложении отсутствует токен,
|
||||||
// необходимо запустить регистрацию кассы.
|
// необходимо запустить регистрацию кассы.
|
||||||
|
|||||||
@@ -1,45 +1,42 @@
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'i18n/messages_all.dart';
|
import 'i18n/messages_all.dart';
|
||||||
|
import 'package:sprintf/sprintf.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
class Strings {
|
class StringsLocalization {
|
||||||
|
|
||||||
static final Strings _singleton = new Strings._internal();
|
static Future load(String locale) async {
|
||||||
|
|
||||||
String _localeName;
|
|
||||||
|
|
||||||
factory Strings(){
|
|
||||||
return _singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
Strings._internal();
|
|
||||||
|
|
||||||
Future load(String locale) async {
|
|
||||||
_localeName = locale;
|
|
||||||
return initializeMessages(locale);
|
return initializeMessages(locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
String registration() => Intl.message('registration', name: 'registration', locale: _localeName);
|
static String confirmPurchase(String val) {
|
||||||
String idStore() => Intl.message('ID_Store', name: 'ID_Store', locale: _localeName);
|
return sprintf(Intl.message('confirm_purchase', name: 'confirm_purchase', locale: Intl.defaultLocale), [val]);
|
||||||
String signUp() => Intl.message('sign_up', name: 'sign_up', locale: _localeName);
|
}
|
||||||
String specifyDinStore() => Intl.message('specify_din_store', name: 'specify_din_store', locale: _localeName);
|
|
||||||
String confirmation() => Intl.message('confirmation', name: 'confirmation', locale: _localeName);
|
static String purchaseCompleted(String val) {
|
||||||
String askChangeStore() => Intl.message('ask_change_store', name: 'ask_change_store', locale: _localeName);
|
return sprintf(Intl.message('purchase_complite', name: 'purchase_complite', locale: Intl.defaultLocale), [val]);
|
||||||
String yes() => Intl.message('yes', name: 'yes', locale: _localeName);
|
}
|
||||||
String no() => Intl.message('no', name: 'no', locale: _localeName);
|
|
||||||
String requestSentWaitActivation() => Intl.message('request_sent_wait_activ', name: 'request_sent_wait_activ', locale: _localeName);
|
static String registration() => Intl.message('registration', name: 'registration', locale: Intl.defaultLocale);
|
||||||
String refreshActivationStatus() => Intl.message('update_activ_status', name: 'update_activ_status', locale: _localeName);
|
static String idStore() => Intl.message('ID_Store', name: 'ID_Store', locale: Intl.defaultLocale);
|
||||||
String appActivated() => Intl.message('app_activ', name: 'app_activ', locale: _localeName);
|
static String signUp() => Intl.message('sign_up', name: 'sign_up', locale: Intl.defaultLocale);
|
||||||
String completeRegistration() => Intl.message('complite_activ', name: 'complite_activ', locale: _localeName);
|
static String specifyDinStore() => Intl.message('specify_din_store', name: 'specify_din_store', locale: Intl.defaultLocale);
|
||||||
String cardScanner() => Intl.message('card_scaner', name: 'card_scaner', locale: _localeName);
|
static String confirmation() => Intl.message('confirmation', name: 'confirmation', locale: Intl.defaultLocale);
|
||||||
String userName() => Intl.message('user_name', name: 'user_name', locale: _localeName);
|
static String askChangeStore() => Intl.message('ask_change_store', name: 'ask_change_store', locale: Intl.defaultLocale);
|
||||||
String card() => Intl.message('card', name: 'card', locale: _localeName);
|
static String yes() => Intl.message('yes', name: 'yes', locale: Intl.defaultLocale);
|
||||||
String reward() => Intl.message('reward', name: 'reward', locale: _localeName);
|
static String no() => Intl.message('no', name: 'no', locale: Intl.defaultLocale);
|
||||||
String sum() => Intl.message('sum', name: 'sum', locale: _localeName);
|
static String requestSentWaitActivation() => Intl.message('request_sent_wait_activ', name: 'request_sent_wait_activ', locale: Intl.defaultLocale);
|
||||||
String carryingPurchase() => Intl.message('carry_purchase', name: 'carry_purchase', locale: _localeName);
|
static String refreshActivationStatus() => Intl.message('update_activ_status', name: 'update_activ_status', locale: Intl.defaultLocale);
|
||||||
String completePurchase() => Intl.message('complite_purchase', name: 'complite_purchase', locale: _localeName);
|
static String appActivated() => Intl.message('app_activ', name: 'app_activ', locale: Intl.defaultLocale);
|
||||||
String scan() => Intl.message('scan', name: 'scan', locale: _localeName);
|
static String completeRegistration() => Intl.message('complite_activ', name: 'complite_activ', locale: Intl.defaultLocale);
|
||||||
String buyer() => Intl.message('buyer', name: 'buyer', locale: _localeName);
|
static String cardScanner() => Intl.message('card_scaner', name: 'card_scaner', locale: Intl.defaultLocale);
|
||||||
String confirmPurchase() => Intl.message('confirm_purchase', name: 'confirm_purchase', locale: _localeName);
|
static String userName() => Intl.message('user_name', name: 'user_name', locale: Intl.defaultLocale);
|
||||||
String idNotFound() => Intl.message('ID_not_found', name: 'ID_not_found', locale: _localeName);
|
static String card() => Intl.message('card', name: 'card', locale: Intl.defaultLocale);
|
||||||
|
static String reward() => Intl.message('reward', name: 'reward', locale: Intl.defaultLocale);
|
||||||
|
static String sum() => Intl.message('sum', name: 'sum', locale: Intl.defaultLocale);
|
||||||
|
static String carryingPurchase() => Intl.message('carry_purchase', name: 'carry_purchase', locale: Intl.defaultLocale);
|
||||||
|
static String completePurchase() => Intl.message('complite_purchase', name: 'complite_purchase', locale: Intl.defaultLocale);
|
||||||
|
static String scan() => Intl.message('scan', name: 'scan', locale: Intl.defaultLocale);
|
||||||
|
static String buyer() => Intl.message('buyer', name: 'buyer', locale: Intl.defaultLocale);
|
||||||
|
static String idNotFound() => Intl.message('ID_not_found', name: 'ID_not_found', locale: Intl.defaultLocale);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user