Поправил много неприятных косяков
This commit is contained in:
@@ -1,7 +1,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.0.3">
|
android:versionName="0.0.4">
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
|
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,11 @@ import okhttp3.OkHttpClient;
|
|||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.json.*;
|
import org.json.*;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.DialogFragment;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.AlertDialog.Builder;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import com.dinect.checker.R;
|
import com.dinect.checker.R;
|
||||||
|
|
||||||
public class CameraActivity extends AppCompatActivity implements SurfaceHolder.Callback {
|
public class CameraActivity extends AppCompatActivity implements SurfaceHolder.Callback {
|
||||||
@@ -70,7 +74,7 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
|||||||
private boolean previewing = true;
|
private boolean previewing = true;
|
||||||
private Handler autoFocusHandler;
|
private Handler autoFocusHandler;
|
||||||
private int mOffset;
|
private int mOffset;
|
||||||
private String mToken = "19305da6610a74504f8a462411199b5de0c93979";
|
private String mToken;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("iconv");
|
System.loadLibrary("iconv");
|
||||||
@@ -108,19 +112,17 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
|||||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mToken = getIntent().getStringExtra(MainActivity.PREF_POS_TOKEN);
|
||||||
|
|
||||||
|
if (mToken == null) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra("item", "logout");
|
||||||
|
setResult(RESULT_OK, intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
mCamera = getCameraInstance();
|
mCamera = getCameraInstance();
|
||||||
mCamera.setPreviewCallback(previewCallback);
|
mCamera.setPreviewCallback(previewCallback);
|
||||||
|
|
||||||
Camera.Parameters params = mCamera.getParameters();
|
|
||||||
List<String> focusModes = params.getSupportedFocusModes();
|
|
||||||
|
|
||||||
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
|
|
||||||
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
|
||||||
} else if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
|
||||||
params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
|
|
||||||
}
|
|
||||||
mCamera.setParameters(params);
|
|
||||||
|
|
||||||
holder.addCallback(this);
|
holder.addCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,13 +223,13 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
Intent intent = new Intent();
|
|
||||||
if (item.getItemId() == R.id.logout) {
|
if (item.getItemId() == R.id.logout) {
|
||||||
intent.putExtra("item", "logout");
|
LogoutDialogFragment newFragment = new LogoutDialogFragment();
|
||||||
setResult(RESULT_OK, intent);
|
newFragment.show(getFragmentManager(), "logout");
|
||||||
finish();
|
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.faq) {
|
} else if (item.getItemId() == R.id.faq) {
|
||||||
|
Intent intent = new Intent();
|
||||||
intent.putExtra("item", "faq");
|
intent.putExtra("item", "faq");
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
@@ -287,9 +289,10 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
|||||||
}
|
}
|
||||||
if (response.code() == 200) {
|
if (response.code() == 200) {
|
||||||
try {
|
try {
|
||||||
JSONArray users = new JSONArray(response.body().string());
|
String s = response.body().string();
|
||||||
|
JSONArray users = new JSONArray(s);
|
||||||
|
Log.d("kifio", s);
|
||||||
if (users.length() > 0) {
|
if (users.length() > 0) {
|
||||||
Toast.makeText(this, "Чики-брики и в дамки", Toast.LENGTH_SHORT).show();
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra("user", users.get(0).toString());
|
intent.putExtra("user", users.get(0).toString());
|
||||||
intent.putExtra("card", card);
|
intent.putExtra("card", card);
|
||||||
@@ -357,6 +360,9 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
|
Log.d("kifio", mUrl);
|
||||||
|
Log.d("kifio", mToken);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.addHeader("DM-Authorization", "dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08")
|
.addHeader("DM-Authorization", "dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08")
|
||||||
.addHeader("Authorization", "dmtoken " + mToken)
|
.addHeader("Authorization", "dmtoken " + mToken)
|
||||||
@@ -380,4 +386,30 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
|||||||
mActivity = null;
|
mActivity = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class LogoutDialogFragment extends DialogFragment {
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
// Use the Builder class for convenient dialog construction
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setTitle("Подтверждение");
|
||||||
|
builder.setMessage("Вы действительно хотите выйти и ввести другой номер магазина?")
|
||||||
|
.setPositiveButton("Да", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.dismiss();
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra("item", "logout");
|
||||||
|
getActivity().setResult(RESULT_OK, intent);
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton("Нет", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Create the AlertDialog object and return it
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,10 +21,10 @@ import java.lang.System;
|
|||||||
public class MainActivity extends FlutterActivity {
|
public class MainActivity extends FlutterActivity {
|
||||||
|
|
||||||
private static final int START_SCANNER_REQUEST_CODE = 2017;
|
private static final int START_SCANNER_REQUEST_CODE = 2017;
|
||||||
private static final String PREF_POS_TOKEN = "pref_pos_token";
|
|
||||||
private static final String PREF_POS_MERCHANT_ID = "pref_pos_merchant_id";
|
private static final String PREF_POS_MERCHANT_ID = "pref_pos_merchant_id";
|
||||||
private static final String PREF_DOC_ID = "pref_doc_id";
|
private static final String PREF_DOC_ID = "pref_doc_id";
|
||||||
private static final String PREF_POS_ID = "pref_pos_id";
|
private static final String PREF_POS_ID = "pref_pos_id";
|
||||||
|
static final String PREF_POS_TOKEN = "pref_pos_token";
|
||||||
|
|
||||||
private MethodChannel mChannel;
|
private MethodChannel mChannel;
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
@@ -67,7 +67,9 @@ public class MainActivity extends FlutterActivity {
|
|||||||
result.success(mPreferences.getString(PREF_POS_MERCHANT_ID, null));
|
result.success(mPreferences.getString(PREF_POS_MERCHANT_ID, null));
|
||||||
break;
|
break;
|
||||||
case "startScanner":
|
case "startScanner":
|
||||||
|
Map arguments = call.arguments();
|
||||||
Intent cameraIntent = new Intent(MainActivity.this, CameraActivity.class);
|
Intent cameraIntent = new Intent(MainActivity.this, CameraActivity.class);
|
||||||
|
cameraIntent.putExtra(PREF_POS_TOKEN, (String) arguments.get("token"));
|
||||||
startActivityForResult(cameraIntent, START_SCANNER_REQUEST_CODE);
|
startActivityForResult(cameraIntent, START_SCANNER_REQUEST_CODE);
|
||||||
break;
|
break;
|
||||||
case "removeKeys":
|
case "removeKeys":
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ abstract class BaseState<T> extends State<T> {
|
|||||||
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(getHintText(), overflow: TextOverflow.ellipsis, textAlign: TextAlign.left,
|
children: <Widget>[new Text(getHintText(), 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))]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,6 @@ abstract class BaseState<T> extends State<T> {
|
|||||||
onChanged: (text) => handleUserInput(text));
|
onChanged: (text) => handleUserInput(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Индикация ...
|
|
||||||
Widget getProgressIndicator() {
|
Widget getProgressIndicator() {
|
||||||
return new Center(child: loading ? new CircularProgressIndicator() : null);
|
return new Center(child: loading ? new CircularProgressIndicator() : null);
|
||||||
}
|
}
|
||||||
@@ -121,7 +120,7 @@ abstract class BaseState<T> extends State<T> {
|
|||||||
return new Container(padding: new EdgeInsets.only(left: verticalMargin, right: verticalMargin, top: 18.0),
|
return new Container(padding: new EdgeInsets.only(left: verticalMargin, right: verticalMargin, top: 18.0),
|
||||||
child: new Column(children: <Widget>[
|
child: new Column(children: <Widget>[
|
||||||
new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[new Text(title, textAlign: TextAlign.left, style: new TextStyle(color: greyTextColor, fontSize: 14.0))]),
|
new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[new Text(title, textAlign: TextAlign.left, style: new TextStyle(color: greyTextColor, fontSize: 14.0))]),
|
||||||
new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[new Text(value, textAlign: TextAlign.left, style: new TextStyle(color: Colors.black, fontSize: 20.0))])
|
new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[new Expanded(child: new Text(value, textAlign: TextAlign.left, style: new TextStyle(color: Colors.black, fontSize: 20.0)))])
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,11 @@ logout(BuildContext context) {
|
|||||||
if (token != null) {
|
if (token != null) {
|
||||||
deleteToken(token).then((response) {
|
deleteToken(token).then((response) {
|
||||||
print(response.body);
|
print(response.body);
|
||||||
platform.invokeMethod('removeKeys');
|
platform.invokeMethod('removeKeys').then((result) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.of(context).pop();
|
||||||
pushRoute(context, new RegistrationScreen()); // Запускаем регистрацию
|
pushRoute(context, new RegistrationScreen()); // Запускаем регистрацию
|
||||||
|
});
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
print(error.toString());
|
print(error.toString());
|
||||||
});
|
});
|
||||||
@@ -45,6 +48,19 @@ logout(BuildContext context) {
|
|||||||
showYesNoDialog(context, 'Подтверждение', 'Вы действительно хотите выйти и ввести другой номер магазина?', positiveCalback);
|
showYesNoDialog(context, 'Подтверждение', 'Вы действительно хотите выйти и ввести другой номер магазина?', positiveCalback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
forceLogout(BuildContext context) {
|
||||||
|
|
||||||
|
deleteToken(token).then((response) {
|
||||||
|
print(response.body);
|
||||||
|
platform.invokeMethod('removeKeys').then((result) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
pushRoute(context, new RegistrationScreen()); // Запускаем регистрацию
|
||||||
|
});
|
||||||
|
}).catchError((error) {
|
||||||
|
print(error.toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Запуск спецефичной для каждой платформы части приложения - сканера.
|
/// Запуск спецефичной для каждой платформы части приложения - сканера.
|
||||||
/// Может производиться с нескольких экранов (splash, finish_registration).
|
/// Может производиться с нескольких экранов (splash, finish_registration).
|
||||||
startScanner(BuildContext context) async {
|
startScanner(BuildContext context) async {
|
||||||
@@ -56,7 +72,7 @@ startScanner(BuildContext context) async {
|
|||||||
|
|
||||||
print('call.method: ${call.method}');
|
print('call.method: ${call.method}');
|
||||||
if (call.method == 'logout') {
|
if (call.method == 'logout') {
|
||||||
logout(context);
|
forceLogout(context);
|
||||||
} else if (call.method == 'faq') {
|
} else if (call.method == 'faq') {
|
||||||
faq(context, true);
|
faq(context, true);
|
||||||
} else {
|
} else {
|
||||||
@@ -68,9 +84,8 @@ startScanner(BuildContext context) async {
|
|||||||
Navigator.of(context).pushReplacement(route);
|
Navigator.of(context).pushReplacement(route);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
await platform.invokeMethod('startScanner', {'token' : token});
|
||||||
}
|
}
|
||||||
|
|
||||||
await platform.invokeMethod('startScanner');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Запуск диалога с двумя кнопками
|
// Запуск диалога с двумя кнопками
|
||||||
|
|||||||
@@ -33,7 +33,3 @@ deleteToken(String token) async {
|
|||||||
print(url);
|
print(url);
|
||||||
return httpClient.delete(url);
|
return httpClient.delete(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Удалить токены
|
|
||||||
// 57e0d09aa935252d2a3463ebc1d61501608a6af9
|
|
||||||
// f1355ea87375c173695b57afa72f78fedbe5b6c3
|
|
||||||
@@ -35,17 +35,16 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
String loyality = '';
|
String loyality = '';
|
||||||
|
|
||||||
@override Widget getScreenContent() {
|
@override Widget getScreenContent() {
|
||||||
return new Container(height: 412.0,
|
return new Column(
|
||||||
child: new ListView(reverse: true, children: <Widget>[
|
children: <Widget>[new Expanded(child: new ListView(children: <Widget>[
|
||||||
new Column(children: <Widget>[
|
getValueWithTitle('ФИО', user['first_name'] == null ? '' : user['first_name']),
|
||||||
getValueWithTitle('ФИО', user['first_name']),
|
|
||||||
getValueWithTitle('Карта', card),
|
getValueWithTitle('Карта', card),
|
||||||
getValueWithTitle('Вознаграждение', loyality),
|
getValueWithTitle('Вознаграждение', loyality),
|
||||||
getHintLabel(),
|
getHintLabel(),
|
||||||
getDecoratedTextWidget(),
|
getDecoratedTextWidget(),
|
||||||
buildButton(new EdgeInsets.only(top: 36.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildRaisedButton(context, 'ЗАВЕРШИТЬ ПОКУПКУ', () => onPurchaseClick(context))),
|
buildButton(new EdgeInsets.only(top: 36.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildRaisedButton(context, 'ЗАВЕРШИТЬ ПОКУПКУ', () => onPurchaseClick(context))),
|
||||||
buildButton(new EdgeInsets.only(top: 24.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildFlatButton(context, 'СКАНИРОВАТЬ', primaryColor))])
|
buildButton(new EdgeInsets.only(top: 24.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildFlatButton(context, 'СКАНИРОВАТЬ', primaryColor))
|
||||||
].reversed.toList()));
|
]))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override String getTitle() {
|
@override String getTitle() {
|
||||||
@@ -68,7 +67,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
@override handleUserInput(String tmpString) {
|
@override handleUserInput(String tmpString) {
|
||||||
setState(() {
|
setState(() {
|
||||||
tmpString = tmpString.replaceAll('-', '');
|
tmpString = tmpString.replaceAll('-', '');
|
||||||
tmpString = tmpString.replaceAll(', ', '');
|
tmpString = tmpString.replaceAll(',', '');
|
||||||
print(tmpString);
|
print(tmpString);
|
||||||
if (tmpString.contains('.')) {
|
if (tmpString.contains('.')) {
|
||||||
int dotIndex = tmpString.indexOf('.');
|
int dotIndex = tmpString.indexOf('.');
|
||||||
@@ -88,6 +87,9 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
|
|
||||||
getLoyality(String url) {
|
getLoyality(String url) {
|
||||||
|
|
||||||
|
print(url);
|
||||||
|
print(token);
|
||||||
|
|
||||||
var headers = {
|
var headers = {
|
||||||
'DM-Authorization': 'dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08',
|
'DM-Authorization': 'dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08',
|
||||||
'Authorization': 'dmtoken ${token}'
|
'Authorization': 'dmtoken ${token}'
|
||||||
@@ -102,11 +104,15 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
if (type == 'amount') {
|
if (type == 'amount') {
|
||||||
this.loyality = user['discount'];
|
this.loyality = '${user['discount']}%';
|
||||||
} else {
|
} else {
|
||||||
List bonusToAmount = bonuses['bonus_to_amount'];
|
List amountToBonus = bonuses['amount_to_bonus'];
|
||||||
this.loyality = (bonusToAmount[1].toInt() / bonusToAmount[0].toInt() ).toString();
|
// print(amountToBonus[0]);
|
||||||
|
// print(amountToBonus[1]);
|
||||||
|
this.loyality = '${(amountToBonus[0] / double.parse(amountToBonus[1])).toStringAsFixed(0)}%';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
@@ -170,7 +176,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
|||||||
|
|
||||||
print(response.body);
|
print(response.body);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
pushRoute(context, new PurchaseSuccessScreen(sum_total, user['first_name']));
|
pushRoute(context, new PurchaseSuccessScreen(sum_total, user['first_name'] == null ? '' : user['first_name']));
|
||||||
|
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
print(error.toString());
|
print(error.toString());
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
|||||||
/// Высота контейнера задана для того, чтобы элементы располагались вверху экрана
|
/// Высота контейнера задана для того, чтобы элементы располагались вверху экрана
|
||||||
/// и список скроллился снизу вверх при открытии клавиатуры.
|
/// и список скроллился снизу вверх при открытии клавиатуры.
|
||||||
@override Widget getScreenContent() {
|
@override Widget getScreenContent() {
|
||||||
return new Container(height: 332.0,
|
return new Container(
|
||||||
child: new ListView(reverse: true, children: <Widget>[
|
child: new ListView(children: <Widget>[
|
||||||
new Center(child: new Column(children: <Widget>[
|
new Center(child: new Column(children: <Widget>[
|
||||||
getLogo(),
|
getLogo(),
|
||||||
getHintLabel(),
|
getHintLabel(),
|
||||||
getDecoratedTextWidget(),
|
getDecoratedTextWidget(),
|
||||||
new Container(margin: new EdgeInsets.only(top: 36.0), child: buildRaisedButton(context, 'ЗАРЕГИСТРИРОВАТЬ', _isValidMerchantID() && !loading ? () => _registerShop(context) : null))]))
|
new Container(margin: new EdgeInsets.only(top: 36.0), child: buildRaisedButton(context, 'ЗАРЕГИСТРИРОВАТЬ', _isValidMerchantID() && !loading ? () => _registerShop(context) : null))]))
|
||||||
].reversed.toList()));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Токен кассы - это DIN код. DIN код - это специальный код динекта, максимальная его длина - 25 символов.
|
/// Токен кассы - это DIN код. DIN код - это специальный код динекта, максимальная его длина - 25 символов.
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ class SplashScreen extends StatelessWidget {
|
|||||||
// Появляется splash screen, проверяется токен.
|
// Появляется splash screen, проверяется токен.
|
||||||
new Future.delayed(const Duration(milliseconds: 500), () {
|
new Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
showNextScreen(context);
|
showNextScreen(context);
|
||||||
// startScanner(context);
|
|
||||||
// pushRoute(context, new PurchaseScreen(null));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Stack(children: <Widget>[getBackgroundContainer(),
|
return new Stack(children: <Widget>[getBackgroundContainer(),
|
||||||
@@ -45,7 +43,6 @@ class SplashScreen extends StatelessWidget {
|
|||||||
if (token == null) {
|
if (token == null) {
|
||||||
pushRoute(context, new RegistrationScreen());
|
pushRoute(context, new RegistrationScreen());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
checkTokenStatus(token).then((statusResponse) {
|
checkTokenStatus(token).then((statusResponse) {
|
||||||
handleStatusResponse(context, statusResponse);
|
handleStatusResponse(context, statusResponse);
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
@@ -80,21 +77,21 @@ class SplashScreen extends StatelessWidget {
|
|||||||
|
|
||||||
if (response.statusCode == 409) {
|
if (response.statusCode == 409) {
|
||||||
pushRoute(context, new FinishRegistrationScreen());
|
pushRoute(context, new FinishRegistrationScreen());
|
||||||
} else {
|
} else if (response.statusCode == 201) {
|
||||||
deleteToken(token).then((response) {
|
platform.invokeMethod('removeKeys').then((result) {
|
||||||
|
Map parsedMap = JSON.decode(result);
|
||||||
|
String t = parsedMap['token'];
|
||||||
|
deleteToken(t).then((response) {
|
||||||
print(response.body);
|
print(response.body);
|
||||||
platform.invokeMethod('removeKeys');
|
|
||||||
Navigator.of(context).pop(); // Убираем текущий route
|
Navigator.of(context).pop(); // Убираем текущий route
|
||||||
pushRoute(context, new RegistrationScreen()); // Запускаем регистрацию
|
pushRoute(context, new RegistrationScreen()); // Запускаем регистрацию
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
print(error.toString());
|
print(error.toString());
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
}).catchError((error) {
|
|
||||||
platform.invokeMethod('removeKeys').then((result) => pushRoute(context, new RegistrationScreen()));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}).catchError((error) => print(error.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user