Merge branch 'ns-printer' of ssh://206.189.105.187:22022/Serik/aman-kassa-flutter into ns-printer

migrate_to_ns
suvaysov 2022-03-21 10:31:28 +06:00
commit 2f2a4dce3a
7 changed files with 150 additions and 91 deletions

View File

@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>

View File

@ -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

View File

@ -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",

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -114,6 +114,8 @@ class BluePrintService extends BaseService {
} else if (isIos) {
await _bluetoothDeviceIOS?.disconnect();
}
print('disconnected');
response = true;
} catch (e) {
print('Error $e');
@ -124,35 +126,48 @@ class BluePrintService extends BaseService {
Future<bool> printBytes(Uint8List bytes,
{int chunkSizeBytes = 20, int queueSleepTimeMs = 20}) async {
if (isAndroid) {
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));
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);
}
for (var i = 0; i < chunks.length; i += 1) {
await _bluetoothAndr.rawBytes(config, chunks[i]);
await Future.delayed(Duration(milliseconds: queueSleepTimeMs));
}
} else if (isIos) {
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);
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);
}
}

View File

@ -61,6 +61,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) {
@ -107,7 +118,7 @@ class _ImageShowContainerState extends State<ImageShowContainer> {
print(e);
}
await Future.delayed(Duration(seconds: 15));
await printerManager.disconnect();
setState(() {
_printing = false;
});

View File

@ -41,6 +41,15 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
super.initState();
_permission();
}
@override
void dispose() {
disconnect();
super.dispose();
}
disconnect() async {
await printerManager.disconnect();
}
void _testPrint() async {
setState(() {
@ -49,12 +58,11 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
try {
final SettingState state = Redux.store!.state.settingState!;
printerManager.device = state.printerBT!;
bool isConnected = await printerManager.connect();
if(isConnected == false) {
await Future.delayed(Duration(seconds: 3));
await printerManager.disconnect();
return;
}
await disconnect();
await Future.delayed(Duration(seconds: 1));
await printerManager.connect();
await Future.delayed(Duration(seconds: 3));
bool isIos = Platform.isIOS;
int chunkSizeBytes = 3096;
@ -77,14 +85,14 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
Uint8List.fromList(await testTicketImage(paper)),
chunkSizeBytes: chunkSizeBytes,
queueSleepTimeMs: queueSleepTimeMs);
_dialogService.showDialog(description: 'result is $res');
//_dialogService.showDialog(description: 'result is $res');
} else {
final bool res = await printerManager.printBytes(
Uint8List.fromList(await printTextCheck(
paper, state.printerEncoding!, exampleJson['check_text'])),
chunkSizeBytes: chunkSizeBytes,
queueSleepTimeMs: queueSleepTimeMs);
_dialogService.showDialog(description: 'result is $res');
//_dialogService.showDialog(description: 'result is $res');
}
} catch (e) {
print('ERROR');
@ -92,8 +100,7 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
}
//10 sec safe disconnect
await Future.delayed(Duration(seconds: 14));
await printerManager.disconnect();
await Future.delayed(Duration(seconds: 3));
setState(() {
_printing = false;
});