diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index 12bdc22..064ff21 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7d8294f..1cfc7b8 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,10 +2,14 @@ + - + + + + - + + - + + + + + @@ -49,6 +59,8 @@ + + @@ -83,7 +95,6 @@ - diff --git a/android/.idea/gradle.xml b/android/.idea/gradle.xml index b220fcc..6cec569 100644 --- a/android/.idea/gradle.xml +++ b/android/.idea/gradle.xml @@ -12,7 +12,6 @@ - diff --git a/android/.idea/modules.xml b/android/.idea/modules.xml index dc6a25e..8ca7f48 100644 --- a/android/.idea/modules.xml +++ b/android/.idea/modules.xml @@ -3,6 +3,9 @@ + + + \ No newline at end of file diff --git a/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java b/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java index 81c063e..1595b14 100644 --- a/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java +++ b/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java @@ -21,11 +21,23 @@ public class AsPrint { } public void printAsCode(String code, String channel, String country, String countStr, int offset, boolean hasPlan) throws IOException { - if (hasPlan) { - PrintPlan(code, channel, country, countStr, offset); - } else { - PrintNoPlan(code, countStr, offset); - } + printTest(); +// if (hasPlan) { +// PrintPlan(code, channel, country, countStr, offset); +// } else { +// PrintNoPlan(code, countStr, offset); +// } + } + + private void printTest() throws UnsupportedEncodingException { + cpclPrinter.setForm(0, 203, 203, 500, 575, 0, 1); + cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL); + cpclPrinter.setJustification(CPCLConst.LK_CPCL_CENTER); + + cpclPrinter.printBox(5,5,500,300,3); + cpclPrinter.printLine(5,50,500,50,3); + cpclPrinter.printLine(430,300,480,250,3); + cpclPrinter.printForm(); } private void PrintPlan(String code, String channel, String country, String countStr, int offset) throws IOException { @@ -61,7 +73,8 @@ public class AsPrint { cpclPrinter.printAndroidFont(400 - offset, 300, Typeface.DEFAULT, countStr, 575, 30); cpclPrinter.printForm(); } + public int Get_Status() { - return cpclPrinter.status(); + return cpclPrinter.status(); } } diff --git a/example/lib/main.dart b/example/lib/main.dart index 7b28f3a..420a70e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -39,8 +39,13 @@ class _MyAppState extends State { DjPrinter().init(); DjPrinter().addDiscoveryListen(onReceive: (data) { var js = json.decode(data.toString()); - devices.add(Device( - name: js['name'], address: js['address'], isPaired: js['isPaired'])); + if ((js['name'] as String).startsWith('3R20P')) { + devices.add(Device( + name: js['name'], + address: js['address'], + isPaired: js['isPaired'])); + } + setState(() {}); }, onStart: () { print("————————————————————————"); @@ -87,7 +92,7 @@ class _MyAppState extends State { ), TextButton( onPressed: () { - DjPrinter().print( + DjPrinter().printAScode( code: 'ASSZ2022012500010002', channel: 'cosco定提-月达-卡派', country: '美国', @@ -95,7 +100,16 @@ class _MyAppState extends State { offset: 0, hasPlan: false); }, - child: const Text('打印')) + child: const Text('打印')), + + const SizedBox( + height: 20, + ), + TextButton( + onPressed: () { + DjPrinter().disposeConnect(); + }, + child: const Text('取消链接')) ], ), ), diff --git a/example/pubspec.lock b/example/pubspec.lock index e52ea86..c093bf6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,58 +5,58 @@ packages: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" bot_toast: dependency: "direct main" description: name: bot_toast - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "4.0.1" + version: "4.0.2" characters: dependency: transitive description: name: characters - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.1" clock: dependency: transitive description: name: clock - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" dj_printer: dependency: "direct main" description: @@ -68,9 +68,9 @@ packages: dependency: transitive description: name: fake_async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -80,7 +80,7 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.0.4" flutter_test: @@ -92,70 +92,77 @@ packages: dependency: transitive description: name: lints - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + 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.4" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.7.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" permission_handler: dependency: "direct main" description: name: permission_handler - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "9.2.0" permission_handler_android: dependency: transitive description: name: permission_handler_android - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "9.0.2" + version: "9.0.2+1" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "9.0.2" + version: "9.0.4" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "3.7.0" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.2" sky_engine: @@ -167,58 +174,51 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.4.3" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "0.4.9" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.15.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.8.0" diff --git a/pubspec.lock b/pubspec.lock index 3128254..d4b1f47 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,51 +5,51 @@ packages: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.1" clock: dependency: transitive description: name: clock - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -59,7 +59,7 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.0.4" flutter_test: @@ -71,37 +71,37 @@ packages: dependency: transitive description: name: lints - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.12.11" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.1.4" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.7.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" sky_engine: dependency: transitive description: flutter @@ -111,58 +111,51 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.3.0" + version: "0.4.9" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.20.0"