blue + bank commit
commit
ccd668a5c9
|
|
@ -34,7 +34,7 @@ if (keystorePropertiesFile.exists()) {
|
|||
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 31
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
|
|
@ -47,7 +47,7 @@ android {
|
|||
defaultConfig {
|
||||
applicationId "kz.com.aman.kassa"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 31
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
multiDexEnabled true
|
||||
|
|
|
|||
|
|
@ -14,12 +14,11 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
|
||||
|
||||
<!-- android:name="io.flutter.app.FlutterApplication"-->
|
||||
<application
|
||||
tools:replace="android:label"
|
||||
android:name="io.flutter.app.FlutterApplication"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:name="${applicationName}"
|
||||
android:label="Аман Касса"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:allowBackup="false"
|
||||
android:roundIcon="@mipmap/ic_launcher_rounded"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package kz.com.aman.kassa
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
|
|
@ -105,17 +106,30 @@ class MainActivity : FlutterActivity() {
|
|||
}
|
||||
|
||||
private fun startOperation(operationType: OperationType, inputJsonData: String?) {
|
||||
try {
|
||||
|
||||
|
||||
val intent = Intent()
|
||||
intent.component = ComponentName("ru.m4bank.softpos.halyk", "ru.m4bank.feature.externalapplication.ExternalApplicationActivity")
|
||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
// intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
intent.putExtra(externalOperationTypeKey, operationType.code)
|
||||
intent.putExtra(externalInputDataKey, inputJsonData)
|
||||
|
||||
if (intent.resolveActivity(packageManager) != null) {
|
||||
startActivityForResult(intent, externalApplicationRequestCode)
|
||||
} else {
|
||||
_result.error("008", "Не удалось найти подходящее приложение", "aaa")
|
||||
}
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
_result.error("008", "Не удалось найти подходящее приложение", "aaa")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
try {
|
||||
if (requestCode == externalApplicationRequestCode) {
|
||||
println("---------------")
|
||||
println(requestCode)
|
||||
|
|
@ -140,6 +154,9 @@ class MainActivity : FlutterActivity() {
|
|||
// } else
|
||||
// _result.success(null)
|
||||
}
|
||||
} catch (e: IllegalStateException) {
|
||||
print("IllegalStateException")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
buildscript {
|
||||
ext.kotlin_version = '1.3.61'
|
||||
ext.kotlin_version = '1.6.10'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@
|
|||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<string>9.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
|||
|
|
@ -1,98 +1,111 @@
|
|||
PODS:
|
||||
- barcode_scan (0.0.1):
|
||||
- barcode_scan2 (0.0.1):
|
||||
- Flutter
|
||||
- MTBBarcodeScanner
|
||||
- SwiftProtobuf
|
||||
- bluetooth_print (0.0.1):
|
||||
- Flutter
|
||||
- charset_converter (0.0.1):
|
||||
- Flutter
|
||||
- device_info (0.0.1):
|
||||
- Flutter
|
||||
- esys_flutter_share (0.0.1):
|
||||
- Flutter
|
||||
- Flutter (1.0.0)
|
||||
- flutter_bluetooth_basic (0.0.1):
|
||||
- flutter_blue (0.0.1):
|
||||
- Flutter
|
||||
- flutter_blue/Protos (= 0.0.1)
|
||||
- flutter_blue/Protos (0.0.1):
|
||||
- Flutter
|
||||
- Protobuf (~> 3.11.4)
|
||||
- FMDB (2.7.5):
|
||||
- FMDB/standard (= 2.7.5)
|
||||
- FMDB/standard (2.7.5)
|
||||
- local_auth (0.0.1):
|
||||
- Flutter
|
||||
- MTBBarcodeScanner (5.0.11)
|
||||
- path_provider (0.0.1):
|
||||
- path_provider_ios (0.0.1):
|
||||
- Flutter
|
||||
- "permission_handler (5.1.0+2)":
|
||||
- Flutter
|
||||
- shared_preferences (0.0.1):
|
||||
- Protobuf (3.11.4)
|
||||
- shared_preferences_ios (0.0.1):
|
||||
- Flutter
|
||||
- sqflite (0.0.2):
|
||||
- Flutter
|
||||
- FMDB (>= 2.7.5)
|
||||
- SwiftProtobuf (1.9.0)
|
||||
- url_launcher (0.0.1):
|
||||
- SwiftProtobuf (1.18.0)
|
||||
- url_launcher_ios (0.0.1):
|
||||
- Flutter
|
||||
- vocsy_esys_flutter_share (0.0.1):
|
||||
- Flutter
|
||||
|
||||
DEPENDENCIES:
|
||||
- barcode_scan (from `.symlinks/plugins/barcode_scan/ios`)
|
||||
- barcode_scan2 (from `.symlinks/plugins/barcode_scan2/ios`)
|
||||
- bluetooth_print (from `.symlinks/plugins/bluetooth_print/ios`)
|
||||
- charset_converter (from `.symlinks/plugins/charset_converter/ios`)
|
||||
- device_info (from `.symlinks/plugins/device_info/ios`)
|
||||
- esys_flutter_share (from `.symlinks/plugins/esys_flutter_share/ios`)
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_bluetooth_basic (from `.symlinks/plugins/flutter_bluetooth_basic/ios`)
|
||||
- flutter_blue (from `.symlinks/plugins/flutter_blue/ios`)
|
||||
- local_auth (from `.symlinks/plugins/local_auth/ios`)
|
||||
- path_provider (from `.symlinks/plugins/path_provider/ios`)
|
||||
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
|
||||
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
|
||||
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
|
||||
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
|
||||
- sqflite (from `.symlinks/plugins/sqflite/ios`)
|
||||
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
|
||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||
- vocsy_esys_flutter_share (from `.symlinks/plugins/vocsy_esys_flutter_share/ios`)
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- FMDB
|
||||
- MTBBarcodeScanner
|
||||
- Protobuf
|
||||
- SwiftProtobuf
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
barcode_scan:
|
||||
:path: ".symlinks/plugins/barcode_scan/ios"
|
||||
barcode_scan2:
|
||||
:path: ".symlinks/plugins/barcode_scan2/ios"
|
||||
bluetooth_print:
|
||||
:path: ".symlinks/plugins/bluetooth_print/ios"
|
||||
charset_converter:
|
||||
:path: ".symlinks/plugins/charset_converter/ios"
|
||||
device_info:
|
||||
:path: ".symlinks/plugins/device_info/ios"
|
||||
esys_flutter_share:
|
||||
:path: ".symlinks/plugins/esys_flutter_share/ios"
|
||||
Flutter:
|
||||
:path: Flutter
|
||||
flutter_bluetooth_basic:
|
||||
:path: ".symlinks/plugins/flutter_bluetooth_basic/ios"
|
||||
flutter_blue:
|
||||
:path: ".symlinks/plugins/flutter_blue/ios"
|
||||
local_auth:
|
||||
:path: ".symlinks/plugins/local_auth/ios"
|
||||
path_provider:
|
||||
:path: ".symlinks/plugins/path_provider/ios"
|
||||
path_provider_ios:
|
||||
:path: ".symlinks/plugins/path_provider_ios/ios"
|
||||
permission_handler:
|
||||
:path: ".symlinks/plugins/permission_handler/ios"
|
||||
shared_preferences:
|
||||
:path: ".symlinks/plugins/shared_preferences/ios"
|
||||
shared_preferences_ios:
|
||||
:path: ".symlinks/plugins/shared_preferences_ios/ios"
|
||||
sqflite:
|
||||
:path: ".symlinks/plugins/sqflite/ios"
|
||||
url_launcher:
|
||||
:path: ".symlinks/plugins/url_launcher/ios"
|
||||
url_launcher_ios:
|
||||
:path: ".symlinks/plugins/url_launcher_ios/ios"
|
||||
vocsy_esys_flutter_share:
|
||||
:path: ".symlinks/plugins/vocsy_esys_flutter_share/ios"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479
|
||||
barcode_scan2: 0af2bb63c81b4565aab6cd78278e4c0fa136dbb0
|
||||
bluetooth_print: da8f47e8881a0b1f0fd8d73cd6fa84c9bd41ac28
|
||||
charset_converter: 215c7b04932ec2b9ba43be96a9bc34afed3e5322
|
||||
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
|
||||
esys_flutter_share: 403498dab005b36ce1f8d7aff377e81f0621b0b4
|
||||
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
|
||||
flutter_bluetooth_basic: 0e4e27e22b50b3a25cc1d1e131953feb4af414f4
|
||||
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
|
||||
flutter_blue: eeb381dc4727a0954dede73515f683865494b370
|
||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||
local_auth: 25938960984c3a7f6e3253e3f8d962fdd16852bd
|
||||
local_auth: ef62030a2731330b95df7ef1331bd15f6a64b8a6
|
||||
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
|
||||
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
|
||||
path_provider_ios: 7d7ce634493af4477d156294792024ec3485acd5
|
||||
permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0
|
||||
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
|
||||
Protobuf: 176220c526ad8bd09ab1fb40a978eac3fef665f7
|
||||
shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32
|
||||
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
|
||||
SwiftProtobuf: ecbec1be9036d15655f6b3443a1c4ea693c97932
|
||||
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
|
||||
SwiftProtobuf: c3c12645230d9b09c72267e0de89468c5543bd86
|
||||
url_launcher_ios: 02f1989d4e14e998335b02b67a7590fa34f971af
|
||||
vocsy_esys_flutter_share: 98b79fad467203ababde56a7289ac90da6a4ddf5
|
||||
|
||||
PODFILE CHECKSUM: 5aafc9b59da66d8d46f05cbbbd21261eb9757176
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
|
|
@ -166,7 +166,7 @@
|
|||
97C146E61CF9000F007C117D /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1020;
|
||||
LastUpgradeCheck = 1300;
|
||||
ORGANIZATIONNAME = "The Chromium Authors";
|
||||
TargetAttributes = {
|
||||
97C146ED1CF9000F007C117D = {
|
||||
|
|
@ -256,31 +256,35 @@
|
|||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/MTBBarcodeScanner/MTBBarcodeScanner.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Protobuf/protobuf.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/barcode_scan/barcode_scan.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/barcode_scan2/barcode_scan2.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/charset_converter/charset_converter.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/device_info/device_info.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/esys_flutter_share/esys_flutter_share.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/flutter_blue/flutter_blue.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/local_auth/local_auth.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/path_provider_ios/path_provider_ios.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/shared_preferences_ios/shared_preferences_ios.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/vocsy_esys_flutter_share/vocsy_esys_flutter_share.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTBBarcodeScanner.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/protobuf.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/barcode_scan.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/barcode_scan2.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/charset_converter.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/esys_flutter_share.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_blue.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_ios.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_ios.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/vocsy_esys_flutter_share.framework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
|
|
@ -376,7 +380,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
|
|
@ -401,7 +405,10 @@
|
|||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
|
|
@ -463,7 +470,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
|
|
@ -512,7 +519,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
|
|
@ -538,7 +545,10 @@
|
|||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
|
|
@ -570,7 +580,10 @@
|
|||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1020"
|
||||
LastUpgradeVersion = "1300"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import 'package:aman_kassa_flutter/core/services/BankService.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/blue_print_service.dart';
|
||||
|
||||
import '../core/services/DbService.dart';
|
||||
|
||||
|
|
@ -26,6 +27,8 @@ class LocatorInjector {
|
|||
locator.registerLazySingleton<DialogService>(() => DialogService());
|
||||
_log.d('Initializing DbService Service');
|
||||
locator.registerLazySingleton<DbService>(() => DbService.instance);
|
||||
_log.d('Initializing BluePrintService Service');
|
||||
locator.registerLazySingleton<BluePrintService>(() => BluePrintService());
|
||||
|
||||
|
||||
// depencies
|
||||
|
|
|
|||
|
|
@ -0,0 +1,173 @@
|
|||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:aman_kassa_flutter/core/base/base_service.dart';
|
||||
import 'package:bluetooth_print/bluetooth_print.dart';
|
||||
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||
import 'package:flutter_blue/flutter_blue.dart' as flutter_blue;
|
||||
import 'package:flutter_blue/gen/flutterblue.pb.dart' as proto;
|
||||
|
||||
class BluePrintService extends BaseService {
|
||||
final BluetoothPrint _bluetoothAndr = BluetoothPrint.instance;
|
||||
flutter_blue.BluetoothDevice? _bluetoothDeviceIOS;
|
||||
final flutter_blue.FlutterBlue _bluetoothIOS =
|
||||
flutter_blue.FlutterBlue.instance;
|
||||
|
||||
final bool isAndroid = Platform.isAndroid;
|
||||
final bool isIos = Platform.isIOS;
|
||||
// final bool isAndroid = false;
|
||||
// final bool isIos = true;
|
||||
|
||||
BluetoothDevice? _device;
|
||||
|
||||
Future<void> scan() async {
|
||||
if (isAndroid) {
|
||||
await _bluetoothAndr.startScan(timeout: Duration(seconds: 4));
|
||||
} else if (isIos) {
|
||||
await _bluetoothIOS.startScan(timeout: const Duration(seconds: 5));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> stopScan() async {
|
||||
if (isAndroid) {
|
||||
await _bluetoothAndr.stopScan();
|
||||
} else if (isIos) {
|
||||
await _bluetoothIOS.stopScan();
|
||||
}
|
||||
}
|
||||
|
||||
Stream<List<BluetoothDevice>> get scanResult {
|
||||
if (isAndroid)
|
||||
return _bluetoothAndr.scanResults;
|
||||
else
|
||||
return _bluetoothIOS.scanResults.asyncMap<List<BluetoothDevice>>(
|
||||
(event) =>
|
||||
Future.wait(event.toList().map((e) async => BluetoothDevice()
|
||||
..name = e.device.name
|
||||
..type = e.device.type.index
|
||||
..address = e.device.id.id)));
|
||||
}
|
||||
|
||||
Stream<bool> get isScanning =>
|
||||
isAndroid ? _bluetoothAndr.isScanning : _bluetoothIOS.isScanning;
|
||||
|
||||
Stream<int> get state => isAndroid
|
||||
? _bluetoothAndr.state
|
||||
: _bluetoothIOS.state.asyncMap<int>((event) => event.index);
|
||||
|
||||
set device(BluetoothDevice device) => _device = device;
|
||||
|
||||
Future<bool> connect() async {
|
||||
bool response = false;
|
||||
if (_device == null) {
|
||||
response = false;
|
||||
} else {
|
||||
// try {
|
||||
// await _bluetoothAndr.connect(_device!);
|
||||
// await Future.delayed(Duration(seconds: 5));
|
||||
// response = true;
|
||||
// } catch (e) {
|
||||
// print('Error connect $e');
|
||||
// response = false;
|
||||
// }
|
||||
|
||||
try {
|
||||
if (isAndroid) {
|
||||
await _bluetoothAndr.connect(_device!);
|
||||
} else if (isIos) {
|
||||
_bluetoothDeviceIOS = flutter_blue.BluetoothDevice.fromProto(
|
||||
proto.BluetoothDevice(
|
||||
name: _device?.name ?? '',
|
||||
remoteId: _device?.address ?? '',
|
||||
type: proto.BluetoothDevice_Type.valueOf(_device?.type ?? 0),
|
||||
),
|
||||
);
|
||||
final List<flutter_blue.BluetoothDevice> connectedDevices =
|
||||
await _bluetoothIOS.connectedDevices;
|
||||
final int deviceConnectedIndex = connectedDevices
|
||||
.indexWhere((flutter_blue.BluetoothDevice bluetoothDevice) {
|
||||
return bluetoothDevice.id == _bluetoothDeviceIOS?.id;
|
||||
});
|
||||
if (deviceConnectedIndex < 0) {
|
||||
await _bluetoothDeviceIOS?.connect();
|
||||
}
|
||||
}
|
||||
|
||||
response = true;
|
||||
_device?.connected = true;
|
||||
return Future<bool>.value(response);
|
||||
} on Exception catch (error) {
|
||||
print('$runtimeType - Error $error');
|
||||
response = false;
|
||||
_device?.connected = false;
|
||||
return Future<bool>.value(response);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<bool> disconnect() async {
|
||||
bool response = false;
|
||||
try {
|
||||
if (isAndroid) {
|
||||
await _bluetoothAndr.disconnect();
|
||||
} else if (isIos) {
|
||||
await _bluetoothDeviceIOS?.disconnect();
|
||||
}
|
||||
|
||||
print('disconnected');
|
||||
response = true;
|
||||
} catch (e) {
|
||||
print('Error $e');
|
||||
response = false;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<bool> printBytes(Uint8List bytes,
|
||||
{int chunkSizeBytes = 20, int queueSleepTimeMs = 20}) async {
|
||||
Map<String, dynamic> config = Map();
|
||||
final len = bytes.length;
|
||||
List<List<int>> chunks = [];
|
||||
for (var i = 0; i < len; i += chunkSizeBytes) {
|
||||
var end = (i + chunkSizeBytes < len) ? i + chunkSizeBytes : len;
|
||||
chunks.add(bytes.sublist(i, end));
|
||||
}
|
||||
|
||||
for (var i = 0; i < chunks.length; i += 1) {
|
||||
if (isAndroid) {
|
||||
await _printAndroid(chunks[i], config);
|
||||
} else if (isIos) {
|
||||
await _printIos(Uint8List.fromList(chunks[i]), config);
|
||||
}
|
||||
|
||||
await Future.delayed(Duration(milliseconds: queueSleepTimeMs));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> _printIos(Uint8List bytes,Map<String, dynamic> config) async {
|
||||
final List<flutter_blue.BluetoothService> bluetoothServices =
|
||||
await _bluetoothDeviceIOS?.discoverServices() ??
|
||||
<flutter_blue.BluetoothService>[];
|
||||
final flutter_blue.BluetoothService bluetoothService =
|
||||
bluetoothServices.firstWhere(
|
||||
(flutter_blue.BluetoothService service) => service.isPrimary,
|
||||
);
|
||||
final flutter_blue.BluetoothCharacteristic characteristic =
|
||||
bluetoothService.characteristics.firstWhere(
|
||||
(flutter_blue.BluetoothCharacteristic bluetoothCharacteristic) =>
|
||||
bluetoothCharacteristic.properties.write,
|
||||
);
|
||||
await characteristic.write(bytes, withoutResponse: true);
|
||||
}
|
||||
|
||||
Future<void> _printAndroid(List<int> chunk ,Map<String, dynamic> config) async {
|
||||
|
||||
|
||||
await _bluetoothAndr.rawBytes(config, chunk);
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ Future<void> cleanKassaItems(Store<AppState> store) async {
|
|||
store.dispatch(SetKassaStateAction(KassaState(kassaItems: [])));
|
||||
}
|
||||
|
||||
ThunkAction<AppState> addCustomProductToKassaItems(String name, int count, double price, double total) {
|
||||
ThunkAction<AppState> addCustomProductToKassaItems(String name, double count, double price, double total) {
|
||||
return (Store<AppState> store) async {
|
||||
List<ProductDao> items = store.state.kassaState!.kassaItems!;
|
||||
items.add(new ProductDao(name: name, count: count, price: price, total: total));
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
||||
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
|
||||
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:redux_thunk/redux_thunk.dart';
|
||||
import 'package:flutter_bluetooth_basic/src/bluetooth_device.dart';
|
||||
import '../store.dart';
|
||||
|
||||
@immutable
|
||||
|
|
|
|||
|
|
@ -8,15 +8,17 @@ class BankState {
|
|||
final String? login;
|
||||
final String? password;
|
||||
final HalykPosSession? session;
|
||||
final bool? loading;
|
||||
|
||||
BankState({this.login, this.password, this.session,});
|
||||
BankState({this.login, this.password, this.session,this.loading});
|
||||
|
||||
//read hive
|
||||
factory BankState.initial(BankState? payload) {
|
||||
return BankState(
|
||||
login: payload?.login,
|
||||
password: payload?.password,
|
||||
session: payload?.session
|
||||
session: payload?.session,
|
||||
loading: payload?.loading
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -25,11 +27,13 @@ class BankState {
|
|||
@required login,
|
||||
@required password,
|
||||
@required session,
|
||||
@required loading,
|
||||
}) {
|
||||
return BankState(
|
||||
login: login ?? this.login,
|
||||
password: password ?? this.password,
|
||||
session: session ?? this.session
|
||||
session: session ?? this.session,
|
||||
loading: loading ?? this.loading
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
||||
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_bluetooth_basic/src/bluetooth_device.dart';
|
||||
|
||||
@immutable
|
||||
class SettingState {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:aman_kassa_flutter/core/entity/Voucher.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||
import 'package:aman_kassa_flutter/core/models/check_data.dart';
|
||||
import 'package:aman_kassa_flutter/core/models/check_image_modal.dart';
|
||||
|
|
@ -11,6 +12,7 @@ import 'package:aman_kassa_flutter/core/models/response.dart';
|
|||
import 'package:aman_kassa_flutter/core/route_names.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/BankService.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/blue_print_service.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
||||
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
||||
|
|
@ -24,11 +26,10 @@ import 'package:aman_kassa_flutter/views/settings/printer/PrinterTest.dart';
|
|||
import 'package:aman_kassa_flutter/views/payment/halyk_pos_service.dart';
|
||||
import 'package:aman_kassa_flutter/widgets/fields/busy_button_icon.dart';
|
||||
import 'package:aman_kassa_flutter/widgets/loader/Dialogs.dart';
|
||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
||||
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
import 'package:vocsy_esys_flutter_share/vocsy_esys_flutter_share.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
|
@ -45,11 +46,10 @@ class ImageShowContainer extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _ImageShowContainerState extends State<ImageShowContainer> {
|
||||
final PrinterBluetoothManager printerManager = PrinterBluetoothManager();
|
||||
final BluePrintService printerManager = locator<BluePrintService>();
|
||||
final DialogService _dialogService = locator<DialogService>();
|
||||
final BluetoothDevice? printerBtDevice =
|
||||
Redux.store!.state.settingState!.printerBT;
|
||||
final BluetoothManager bluetoothManager = BluetoothManager.instance;
|
||||
|
||||
bool _printing = false;
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ class _ImageShowContainerState extends State<ImageShowContainer> {
|
|||
if (Platform.isIOS) {
|
||||
_print();
|
||||
} else {
|
||||
bluetoothManager.state.listen((val) {
|
||||
printerManager.state.listen((val) {
|
||||
print("state = $val");
|
||||
if (!mounted) return;
|
||||
if (val == 12) {
|
||||
|
|
@ -74,6 +74,17 @@ class _ImageShowContainerState extends State<ImageShowContainer> {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
disconnect();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
void disconnect() async {
|
||||
await printerManager.disconnect();
|
||||
}
|
||||
|
||||
void _print() async {
|
||||
final SettingState state = Redux.store!.state.settingState!;
|
||||
if (state.printerBT == null) {
|
||||
|
|
@ -95,32 +106,32 @@ class _ImageShowContainerState extends State<ImageShowContainer> {
|
|||
_printing = true;
|
||||
});
|
||||
try {
|
||||
printerManager.selectPrinter(PrinterBluetooth(state.printerBT!));
|
||||
printerManager.device = state.printerBT!;
|
||||
await printerManager.connect();
|
||||
PaperSize paper = state.printerPaperSize == SettingPrinterPaperM80
|
||||
? PaperSize.mm80
|
||||
: PaperSize.mm58;
|
||||
if (SettingPrinterEncodingImage == state.printerEncoding) {
|
||||
final PosPrintResult res = await printerManager.printTicket(
|
||||
await printImageCheck(paper, widget.showModel.data!.base64Data!),
|
||||
chunkSizeBytes: chunkSizeBytes,
|
||||
queueSleepTimeMs: queueSleepTimeMs);
|
||||
if (res.value != 1) {
|
||||
_dialogService.showDialog(description: res.msg);
|
||||
final bool res = await printerManager.printBytes(
|
||||
Uint8List.fromList(await printImageCheck(paper, widget.showModel.data!.base64Data!)));
|
||||
if (!res) {
|
||||
_dialogService.showDialog(description: 'Ошибка при печати');
|
||||
}
|
||||
} else {
|
||||
final PosPrintResult res = await printerManager.printTicket(
|
||||
await printTextCheck(paper, state.printerEncoding!,
|
||||
jsonDecode(widget.showModel.data!.textData!)),
|
||||
chunkSizeBytes: chunkSizeBytes,
|
||||
queueSleepTimeMs: queueSleepTimeMs);
|
||||
if (res.value != 1) {
|
||||
_dialogService.showDialog(description: res.msg);
|
||||
final bool res = await printerManager.printBytes(
|
||||
Uint8List.fromList(await printTextCheck(paper, state.printerEncoding!,
|
||||
jsonDecode(widget.showModel.data!.textData!)))
|
||||
);
|
||||
if (!res) {
|
||||
_dialogService.showDialog(description: 'Ошибка при печати');
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
await Future.delayed(Duration(seconds: 7));
|
||||
await Future.delayed(Duration(seconds: 15));
|
||||
|
||||
setState(() {
|
||||
_printing = false;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
|||
final prevState = sp.getInt(lastKnownStateKey);
|
||||
final prevStateIsNotPaused = prevState != null &&
|
||||
AppLifecycleState.values[prevState] != AppLifecycleState.paused;
|
||||
final bool pinIsExist = Redux.store!.state.settingState?.pinCode != null;
|
||||
final bool pinIsExist = Redux.store!.state.settingState?.pinCode != null && Redux.store!.state.settingState!.pinCode!.length > 3;
|
||||
final bool pinSkipped = Redux.store!.state.settingState?.pinSkip == true;
|
||||
print('prevStateIsNotPaused=$prevStateIsNotPaused, pinIsExist=$pinIsExist, pinSkipped=$pinSkipped');
|
||||
if(prevStateIsNotPaused && pinSkipped == false && pinIsExist == true) {
|
||||
|
|
@ -92,7 +92,7 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
|||
}
|
||||
|
||||
_checkLockPin () async {
|
||||
final bool pinIsExist = Redux.store!.state.settingState?.pinCode != null;
|
||||
final bool pinIsExist = Redux.store!.state.settingState?.pinCode != null && Redux.store!.state.settingState!.pinCode!.length > 3;
|
||||
final bool pinLocked = Redux.store!.state.settingState?.pinLocked == true;
|
||||
final sp = await SharedPreferences.getInstance();
|
||||
sp.remove(backgroundedTimeKey);
|
||||
|
|
|
|||
|
|
@ -75,11 +75,12 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
|||
prefixText: ' ',
|
||||
),
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
decimal: false,
|
||||
decimal: true,
|
||||
),
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
// WhitelistingTextInputFormatter.digitsOnly
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
// FilteringTextInputFormatter.digitsOnly
|
||||
FilteringTextInputFormatter.allow(RegExp("^[0-9.]*")),
|
||||
],
|
||||
controller: countController,
|
||||
onChanged: calcOnChange,
|
||||
|
|
@ -159,7 +160,7 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
|||
} else {
|
||||
Redux.store!.dispatch(addCustomProductToKassaItems(
|
||||
nameController.text,
|
||||
int.parse(countController.text),
|
||||
double.parse(countController.text),
|
||||
double.parse(priceController.text),
|
||||
sum));
|
||||
Navigator.pop(context);
|
||||
|
|
|
|||
|
|
@ -216,7 +216,8 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
return Container();
|
||||
}
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
onTap: isBusy ? null : () async {
|
||||
|
||||
|
||||
var today = new DateTime.now();
|
||||
var yesterday = today.subtract(new Duration(days: 1));
|
||||
|
|
@ -227,6 +228,9 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
_dialogService.showDialog(description: 'Текущая смена открыта более 24 ч. Необходимо закрыть смену и открыть ее заново.');
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
isBusy = true;
|
||||
});
|
||||
|
||||
try {
|
||||
await Redux.store!.dispatch(changePinSkipFromSetting(true));
|
||||
|
|
@ -238,6 +242,9 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
}
|
||||
} finally {
|
||||
await Redux.store!.dispatch(changePinSkipFromSetting(false));
|
||||
setState(() {
|
||||
isBusy = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
splashColor: halykColor.withOpacity(0.4),
|
||||
|
|
|
|||
|
|
@ -1,22 +1,13 @@
|
|||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:aman_kassa_flutter/core/logger.dart';
|
||||
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||
|
||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart' hide Image;
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
|
||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
import '../data/settings_envi.dart';
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,11 @@
|
|||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:aman_kassa_flutter/core/logger.dart';
|
||||
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||
|
||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart' hide Image;
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
|
||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
import '../data/settings_envi.dart';
|
||||
|
|
|
|||
|
|
@ -1,25 +1,16 @@
|
|||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||
import 'package:aman_kassa_flutter/core/logger.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/blue_print_service.dart';
|
||||
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||
|
||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart' hide Image;
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
|
||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
import '../PrinterTest.dart';
|
||||
|
||||
|
||||
class PrinterSelectView extends StatefulWidget {
|
||||
PrinterSelectView({Key? key, this.title}) : super(key: key);
|
||||
final String? title;
|
||||
|
|
@ -30,16 +21,14 @@ class PrinterSelectView extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _PrinterSelectViewState extends State<PrinterSelectView> {
|
||||
PrinterBluetoothManager printerManager = PrinterBluetoothManager();
|
||||
List<PrinterBluetooth> _devices = [];
|
||||
BluePrintService printerManager = locator<BluePrintService>();
|
||||
List<BluetoothDevice> _devices = [];
|
||||
Logger _logger = getLogger('PrinterSelectView');
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
printerManager.scanResults.listen((devices) async {
|
||||
// print('UI: Devices found ${devices.length}');
|
||||
printerManager.scanResult.listen((devices) async {
|
||||
setState(() {
|
||||
_devices = devices;
|
||||
});
|
||||
|
|
@ -51,15 +40,15 @@ class _PrinterSelectViewState extends State<PrinterSelectView> {
|
|||
setState(() {
|
||||
_devices = [];
|
||||
});
|
||||
printerManager.startScan(Duration(seconds: 4));
|
||||
printerManager.scan();
|
||||
}
|
||||
|
||||
void _stopScanDevices() {
|
||||
printerManager.stopScan();
|
||||
}
|
||||
|
||||
void _selectPrinter(PrinterBluetooth printer, BuildContext context, ) async {
|
||||
printerManager.selectPrinter(printer);
|
||||
void _selectPrinter(BluetoothDevice printer, BuildContext context, ) async {
|
||||
printerManager.device = printer;
|
||||
_logger.i(printer.name);
|
||||
_logger.i(printer.address);
|
||||
|
||||
|
|
@ -71,27 +60,6 @@ class _PrinterSelectViewState extends State<PrinterSelectView> {
|
|||
await Redux.store!.dispatch(selectPrinterFromSetting(device));
|
||||
Navigator.of(context).pop(false);
|
||||
}
|
||||
|
||||
void _testPrint(PrinterBluetooth printer) async {
|
||||
printerManager.selectPrinter(printer);
|
||||
|
||||
// TODO Don't forget to choose printer's paper
|
||||
const PaperSize paper = PaperSize.mm58;
|
||||
|
||||
// TEST PRINT
|
||||
// final PosPrintResult res =
|
||||
// await printerManager.printTicket(await testTicket(paper), queueSleepTimeMs: 50);
|
||||
|
||||
final PosPrintResult res =
|
||||
await printerManager.printTicket(
|
||||
await testTicketImage(paper),
|
||||
chunkSizeBytes: 1024,
|
||||
queueSleepTimeMs: 50
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
final key = GlobalKey();
|
||||
|
||||
@override
|
||||
|
|
@ -140,7 +108,7 @@ class _PrinterSelectViewState extends State<PrinterSelectView> {
|
|||
);
|
||||
}),
|
||||
floatingActionButton: StreamBuilder<bool>(
|
||||
stream: printerManager.isScanningStream,
|
||||
stream: printerManager.isScanning,
|
||||
initialData: false,
|
||||
builder: (c, snapshot) {
|
||||
if (snapshot.data != null) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import 'dart:io';
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:aman_kassa_flutter/core/models/dialog_models.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/blue_print_service.dart';
|
||||
import 'package:aman_kassa_flutter/widgets/fields/busy_button_icon.dart';
|
||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
||||
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||
import 'package:aman_kassa_flutter/core/logger.dart';
|
||||
import 'package:aman_kassa_flutter/core/route_names.dart';
|
||||
|
|
@ -12,9 +12,6 @@ import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
|||
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
||||
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
|
||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||
import 'package:aman_kassa_flutter/widgets/fields/aman_icon_button_horizontal.dart';
|
||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
|
@ -34,8 +31,7 @@ class SettingPrinterView extends StatefulWidget {
|
|||
class _SettingPrinterViewState extends State<SettingPrinterView> {
|
||||
NavigatorService _navigatorService = locator<NavigatorService>();
|
||||
final DialogService _dialogService = locator<DialogService>();
|
||||
final PrinterBluetoothManager printerManager = PrinterBluetoothManager();
|
||||
final BluetoothManager bluetoothManager = BluetoothManager.instance;
|
||||
final BluePrintService printerManager = locator<BluePrintService>();
|
||||
final Logger log = getLogger('SettingPrinterView');
|
||||
|
||||
bool _printing = false;
|
||||
|
|
@ -44,9 +40,16 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
_permission();
|
||||
|
||||
}
|
||||
@override
|
||||
void dispose() {
|
||||
disconnect();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
disconnect() async {
|
||||
await printerManager.disconnect();
|
||||
}
|
||||
|
||||
void _testPrint() async {
|
||||
setState(() {
|
||||
|
|
@ -54,7 +57,13 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
|||
});
|
||||
try {
|
||||
final SettingState state = Redux.store!.state.settingState!;
|
||||
printerManager.selectPrinter(PrinterBluetooth(state.printerBT!));
|
||||
printerManager.device = state.printerBT!;
|
||||
|
||||
await disconnect();
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
|
||||
await printerManager.connect();
|
||||
await Future.delayed(Duration(seconds: 3));
|
||||
bool isIos = Platform.isIOS;
|
||||
int chunkSizeBytes = 3096;
|
||||
int queueSleepTimeMs = 100;
|
||||
|
|
@ -68,34 +77,33 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
|||
log.i(queueSleepTimeMs);
|
||||
|
||||
// TODO Don't forget to choose printer's paper
|
||||
PaperSize paper = state.printerPaperSize == SettingPrinterPaperM80 ? PaperSize.mm80 : PaperSize.mm58;
|
||||
PaperSize paper = state.printerPaperSize == SettingPrinterPaperM80
|
||||
? PaperSize.mm80
|
||||
: PaperSize.mm58;
|
||||
if (SettingPrinterEncodingImage == state.printerEncoding) {
|
||||
final PosPrintResult res = await printerManager.printTicket(
|
||||
await testTicketImage(paper),
|
||||
final bool res = await printerManager.printBytes(
|
||||
Uint8List.fromList(await testTicketImage(paper)),
|
||||
chunkSizeBytes: chunkSizeBytes,
|
||||
queueSleepTimeMs: queueSleepTimeMs
|
||||
);
|
||||
_dialogService.showDialog(description: res.msg);
|
||||
queueSleepTimeMs: queueSleepTimeMs);
|
||||
//_dialogService.showDialog(description: 'result is $res');
|
||||
} else {
|
||||
final PosPrintResult res = await printerManager.printTicket(
|
||||
await printTextCheck(paper, state.printerEncoding!, exampleJson['check_text']),
|
||||
final bool res = await printerManager.printBytes(
|
||||
Uint8List.fromList(await printTextCheck(
|
||||
paper, state.printerEncoding!, exampleJson['check_text'])),
|
||||
chunkSizeBytes: chunkSizeBytes,
|
||||
queueSleepTimeMs: queueSleepTimeMs
|
||||
);
|
||||
_dialogService.showDialog(description: res.msg);
|
||||
queueSleepTimeMs: queueSleepTimeMs);
|
||||
//_dialogService.showDialog(description: 'result is $res');
|
||||
}
|
||||
} catch (e) {
|
||||
print('ERROR');
|
||||
print(e);
|
||||
}
|
||||
|
||||
//7 sec safe disconnect
|
||||
await Future.delayed(Duration(seconds: 7));
|
||||
//10 sec safe disconnect
|
||||
await Future.delayed(Duration(seconds: 14));
|
||||
|
||||
setState(() {
|
||||
_printing = false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -122,13 +130,17 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
|||
}),
|
||||
SettingItem(
|
||||
title: 'Кодировка',
|
||||
name: vm.printerEncoding != null ? encoding[vm.printerEncoding] : '' ,
|
||||
name: vm.printerEncoding != null
|
||||
? encoding[vm.printerEncoding]
|
||||
: '',
|
||||
onTap: () {
|
||||
_navigatorService.push(SettingsPrinterEncodingRoute);
|
||||
}),
|
||||
SettingItem(
|
||||
title: 'Ширина ленты',
|
||||
name: vm.printerPaperSize != null ? paperSize[vm.printerPaperSize] : null ,
|
||||
name: vm.printerPaperSize != null
|
||||
? paperSize[vm.printerPaperSize]
|
||||
: null,
|
||||
onTap: () {
|
||||
_navigatorService.push(SettingsPrinterPaperRoute);
|
||||
}),
|
||||
|
|
@ -161,24 +173,24 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
|||
//Метод для получения постоянного доступа к местополения
|
||||
//только для Android
|
||||
void _permission() async {
|
||||
if( Platform.isAndroid) {
|
||||
if (Platform.isAndroid) {
|
||||
var status = await Permission.location.status;
|
||||
log.i(status);
|
||||
if ( status.isDenied || status.isPermanentlyDenied) {
|
||||
if (status.isDenied || status.isPermanentlyDenied) {
|
||||
DialogResponse response = await _dialogService.showConfirmationDialog(
|
||||
title: 'Доступ',
|
||||
description: 'Для поиска устройств Bluetooth необходимо предоставить доступ к отслеживанию геолокации.',
|
||||
description:
|
||||
'Для поиска устройств Bluetooth необходимо предоставить доступ к отслеживанию геолокации.',
|
||||
cancelTitle: 'Нет',
|
||||
confirmationTitle: 'Хорошо',
|
||||
);
|
||||
if (response.confirmed) {
|
||||
if (await Permission.location
|
||||
.request()
|
||||
.isGranted) {
|
||||
if (await Permission.location.request().isGranted) {
|
||||
print('Granted');
|
||||
} else {
|
||||
_dialogService.showDialog(
|
||||
description: 'Необходимо указать постоянный доступ к местоположении для поиска принтера');
|
||||
description:
|
||||
'Необходимо указать постоянный доступ к местоположении для поиска принтера');
|
||||
_navigatorService.pop();
|
||||
}
|
||||
} else {
|
||||
|
|
@ -190,22 +202,20 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
|||
}
|
||||
|
||||
void _startInitialPrint() async {
|
||||
|
||||
|
||||
if (Platform.isIOS) {
|
||||
_testPrint();
|
||||
} else {
|
||||
bluetoothManager.state.listen((val) {
|
||||
printerManager.state.listen((val) {
|
||||
print("state = $val");
|
||||
if (!mounted) return;
|
||||
if (val == 12) {
|
||||
print('on');
|
||||
_testPrint();
|
||||
|
||||
} else if (val == 10) {
|
||||
print('off');
|
||||
_dialogService.showDialog(
|
||||
description: 'Отсутвует соеденение Bluetooth или он отключен' , title: 'Bluetooth');
|
||||
description: 'Отсутвует соеденение Bluetooth или он отключен',
|
||||
title: 'Bluetooth');
|
||||
}
|
||||
print('state is $val');
|
||||
});
|
||||
|
|
|
|||
56
pubspec.lock
56
pubspec.lock
|
|
@ -29,6 +29,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.2.0"
|
||||
bluetooth_print:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../bluetooth_print"
|
||||
relative: true
|
||||
source: path
|
||||
version: "3.0.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -56,7 +63,7 @@ packages:
|
|||
name: charset_converter
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -71,6 +78,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -113,13 +127,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
esc_pos_bluetooth:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: esc_pos_bluetooth
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.1"
|
||||
esc_pos_utils:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -160,13 +167,13 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_bluetooth_basic:
|
||||
dependency: transitive
|
||||
flutter_blue:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_bluetooth_basic
|
||||
name: flutter_blue
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.7"
|
||||
version: "0.8.0"
|
||||
flutter_lock_screen:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -194,7 +201,7 @@ packages:
|
|||
name: flutter_screenutil
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.1.0"
|
||||
version: "5.3.1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
|
|
@ -225,7 +232,7 @@ packages:
|
|||
name: google_fonts
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
version: "2.3.1"
|
||||
hex:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -288,7 +295,7 @@ packages:
|
|||
name: local_auth
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.10"
|
||||
version: "1.1.11"
|
||||
logger:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -310,6 +317,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
material_design_icons_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -344,7 +358,7 @@ packages:
|
|||
name: path_provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
version: "2.0.9"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -491,7 +505,7 @@ packages:
|
|||
name: responsive_builder
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.1"
|
||||
version: "0.4.2"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -505,7 +519,7 @@ packages:
|
|||
name: shared_preferences
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.12"
|
||||
version: "2.0.13"
|
||||
shared_preferences_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -622,7 +636,7 @@ packages:
|
|||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.3"
|
||||
version: "0.4.8"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -636,7 +650,7 @@ packages:
|
|||
name: url_launcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.18"
|
||||
version: "6.0.20"
|
||||
url_launcher_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -723,4 +737,4 @@ packages:
|
|||
version: "5.3.1"
|
||||
sdks:
|
||||
dart: ">=2.15.0 <3.0.0"
|
||||
flutter: ">=2.5.0"
|
||||
flutter: ">=2.10.0-0"
|
||||
|
|
|
|||
21
pubspec.yaml
21
pubspec.yaml
|
|
@ -12,32 +12,35 @@ dependencies:
|
|||
redux_thunk: ^0.4.0
|
||||
redux_persist: ^0.9.0
|
||||
redux_persist_flutter: ^0.9.0
|
||||
responsive_builder: ^0.4.1
|
||||
responsive_builder: ^0.4.2
|
||||
provider: ^6.0.2
|
||||
logger: ^1.1.0
|
||||
get_it: ^7.2.0
|
||||
equatable: ^2.0.3
|
||||
http: ^0.13.4
|
||||
sqflite: ^2.0.2
|
||||
path_provider: ^2.0.8
|
||||
google_fonts: ^2.2.0
|
||||
path_provider: ^2.0.9
|
||||
google_fonts: ^2.3.1
|
||||
material_design_icons_flutter: ^5.0.6595
|
||||
intl: ^0.17.0
|
||||
barcode_scan2: ^4.2.0
|
||||
device_info: ^2.0.3
|
||||
vocsy_esys_flutter_share: ^1.0.0
|
||||
auto_size_text: ^3.0.0
|
||||
url_launcher: ^6.0.18
|
||||
url_launcher: ^6.0.20
|
||||
qr_flutter: ^4.0.0
|
||||
mask_text_input_formatter: ^2.1.0
|
||||
flutter_screenutil: ^5.1.0
|
||||
shared_preferences: ^2.0.12
|
||||
flutter_screenutil: ^5.3.1
|
||||
shared_preferences: ^2.0.13
|
||||
flutter_lock_screen: ^2.0.1
|
||||
local_auth: ^1.1.10
|
||||
esc_pos_bluetooth: ^0.4.1
|
||||
esc_pos_utils: ^1.1.0 # no edit for esc_pos_bluetooth: ^0.2.8
|
||||
local_auth: ^1.1.11
|
||||
#esc_pos_bluetooth: ^0.4.1
|
||||
esc_pos_utils: ^1.1.0
|
||||
charset_converter: ^2.0.0
|
||||
permission_handler: ^8.3.0
|
||||
bluetooth_print:
|
||||
path: ../bluetooth_print
|
||||
flutter_blue: ^0.8.0
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
|
|
|||
Loading…
Reference in New Issue