Получение информации о пользователе, разные исправления
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.1">
|
android:versionName="0.0.2">
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
|
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.widget.Button;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
|
import android.hardware.Camera.CameraInfo;
|
||||||
import android.hardware.Camera.PreviewCallback;
|
import android.hardware.Camera.PreviewCallback;
|
||||||
import android.hardware.Camera.AutoFocusCallback;
|
import android.hardware.Camera.AutoFocusCallback;
|
||||||
import android.hardware.Camera.Parameters;
|
import android.hardware.Camera.Parameters;
|
||||||
@@ -39,10 +40,15 @@ import net.sourceforge.zbar.SymbolSet;
|
|||||||
import net.sourceforge.zbar.Config;
|
import net.sourceforge.zbar.Config;
|
||||||
import android.graphics.YuvImage;
|
import android.graphics.YuvImage;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.Display;
|
||||||
|
import android.view.Surface;
|
||||||
|
import android.view.SurfaceHolder;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import com.dinect.checker.R;
|
import com.dinect.checker.R;
|
||||||
|
|
||||||
public class CameraActivity extends AppCompatActivity {
|
public class CameraActivity extends AppCompatActivity implements SurfaceHolder.Callback {
|
||||||
|
|
||||||
private Camera mCamera;
|
private Camera mCamera;
|
||||||
private Handler mAutoFocusHandler = new Handler();
|
private Handler mAutoFocusHandler = new Handler();
|
||||||
@@ -56,6 +62,17 @@ public class CameraActivity extends AppCompatActivity {
|
|||||||
System.loadLibrary("iconv");
|
System.loadLibrary("iconv");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A safe way to get an instance of the Camera object. */
|
||||||
|
private static Camera getCameraInstance(){
|
||||||
|
Camera c = null;
|
||||||
|
try {
|
||||||
|
c = Camera.open();
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.a_scanner);
|
setContentView(R.layout.a_scanner);
|
||||||
@@ -74,34 +91,102 @@ public class CameraActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mCamera = getCameraInstance();
|
mCamera = getCameraInstance();
|
||||||
mCamera.setDisplayOrientation(90);
|
mCamera.setPreviewCallback(previewCallback);
|
||||||
|
|
||||||
holder.addCallback(new SurfaceHolder.Callback() {
|
Camera.Parameters params = mCamera.getParameters();
|
||||||
@Override
|
List<String> focusModes = params.getSupportedFocusModes();
|
||||||
public void surfaceCreated(SurfaceHolder holder) {
|
for (String fMode : focusModes) {
|
||||||
try {
|
Log.d("kifio", fMode);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
mCamera.setPreviewDisplay(holder);
|
holder.addCallback(this);
|
||||||
mCamera.startPreview();
|
|
||||||
mCamera.setPreviewCallback(previewCallback);
|
|
||||||
mCamera.autoFocus(autoFocusCB);
|
|
||||||
initCountours();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
mCamera.startPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
mCamera.stopPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (mCamera != null)
|
||||||
|
mCamera.release();
|
||||||
|
mCamera = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceCreated(SurfaceHolder holder) {
|
||||||
|
try {
|
||||||
|
mCamera.setPreviewDisplay(holder);
|
||||||
|
Log.d("kifio", "surfaceCreated");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||||
|
setCameraDisplayOrientation(0);
|
||||||
|
Log.d("kifio", "surfaceChanged");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
|
Log.d("kifio", "surfaceDestroyed");
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCameraDisplayOrientation(int cameraId) {
|
||||||
|
|
||||||
|
int rotation = getWindowManager().getDefaultDisplay().getRotation();
|
||||||
|
int degrees = 0;
|
||||||
|
switch (rotation) {
|
||||||
|
case Surface.ROTATION_0:
|
||||||
|
degrees = 0;
|
||||||
|
break;
|
||||||
|
case Surface.ROTATION_90:
|
||||||
|
degrees = 90;
|
||||||
|
break;
|
||||||
|
case Surface.ROTATION_180:
|
||||||
|
degrees = 180;
|
||||||
|
break;
|
||||||
|
case Surface.ROTATION_270:
|
||||||
|
degrees = 270;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
// получаем инфо по камере cameraId
|
||||||
|
CameraInfo info = new CameraInfo();
|
||||||
|
Camera.getCameraInfo(cameraId, info);
|
||||||
|
|
||||||
|
// задняя камера
|
||||||
|
if (info.facing == CameraInfo.CAMERA_FACING_BACK) {
|
||||||
|
result = ((360 - degrees) + info.orientation);
|
||||||
|
} else
|
||||||
|
// передняя камера
|
||||||
|
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
|
||||||
|
result = ((360 - degrees) - info.orientation);
|
||||||
|
result += 360;
|
||||||
|
}
|
||||||
|
result = result % 360;
|
||||||
|
mCamera.setDisplayOrientation(result);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu, menu);
|
getMenuInflater().inflate(R.menu.menu, menu);
|
||||||
@@ -124,13 +209,6 @@ public class CameraActivity extends AppCompatActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
mCamera = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void initCountours() {
|
private void initCountours() {
|
||||||
|
|
||||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||||
@@ -143,43 +221,12 @@ public class CameraActivity extends AppCompatActivity {
|
|||||||
mContours.put("width", (int) res.getDimension(R.dimen.scanner_contour_height));
|
mContours.put("width", (int) res.getDimension(R.dimen.scanner_contour_height));
|
||||||
mContours.put("height", width - (2 * (int) res.getDimension(R.dimen.scanner_contour_left)));
|
mContours.put("height", width - (2 * (int) res.getDimension(R.dimen.scanner_contour_left)));
|
||||||
|
|
||||||
Log.d("kifio", "left: " + mContours.get("left"));
|
// Log.d("kifio", "left: " + mContours.get("left"));
|
||||||
Log.d("kifio", "top: " + mContours.get("top"));
|
// Log.d("kifio", "top: " + mContours.get("top"));
|
||||||
Log.d("kifio", "width: " + mContours.get("width"));
|
// Log.d("kifio", "width: " + mContours.get("width"));
|
||||||
Log.d("kifio", "height: " + mContours.get("height"));
|
// Log.d("kifio", "height: " + mContours.get("height"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
releaseCamera();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A safe way to get an instance of the Camera object. */
|
|
||||||
public static Camera getCameraInstance(){
|
|
||||||
Camera c = null;
|
|
||||||
try {
|
|
||||||
c = Camera.open();
|
|
||||||
} catch (Exception e){
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void releaseCamera() {
|
|
||||||
if (mCamera != null) {
|
|
||||||
previewing = false;
|
|
||||||
mCamera.setPreviewCallback(null);
|
|
||||||
mCamera.release();
|
|
||||||
mCamera = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Runnable doAutoFocus = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (previewing)
|
|
||||||
mCamera.autoFocus(autoFocusCB);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PreviewCallback previewCallback = new PreviewCallback() {
|
PreviewCallback previewCallback = new PreviewCallback() {
|
||||||
public void onPreviewFrame(byte[] data, Camera camera) {
|
public void onPreviewFrame(byte[] data, Camera camera) {
|
||||||
|
|
||||||
@@ -204,16 +251,8 @@ public class CameraActivity extends AppCompatActivity {
|
|||||||
intent.putExtra("code", sym.getData());
|
intent.putExtra("code", sym.getData());
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
Toast.makeText(CameraActivity.this, sym.getData(), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mimic continuous auto-focusing
|
|
||||||
AutoFocusCallback autoFocusCB = new AutoFocusCallback() {
|
|
||||||
public void onAutoFocus(boolean success, Camera camera) {
|
|
||||||
mAutoFocusHandler.postDelayed(doAutoFocus, 1000);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<LinearLayout android:orientation="vertical"
|
<!-- <LinearLayout android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="?attr/actionBarSize">
|
android:layout_marginTop="?attr/actionBarSize">
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:background="#с0000000"/>
|
android:background="#с0000000"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout> -->
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
|
|||||||
BIN
assets/expansion_icon.png
Normal file
BIN
assets/expansion_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 173 B |
BIN
assets/powered_by_dinect.png
Normal file
BIN
assets/powered_by_dinect.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/powered_by_dinect_splash.png
Normal file
BIN
assets/powered_by_dinect_splash.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 432 KiB After Width: | Height: | Size: 359 KiB |
@@ -34,8 +34,7 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
|||||||
getHintLabel(),
|
getHintLabel(),
|
||||||
getDecoratedTextWidget(),
|
getDecoratedTextWidget(),
|
||||||
getMessage(),
|
getMessage(),
|
||||||
buildButton(new EdgeInsets.only(top: 36.0, left: buttonVerticalMargin, right: buttonVerticalMargin),
|
buildRaisedButton(context, _tokenActive ? 'ЗАВЕРШИТЬ РЕГИСТРАЦИЮ' : 'ОБНОВИТЬ СТАТУС АКТИВАЦИИ', () => handleTap())
|
||||||
buildRaisedButton(context, _tokenActive ? 'ЗАВЕРШИТЬ РЕГИСТРАЦИЮ' : 'ОБНОВИТЬ СТАТУС АКТИВАЦИИ', () => handleTap()))
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ abstract class BaseState<T> extends State<T> {
|
|||||||
String getHint();
|
String getHint();
|
||||||
|
|
||||||
faq() {
|
faq() {
|
||||||
pushRoute(context, new FAQScreen());
|
var route = new MaterialPageRoute<Null>(builder: (BuildContext context) => new FAQScreen());
|
||||||
|
Navigator.of(context).push(route);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Метод возвращает контейнер с отступами, который содержит картинку с логотипом.
|
/// Метод возвращает контейнер с отступами, который содержит картинку с логотипом.
|
||||||
@@ -101,7 +102,7 @@ abstract class BaseState<T> extends State<T> {
|
|||||||
/// Метод возвращает BoxDecoration для _getDecoratedInputField
|
/// Метод возвращает BoxDecoration для _getDecoratedInputField
|
||||||
getDecoraionForTextWidget() {
|
getDecoraionForTextWidget() {
|
||||||
return new BoxDecoration(color: getTextFilledBackground(),
|
return new BoxDecoration(color: getTextFilledBackground(),
|
||||||
border: new Border.all(color: textBorderColor, width: 1.0,),
|
border: new Border.all(color: textBorderColor, width: 1.0),
|
||||||
borderRadius: new BorderRadius.all(new Radius.circular(4.0)));
|
borderRadius: new BorderRadius.all(new Radius.circular(4.0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
lib/faq.dart
30
lib/faq.dart
@@ -11,21 +11,25 @@ class Entry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class EntryItem extends StatelessWidget {
|
class EntryItem extends StatelessWidget {
|
||||||
const EntryItem(this.entry);
|
|
||||||
|
|
||||||
|
const EntryItem(this.entry);
|
||||||
final Entry entry;
|
final Entry entry;
|
||||||
|
|
||||||
Widget _buildTiles(Entry root) {
|
Widget _buildTiles(BuildContext context, Entry root) {
|
||||||
return new ExpansionTile(
|
EdgeInsets margin = new EdgeInsets.only(left: 20.0, right: 20.0);
|
||||||
|
TextStyle titleStyle = Theme.of(context).textTheme.button.copyWith(fontWeight: FontWeight.bold, color: faqTitlesColor);
|
||||||
|
return new Container(margin: margin, child: new Card(child: new ExpansionTile(
|
||||||
key: new PageStorageKey<Entry>(root),
|
key: new PageStorageKey<Entry>(root),
|
||||||
title: new Text(root.title),
|
title:new Text(root.title, style: titleStyle),
|
||||||
children: [new Text(root.text)]
|
children: [new Container(margin: margin, padding: new EdgeInsets.only(top: 12.0, bottom: 20.0),
|
||||||
);
|
child: new Text(root.text, style: new TextStyle(fontWeight: FontWeight.w300, color: faqGrey, fontSize: 14.0)),
|
||||||
|
decoration: new BoxDecoration(border: new Border(top: new BorderSide(color: greyTextColor, width: 0.5))))]
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return _buildTiles(entry);
|
return _buildTiles(context, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,10 +38,10 @@ class FAQScreen extends StatelessWidget {
|
|||||||
|
|
||||||
AppBar getAppBar(BuildContext context) {
|
AppBar getAppBar(BuildContext context) {
|
||||||
return new AppBar(title: new Text('FAQ', style: new TextStyle(fontSize: 18.0)),
|
return new AppBar(title: new Text('FAQ', style: new TextStyle(fontSize: 18.0)),
|
||||||
backgroundColor: primaryColor, actions: <Widget>[getLogoutButton()]);
|
backgroundColor: primaryColor, actions: <Widget>[getLogoutButton(context)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogoutButton() {
|
getLogoutButton(BuildContext context) {
|
||||||
return new IconButton(icon: new Image.asset(logout_png, height: iconHeight, width: iconHeight), onPressed: () => logout(context));
|
return new IconButton(icon: new Image.asset(logout_png, height: iconHeight, width: iconHeight), onPressed: () => logout(context));
|
||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
@@ -54,10 +58,10 @@ class FAQScreen extends StatelessWidget {
|
|||||||
|
|
||||||
/// Список с контентом
|
/// Список с контентом
|
||||||
final List<Entry> data = <Entry>[
|
final List<Entry> data = <Entry>[
|
||||||
new Entry('Регистрация', registrationGuide),
|
new Entry('РЕГИСТРАЦИЯ', registrationGuide),
|
||||||
new Entry('Использование', usageGuide),
|
new Entry('ИСПОЛЬЗОВАНИЕ', usageGuide),
|
||||||
new Entry('Контакты поддержки', supportGuide),
|
new Entry('КОНТАКТЫ ПОДДЕРЖКИ', supportGuide),
|
||||||
new Entry('Использование', commonGuide)
|
new Entry('ОБЩАЯ ИНФОРМАЦИЯ', commonGuide)
|
||||||
];
|
];
|
||||||
|
|
||||||
/// TODO: Отформатировать строки
|
/// TODO: Отформатировать строки
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ const String splash_png = 'assets/splash.png';
|
|||||||
const String logout_png = 'assets/logout.png';
|
const String logout_png = 'assets/logout.png';
|
||||||
const String activate_token_bg_png = 'assets/activate_token_message_background.png';
|
const String activate_token_bg_png = 'assets/activate_token_message_background.png';
|
||||||
const String active_token_bg_png = 'assets/active_token_message_background.png';
|
const String active_token_bg_png = 'assets/active_token_message_background.png';
|
||||||
|
const String expansion_icon_png = 'assets/expansion_icon.png';
|
||||||
|
const String powered_by_dinect_splash_png = 'assets/powered_by_dinect_splash.png';
|
||||||
|
const String powered_by_dinect_png = 'assets/powered_by_dinect.png';
|
||||||
// Colors
|
// Colors
|
||||||
const Color primaryColor = const Color(0xffeb0004);
|
const Color primaryColor = const Color(0xffeb0004);
|
||||||
const Color greyTextColor = const Color(0xffa5a5a5);
|
const Color greyTextColor = const Color(0xffa5a5a5);
|
||||||
@@ -31,7 +33,8 @@ const Color textBorderColor = const Color(0xffcfd8dc);
|
|||||||
const Color tokenActiveTextColor = const Color(0xff1f5a1f);
|
const Color tokenActiveTextColor = const Color(0xff1f5a1f);
|
||||||
const Color tokenActivateTextColor = const Color(0xff4e3a19);
|
const Color tokenActivateTextColor = const Color(0xff4e3a19);
|
||||||
const Color greenBackground = const Color(0xff8ae28a);
|
const Color greenBackground = const Color(0xff8ae28a);
|
||||||
|
const Color faqGrey = const Color(0xff5b5b5b);
|
||||||
|
const Color faqTitlesColor = const Color(0xff404040);
|
||||||
// Dimens
|
// Dimens
|
||||||
const double verticalMargin = 28.0;
|
const double verticalMargin = 28.0;
|
||||||
const double buttonVerticalMargin = 42.0;
|
const double buttonVerticalMargin = 42.0;
|
||||||
@@ -62,44 +65,68 @@ startScanner(BuildContext context) async {
|
|||||||
|
|
||||||
// Канал ловит вызовы методов из "нативной" части приложения.
|
// Канал ловит вызовы методов из "нативной" части приложения.
|
||||||
// Могут быть вызваны либо logaut либо faq, либо purchase.
|
// Могут быть вызваны либо logaut либо faq, либо purchase.
|
||||||
platform.setMethodCallHandler((MethodCall call) async {
|
if (token != null) {
|
||||||
|
platform.setMethodCallHandler((MethodCall call) async {
|
||||||
|
|
||||||
if (call.method == 'foo') {
|
if (call.method == 'foo') {
|
||||||
logout(context);
|
logout(context);
|
||||||
} else {
|
} else {
|
||||||
pushRoute(context, new PurchaseScreen());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
var card = call.arguments;
|
||||||
|
|
||||||
});
|
print('card: ' + card);
|
||||||
|
String url = 'http://pos-api-int.dinect.com/20130701/users/?auto=${card}';
|
||||||
|
print('url: ' + url);
|
||||||
|
|
||||||
|
var headers = {
|
||||||
|
'DM-Authorization': 'dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08',
|
||||||
|
'Authorization': 'dmtoken ${token}'
|
||||||
|
};
|
||||||
|
|
||||||
|
httpClient.get(url, headers: headers).then((response) {
|
||||||
|
|
||||||
|
print(response.body);
|
||||||
|
|
||||||
|
List usersList = JSON.decode(response.body);
|
||||||
|
|
||||||
|
if (usersList.length > 0) {
|
||||||
|
pushRoute(context, new PurchaseScreen(usersList[0], card));
|
||||||
|
}
|
||||||
|
|
||||||
|
}).catchError((error) {
|
||||||
|
print(error.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
await platform.invokeMethod('startScanner');
|
await platform.invokeMethod('startScanner');
|
||||||
}
|
}
|
||||||
|
|
||||||
logout(BuildContext context) {
|
logout(BuildContext context) {
|
||||||
|
if (token != null) {
|
||||||
String url = intUrl + 'tokens/' + token + '?_dmapptoken=' + intToken;
|
String url = intUrl + 'tokens/' + token + '?_dmapptoken=' + intToken;
|
||||||
print(url);
|
print(url);
|
||||||
httpClient.delete(url).then((response) {
|
httpClient.delete(url).then((response) {
|
||||||
print(response.body);
|
print(response.body);
|
||||||
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
||||||
platform.invokeMethod('removeKeys');
|
platform.invokeMethod('removeKeys');
|
||||||
pushRoute(context, new RegistrationScreen());
|
Navigator.of(context).pop();
|
||||||
}).catchError((error) {
|
pushRoute(context, new RegistrationScreen());
|
||||||
print(error.toString());
|
}).catchError((error) {
|
||||||
});
|
print(error.toString());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Навигация по приложению.
|
/// Навигация по приложению.
|
||||||
/// widget - следующий экран приложения.
|
/// widget - следующий экран приложения.
|
||||||
pushRoute(BuildContext context, Widget widget) {
|
pushRoute(BuildContext context, Widget widget) {
|
||||||
Navigator.of(context).pushReplacement(new MaterialPageRoute<Null>(
|
var route = new MaterialPageRoute<Null>(builder: (BuildContext context) => widget);
|
||||||
builder: (BuildContext context) {
|
Navigator.of(context).pushReplacement(route);
|
||||||
return widget;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Checker extends StatelessWidget {
|
class Checker extends StatelessWidget {
|
||||||
@@ -112,3 +139,5 @@ class Checker extends StatelessWidget {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,41 @@ import 'purchase_success.dart';
|
|||||||
|
|
||||||
/// Экран проведения покупки.
|
/// Экран проведения покупки.
|
||||||
class PurchaseScreen extends StatefulWidget {
|
class PurchaseScreen extends StatefulWidget {
|
||||||
@override State createState() => new PurchaseScreenState<PurchaseScreen>();
|
|
||||||
|
PurchaseScreen(this.response, this.card);
|
||||||
|
|
||||||
|
Map response;
|
||||||
|
String card;
|
||||||
|
|
||||||
|
@override State createState() => new PurchaseScreenState<PurchaseScreen>(response, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PurchaseScreenState<T> extends BaseState<T> {
|
class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||||
|
|
||||||
|
PurchaseScreenState(Map user, String card) {
|
||||||
|
this.user = user;
|
||||||
|
this.card = card;
|
||||||
|
getLoyality(user['loyalty_url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map user;
|
||||||
|
String card;
|
||||||
String integerPart = '', fractionalPart = '';
|
String integerPart = '', fractionalPart = '';
|
||||||
|
String loyality = '';
|
||||||
|
|
||||||
|
@override Widget getScreenContent() {
|
||||||
|
return new Container(height: 412.0,
|
||||||
|
child: new ListView(reverse: true, children: <Widget>[
|
||||||
|
new Column(children: <Widget>[
|
||||||
|
getValueWithTitle('ФИО', user['first_name']),
|
||||||
|
getValueWithTitle('Карта', card),
|
||||||
|
getValueWithTitle('Вознаграждение', loyality),
|
||||||
|
getHintLabel(),
|
||||||
|
getDecoratedTextWidget(),
|
||||||
|
buildButton(new EdgeInsets.only(top: 36.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildRaisedButton(context, 'ЗАВЕРШИТЬ ПОКУПКУ', () => _purchase(context))),
|
||||||
|
buildButton(new EdgeInsets.only(top: 24.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildFlatButton(context, 'СКАНИРОВАТЬ', primaryColor))])
|
||||||
|
].reversed.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
@override String getTitle() {
|
@override String getTitle() {
|
||||||
return "Проведение покупки";
|
return "Проведение покупки";
|
||||||
@@ -25,24 +54,7 @@ class PurchaseScreenState<T> extends BaseState<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@overide getMenuButtons(BuildContext context) {
|
@overide getMenuButtons(BuildContext context) {
|
||||||
return <Widget>[
|
return <Widget>[getFaqButton(), getLogoutButton()];
|
||||||
new getFaqButton(),
|
|
||||||
new getLogoutButton()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
@override Widget getScreenContent() {
|
|
||||||
return new Container(height: 412.0,
|
|
||||||
child: new ListView(reverse: true, children: <Widget>[
|
|
||||||
new Column(children: <Widget>[
|
|
||||||
getValueWithTitle('ФИО', 'Знаменитый Рокер Паук'),
|
|
||||||
getValueWithTitle('Карта', 'B0399900702'),
|
|
||||||
getValueWithTitle('Вознаграждение', '100%'),
|
|
||||||
getHintLabel(),
|
|
||||||
getDecoratedTextWidget(),
|
|
||||||
buildButton(new EdgeInsets.only(top: 36.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildRaisedButton(context, 'ЗАВЕРШИТЬ ПОКУПКУ', () => _purchase(context))),
|
|
||||||
buildButton(new EdgeInsets.only(top: 24.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildFlatButton(context, 'СКАНИРОВАТЬ', primaryColor))])
|
|
||||||
].reversed.toList()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override Color getTextFilledBackground() {
|
@override Color getTextFilledBackground() {
|
||||||
@@ -71,6 +83,35 @@ class PurchaseScreenState<T> extends BaseState<T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLoyality(String url) {
|
||||||
|
|
||||||
|
var headers = {
|
||||||
|
'DM-Authorization': 'dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08',
|
||||||
|
'Authorization': 'dmtoken ${token}'
|
||||||
|
};
|
||||||
|
|
||||||
|
httpClient.get(url, headers: headers).then((response) {
|
||||||
|
|
||||||
|
print(response.body);
|
||||||
|
|
||||||
|
Map bonuses = JSON.decode(response.body);
|
||||||
|
String type = bonuses['type'];
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
if (type == 'amount') {
|
||||||
|
this.loyality = user['discount'];
|
||||||
|
} else {
|
||||||
|
List bonusToAmount = bonuses['bonus_to_amount'];
|
||||||
|
this.loyality = (bonusToAmount[1].toInt() / bonusToAmount[0].toInt() ).toString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}).catchError((error) {
|
||||||
|
print(error.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
_buildSum() {
|
_buildSum() {
|
||||||
String temporaryInteger = integerPart;
|
String temporaryInteger = integerPart;
|
||||||
String temporaryFractional = fractionalPart;
|
String temporaryFractional = fractionalPart;
|
||||||
@@ -84,6 +125,7 @@ class PurchaseScreenState<T> extends BaseState<T> {
|
|||||||
|
|
||||||
_purchase(BuildContext context) {
|
_purchase(BuildContext context) {
|
||||||
String val = _buildSum();
|
String val = _buildSum();
|
||||||
|
print(val);
|
||||||
showDialog(context: context, child: new AlertDialog(
|
showDialog(context: context, child: new AlertDialog(
|
||||||
title: new Text('Подтверждение'),
|
title: new Text('Подтверждение'),
|
||||||
content: new Text('Вы подтверждаете покупку на ${val} руб?'),
|
content: new Text('Вы подтверждаете покупку на ${val} руб?'),
|
||||||
@@ -97,7 +139,8 @@ class PurchaseScreenState<T> extends BaseState<T> {
|
|||||||
new FlatButton(
|
new FlatButton(
|
||||||
child: new Text('Да'),
|
child: new Text('Да'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
pushRoute(context, new PurchaseSuccessScreen(val));
|
Navigator.of(context).pop();
|
||||||
|
pushRoute(context, new PurchaseSuccessScreen(val, user['first_name']));
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
]));
|
]));
|
||||||
|
|||||||
@@ -8,21 +8,22 @@ import 'purchase.dart';
|
|||||||
/// Экран проведения покупки.
|
/// Экран проведения покупки.
|
||||||
class PurchaseSuccessScreen extends StatefulWidget {
|
class PurchaseSuccessScreen extends StatefulWidget {
|
||||||
|
|
||||||
String val = '';
|
PurchaseSuccessScreen(this.val, this.name);
|
||||||
|
String val;
|
||||||
|
String name;
|
||||||
|
|
||||||
PurchaseSuccessScreen(String val) {
|
@override State createState() => new PurchaseSuccessScreenState(val, name);
|
||||||
this.val = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override State createState() => new PurchaseSuccessScreenState(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PurchaseSuccessScreenState<T> extends PurchaseScreenState<T> {
|
class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||||
|
|
||||||
String val = '';
|
PurchaseSuccessScreenState(this.sum, this.username);
|
||||||
|
|
||||||
PurchaseSuccessScreenState(String val) {
|
String sum;
|
||||||
this.val = val;
|
String username;
|
||||||
|
|
||||||
|
@overide getMenuButtons(BuildContext context) {
|
||||||
|
return <Widget>[getFaqButton(), getLogoutButton()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override String getTitle() {
|
@override String getTitle() {
|
||||||
@@ -31,7 +32,7 @@ class PurchaseSuccessScreenState<T> extends PurchaseScreenState<T> {
|
|||||||
|
|
||||||
@override Widget getScreenContent() {
|
@override Widget getScreenContent() {
|
||||||
return new Column(children: <Widget>[
|
return new Column(children: <Widget>[
|
||||||
getValueWithTitle('Покупатель', 'Знаменитый Рокер Паук'),
|
getValueWithTitle('Покупатель', username),
|
||||||
getSuccessMessage(),
|
getSuccessMessage(),
|
||||||
new Expanded(child: new Center()),
|
new Expanded(child: new Center()),
|
||||||
buildButton(new EdgeInsets.only(bottom: 74.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildRaisedButton(context, 'СКАНИРОВАТЬ', () => startScanner(context)))
|
buildButton(new EdgeInsets.only(bottom: 74.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildRaisedButton(context, 'СКАНИРОВАТЬ', () => startScanner(context)))
|
||||||
@@ -41,7 +42,7 @@ class PurchaseSuccessScreenState<T> extends PurchaseScreenState<T> {
|
|||||||
getSuccessMessage() {
|
getSuccessMessage() {
|
||||||
return new Row(children: <Widget>[new Expanded(child: new Container(margin: new EdgeInsets.only(top: 20.0), height: 64.0,
|
return new Row(children: <Widget>[new Expanded(child: new Container(margin: new EdgeInsets.only(top: 20.0), height: 64.0,
|
||||||
decoration: new BoxDecoration(color: greenBackground),
|
decoration: new BoxDecoration(color: greenBackground),
|
||||||
child: new Center(child: new Text('Покупка на сумму ${val} руб. проведена', textAlign: TextAlign.center,
|
child: new Center(child: new Text('Покупка на сумму ${sum} руб. проведена', textAlign: TextAlign.center,
|
||||||
style: new TextStyle(fontWeight: FontWeight.bold, color: tokenActiveTextColor)))))]);
|
style: new TextStyle(fontWeight: FontWeight.bold, color: tokenActiveTextColor)))))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
|||||||
getLogo(),
|
getLogo(),
|
||||||
getHintLabel(),
|
getHintLabel(),
|
||||||
getDecoratedTextWidget(),
|
getDecoratedTextWidget(),
|
||||||
buildButton(new EdgeInsets.only(top: 36.0, left: buttonVerticalMargin, right: buttonVerticalMargin),
|
new Container(margin: new EdgeInsets.only(top: 36.0), child: buildRaisedButton(context, 'ЗАРЕГИСТРИРОВАТЬ', _isValidMerchantID() && !loading ? () => _registerShop(context) : null))]))
|
||||||
buildRaisedButton(context, 'ЗАРЕГИСТРИРОВАТЬ', _isValidMerchantID() && !loading ? () => _registerShop(context) : null))]))
|
|
||||||
].reversed.toList()));
|
].reversed.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,18 @@ 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 Image.asset(splash_png, fit: BoxFit.cover);
|
return new Stack(children: <Widget>[new Container(padding: new EdgeInsets.only(left: 48.0, right: 48.0), decoration: getSplashBg()),
|
||||||
|
new Align(alignment: FractionalOffset.bottomRight, child:
|
||||||
|
new Container(margin: new EdgeInsets.only(right: 11.0, bottom: 5.0), child: new Image.asset(powered_by_dinect_splash_png, height: 16.0, width: 122.0)))]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Decoration getSplashBg() {
|
||||||
|
return new BoxDecoration(image: new DecorationImage(
|
||||||
|
image: new ExactAssetImage(splash_png), fit: BoxFit.cover));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Запуск следующего экрана приложения.
|
/// Запуск следующего экрана приложения.
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ flutter:
|
|||||||
- assets/logout.png
|
- assets/logout.png
|
||||||
- assets/activate_token_message_background.png
|
- assets/activate_token_message_background.png
|
||||||
- assets/active_token_message_background.png
|
- assets/active_token_message_background.png
|
||||||
|
- assets/expansion_icon.png
|
||||||
|
- assets/powered_by_dinect_splash.png
|
||||||
|
- assets/powered_by_dinect.png
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# To add assets from package dependencies, first ensure the asset
|
# To add assets from package dependencies, first ensure the asset
|
||||||
# is in the lib/ directory of the dependency. Then,
|
# is in the lib/ directory of the dependency. Then,
|
||||||
|
|||||||
Reference in New Issue
Block a user