diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 7836658..aa44f7b 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -3,14 +3,20 @@ PODS: - Flutter - MTBBarcodeScanner - SwiftProtobuf + - 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 - 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): - Flutter @@ -25,9 +31,12 @@ PODS: DEPENDENCIES: - barcode_scan (from `.symlinks/plugins/barcode_scan/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`) + - local_auth (from `.symlinks/plugins/local_auth/ios`) - path_provider (from `.symlinks/plugins/path_provider/ios`) - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) @@ -42,12 +51,18 @@ SPEC REPOS: EXTERNAL SOURCES: barcode_scan: :path: ".symlinks/plugins/barcode_scan/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" + local_auth: + :path: ".symlinks/plugins/local_auth/ios" path_provider: :path: ".symlinks/plugins/path_provider/ios" shared_preferences: @@ -59,10 +74,13 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479 + charset_converter: 215c7b04932ec2b9ba43be96a9bc34afed3e5322 device_info: d7d233b645a32c40dfdc212de5cf646ca482f175 esys_flutter_share: 403498dab005b36ce1f8d7aff377e81f0621b0b4 - Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c + flutter_bluetooth_basic: 0e4e27e22b50b3a25cc1d1e131953feb4af414f4 FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a + local_auth: 25938960984c3a7f6e3253e3f8d962fdd16852bd MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d @@ -72,4 +90,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c -COCOAPODS: 1.8.4 +COCOAPODS: 1.10.1 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index b28cc99..718cc20 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -255,12 +255,13 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework", - "${PODS_ROOT}/../Flutter/Flutter.framework", "${BUILT_PRODUCTS_DIR}/MTBBarcodeScanner/MTBBarcodeScanner.framework", "${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework", "${BUILT_PRODUCTS_DIR}/barcode_scan/barcode_scan.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}/local_auth/local_auth.framework", "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework", "${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework", @@ -269,12 +270,13 @@ name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTBBarcodeScanner.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/barcode_scan.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}/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}/sqflite.framework", @@ -391,7 +393,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 6; DEVELOPMENT_TEAM = 94BM6VL7L8; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -528,7 +530,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 6; DEVELOPMENT_TEAM = 94BM6VL7L8; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -560,7 +562,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 6; DEVELOPMENT_TEAM = 94BM6VL7L8; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index cf1a759..05876d3 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -26,8 +26,17 @@ LSRequiresIPhoneOS + NSBluetoothAlwaysUsageDescription + Требуется доступ к Bluetooth для подключения к принтерам и печати чеков + NSBluetoothPeripheralUsageDescription + Требуется доступ к Bluetooth для подключения к принтерам и печати чеков NSCameraUsageDescription Требуется доступ к камере для сканирования QR-кодов и штрих-кодов + UIBackgroundModes + + bluetooth-central + bluetooth-peripheral + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile diff --git a/lib/views/check/image_show_container.dart b/lib/views/check/image_show_container.dart index de281d5..2c8303c 100644 --- a/lib/views/check/image_show_container.dart +++ b/lib/views/check/image_show_container.dart @@ -50,6 +50,15 @@ class _ImageShowContainerState extends State { return; } + bool isIos = Platform.isIOS; + int chunkSizeBytes = 3096; + int queueSleepTimeMs = 50; + + if(isIos){ + chunkSizeBytes = 75; + queueSleepTimeMs = 10; + } + setState(() { _printing = true; }); @@ -61,8 +70,8 @@ class _ImageShowContainerState extends State { if (SettingPrinterEncodingImage == state.printerEncoding) { final PosPrintResult res = await printerManager.printTicket( await printImageCheck(paper, widget.showModel.data.base64Data), - chunkSizeBytes: 3096, - queueSleepTimeMs: 50); + chunkSizeBytes: chunkSizeBytes, + queueSleepTimeMs: queueSleepTimeMs); if (res.value != 1) { _dialogService.showDialog(description: res.msg); } @@ -71,8 +80,8 @@ class _ImageShowContainerState extends State { await printTextCheck( paper, state.printerEncoding, jsonDecode(widget.showModel.data.textData)), - chunkSizeBytes: 3096, - queueSleepTimeMs: 50); + chunkSizeBytes: chunkSizeBytes, + queueSleepTimeMs: queueSleepTimeMs); if (res.value != 1) { _dialogService.showDialog(description: res.msg); } diff --git a/lib/views/payment/payment_view.dart b/lib/views/payment/payment_view.dart index 70b6c8f..fb46ad6 100644 --- a/lib/views/payment/payment_view.dart +++ b/lib/views/payment/payment_view.dart @@ -156,7 +156,7 @@ class _PaymentViewState extends State { onPressed: () { pressPayment('card'); }, - mainColor: greenColor, + mainColor: primaryColor, )), horizontalSpaceSmall, Expanded( @@ -165,7 +165,7 @@ class _PaymentViewState extends State { onPressed: () { pressPayment('cash'); }, - mainColor: primaryColor, + mainColor: greenColor, )), ], ), diff --git a/lib/views/settings/printer/PrinterTest.dart b/lib/views/settings/printer/PrinterTest.dart index b3bfdff..e9e646b 100644 --- a/lib/views/settings/printer/PrinterTest.dart +++ b/lib/views/settings/printer/PrinterTest.dart @@ -124,7 +124,7 @@ Future testTicketImage(PaperSize paper) async { //ticket.imageRaster(imagea); // Using `GS ( L` ticket.imageRaster(imagea, imageFn: PosImageFn.bitImageRaster); - + //ticket.image(imagea); ticket.feed(2); @@ -147,7 +147,7 @@ Future printImageCheck(PaperSize paper, String base64Src) async { Future printTextCheck(PaperSize paper, String encoding, var data ) async { final Ticket ticket = Ticket(paper); - + ticket.emptyLines(1); PosCodeTable codeTable; @@ -157,7 +157,7 @@ Future printTextCheck(PaperSize paper, String encoding, var data ) async codeTable = PosCodeTable.wpc1251; } - ticket.setGlobalCodeTable(codeTable); + //ticket.setGlobalCodeTable(codeTable); ticket.setGlobalFont(PosFontType.fontB); @@ -176,12 +176,12 @@ Future printTextCheck(PaperSize paper, String encoding, var data ) async PosColumn( textEncoded: firstCol, width: 6, - styles: PosStyles(align: PosAlign.left), + styles: PosStyles(align: PosAlign.left, codeTable: codeTable ), ), PosColumn( textEncoded: lastCol, width: 6, - styles: PosStyles(align: PosAlign.right), + styles: PosStyles(align: PosAlign.right, codeTable: codeTable ), ), ]); } else { @@ -190,9 +190,13 @@ Future printTextCheck(PaperSize paper, String encoding, var data ) async ticket.hr(); } else if(line == 'br') { ticket.emptyLines(1); + } else if(line.trim() == '') { + ticket.emptyLines(1); } else { + line = line.replaceAll("«", '\"'); + line = line.replaceAll("»", '\"'); Uint8List encTxt11 = await CharsetConverter.encode(encoding, line); - ticket.textEncoded( encTxt11, styles: PosStyles( align: center ? PosAlign.center : PosAlign.left )); + ticket.textEncoded( encTxt11, styles: PosStyles( align: center ? PosAlign.center : PosAlign.left, codeTable: codeTable )); } } } @@ -205,24 +209,27 @@ Future printTextCheck(PaperSize paper, String encoding, var data ) async const double qrSize = 200; try { final uiImg = await QrPainter( + data: qr, version: QrVersions.auto, - gapless: false, + gapless: true, ).toImageData(qrSize); final dir = await getTemporaryDirectory(); final pathName = '${dir.path}/qr_tmp.png'; final qrFile = File(pathName); final imgFile = await qrFile.writeAsBytes(uiImg.buffer.asUint8List()); - final img = Im.decodeImage(imgFile.readAsBytesSync()); + final img = Im.decodePng(imgFile.readAsBytesSync()); ticket.image(img); + + //ticket.qrcode(qr, size: QRSize.Size1 ); } catch (e) { print(e); } - - ticket.feed(2); + ticket.emptyLines(1); + ticket.feed(1); ticket.cut(); return ticket; diff --git a/lib/views/settings/setting_printer_view.dart b/lib/views/settings/setting_printer_view.dart index f255309..6e0e8ca 100644 --- a/lib/views/settings/setting_printer_view.dart +++ b/lib/views/settings/setting_printer_view.dart @@ -1,3 +1,4 @@ +import 'dart:io'; import 'dart:typed_data'; import 'package:aman_kassa_flutter/core/locator.dart'; @@ -39,20 +40,28 @@ class _SettingPrinterViewState extends State { void _testPrint() async { final SettingState state = Redux.store.state.settingState; printerManager.selectPrinter(PrinterBluetooth(state.printerBT)); + bool isIos = Platform.isIOS; + int chunkSizeBytes = 3096; + int queueSleepTimeMs = 50; + + if(isIos) { + chunkSizeBytes = 75; + queueSleepTimeMs = 10; + } // TODO Don't forget to choose printer's paper PaperSize paper = state.printerPaperSize == SettingPrinterPaperM80 ? PaperSize.mm80 : PaperSize.mm58; if(SettingPrinterEncodingImage == state.printerEncoding) { final PosPrintResult res = await printerManager.printTicket( await testTicketImage(paper), - chunkSizeBytes: 3096, - queueSleepTimeMs: 50 + chunkSizeBytes: chunkSizeBytes, + queueSleepTimeMs: queueSleepTimeMs ); _dialogService.showDialog(description: res.msg); } else { final PosPrintResult res = await printerManager.printTicket( await printTextCheck(paper, state.printerEncoding, exampleJson['check_text']), - chunkSizeBytes: 3096, - queueSleepTimeMs: 50 + chunkSizeBytes: chunkSizeBytes, + queueSleepTimeMs: queueSleepTimeMs ); _dialogService.showDialog(description: res.msg); } diff --git a/pubspec.yaml b/pubspec.yaml index a2e2383..b1dca3c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: aman_kassa_flutter description: A new Flutter project. -version: 1.1.1+26 +version: 1.2.1+27 environment: sdk: '>=2.3.0 <3.0.0' dependencies: