Android analytics done, camera instructions added.
This commit is contained in:
@@ -3,7 +3,6 @@ import 'dart:async';
|
||||
import 'package:checker/screens/faq.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import 'db.dart';
|
||||
import 'strings.dart';
|
||||
@@ -51,8 +50,3 @@ getLocaleTitle(String code) {
|
||||
return 'Español';
|
||||
}
|
||||
}
|
||||
|
||||
// Добавил вызов, что-бы AOT компилер не выкинул либу.
|
||||
getImage() async {
|
||||
return await ImagePicker.pickImage();
|
||||
}
|
||||
|
||||
13
lib/db.dart
13
lib/db.dart
@@ -37,14 +37,14 @@ class SqliteHelper {
|
||||
db = await openDatabase(path, version: 1,
|
||||
onCreate: (Database db, int version) async {
|
||||
|
||||
await db.execute('''create table $tableSession (
|
||||
await db.execute('''create table $tableSession (
|
||||
$columnMerchantID text primary key,
|
||||
$columnToken text,
|
||||
$columnToken text,
|
||||
$columnPosID text,
|
||||
$columnDocID integer)''');
|
||||
|
||||
await db.execute('''create table $tableSettings (
|
||||
$columnCurrency integer,
|
||||
await db.execute('''create table $tableSettings (
|
||||
$columnCurrency integer,
|
||||
$columnLocale text)''');
|
||||
});
|
||||
}
|
||||
@@ -52,14 +52,12 @@ class SqliteHelper {
|
||||
/// Создается запись в таблице, содержащая
|
||||
/// необходимые для идентификации пользователя и проведения запросов.
|
||||
Future createSession(String merchantID, String posID, String token) async {
|
||||
|
||||
Map session = {
|
||||
columnMerchantID: merchantID,
|
||||
columnPosID: posID,
|
||||
columnToken: token,
|
||||
columnDocID: 0
|
||||
};
|
||||
|
||||
return db.insert(tableSession, session);
|
||||
}
|
||||
|
||||
@@ -109,7 +107,8 @@ class SqliteHelper {
|
||||
|
||||
Future<String> getPosID() async {
|
||||
Map session = await selectAll(tableSession);
|
||||
return session != null ? session[columnPosID] : new DateTime.now().millisecondsSinceEpoch.toString();
|
||||
String time = new DateTime.now().millisecondsSinceEpoch.toString();
|
||||
return session != null ? session[columnPosID] : time;
|
||||
}
|
||||
|
||||
Future<int> getDocID() async {
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
import 'dart:core';
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:checker/screens/splash.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
||||
import 'package:checker/common.dart';
|
||||
|
||||
main() {
|
||||
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
platform.invokeMethod('getAppTitle').then((title) {
|
||||
|
||||
String app = flavor; // dinect, autobonus
|
||||
String appName= title; // Dinect, Dinect (INT), Autobonus
|
||||
|
||||
String app = flavor; // dinect, autobonus
|
||||
String appName = title; // Dinect, Dinect (INT), Autobonus
|
||||
SqliteHelper helper = new SqliteHelper();
|
||||
|
||||
helper.open().then((_) {
|
||||
helper.getLocale().then((locale) {
|
||||
if (locale == null) {
|
||||
@@ -23,13 +18,22 @@ main() {
|
||||
} else {
|
||||
start(app, appName, locale, helper);
|
||||
}
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}
|
||||
|
||||
initWithSystemValue(String app, String name, String locale, SqliteHelper helper) {
|
||||
initWithSystemValue(String app, String name, String locale,
|
||||
SqliteHelper helper) {
|
||||
helper.getSettings(false).then((settings) {
|
||||
if (settings.isEmpty) {
|
||||
createSettingsTable(app, name, helper);
|
||||
@@ -44,7 +48,11 @@ createSettingsTable(String app, String name, SqliteHelper helper) {
|
||||
platform.invokeMethod('getCurrency').then((currency) {
|
||||
helper.createAppInfo(currency, locale).then((_) {
|
||||
start(app, name, locale, helper);
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -64,10 +72,11 @@ class Checker extends StatefulWidget {
|
||||
Checker(this.app, this.appName, this.helper);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => new CheckerState(
|
||||
this.app,
|
||||
this.appName,
|
||||
this.helper);
|
||||
State<StatefulWidget> createState() =>
|
||||
new CheckerState(
|
||||
this.app,
|
||||
this.appName,
|
||||
this.helper);
|
||||
}
|
||||
|
||||
class CheckerState extends State<Checker> {
|
||||
@@ -81,8 +90,8 @@ class CheckerState extends State<Checker> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: appName,
|
||||
home: new SplashScreen(helper, app)
|
||||
title: appName,
|
||||
home: new SplashScreen(helper, app)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,4 +50,4 @@ class _CurrenciesState extends SettingsBaseState<CurrenciesScreen> {
|
||||
saveOption() async {
|
||||
await helper.saveCurrency(currencies[selectedItem]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +79,10 @@ class RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
setState(() {
|
||||
_tokenActive = JSON.decode(response.body)['active'];
|
||||
});
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
return false;
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()}).then((_) {
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ class RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
error = parsedMap['errors'][0];
|
||||
});
|
||||
}
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,9 +191,10 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
helper.clear().then((result) {
|
||||
Navigator.of(context).pop('');
|
||||
});
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
Navigator.of(context).pop('');
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()}).then((_) {
|
||||
Navigator.of(context).pop('');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,9 +83,10 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
} else if (token != null) {
|
||||
_initAndStartScanner(context, app, token, helper);
|
||||
} else {
|
||||
print('Произошла непредусмотренная ошибка в логике приложения');
|
||||
helper.getToken().then((token) {
|
||||
_initAndStartScanner(context, app, token, helper);
|
||||
platform.invokeMethod('logError', {"message":"Token is null"}).then((_) {
|
||||
helper.getToken().then((token) {
|
||||
_initAndStartScanner(context, app, token, helper);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -103,8 +104,8 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
if (await platform.invokeMethod('isOnline')) {
|
||||
getCheckTokenStatusRequest(token).then((statusResponse) {
|
||||
handleStatusResponse(statusResponse, helper);
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -153,8 +154,8 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
} else if (response.statusCode == 201) {
|
||||
clearToken(response, helper);
|
||||
}
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -164,9 +165,11 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
Map parsedMap = JSON.decode(response.body);
|
||||
getDeleteTokenRequest(parsedMap['token']).then((_) {
|
||||
showNextScreen(new RegistrationScreen(helper, app));
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -257,7 +260,11 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
.value
|
||||
.toString();
|
||||
platform.invokeMethod('startScanner', args);
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}, onError: (e) {
|
||||
platform.invokeMethod('logError', {"message":e.toString()});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user