Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
5100ebb638 | |||
62e4e8feea | |||
47714d87ea | |||
9e13ce02b1 | |||
b946b65373 | |||
fbf8462e9c |
@ -35,7 +35,7 @@ EXTERNAL SOURCES:
|
|||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
|
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
|
||||||
integration_test: 13825b8a9334a850581300559b8839134b124670
|
integration_test: 13825b8a9334a850581300559b8839134b124670
|
||||||
jc_printer: dd12742e6ed498d581365e45724894ccae418f8f
|
jc_printer: 98d27e989a3129f784669a21dd5883eec26ba102
|
||||||
Protobuf: 351e9022fe13a6e2af00e9aefc22077cb88520f8
|
Protobuf: 351e9022fe13a6e2af00e9aefc22077cb88520f8
|
||||||
reactive_ble_mobile: 9ce6723d37ccf701dbffd202d487f23f5de03b4c
|
reactive_ble_mobile: 9ce6723d37ccf701dbffd202d487f23f5de03b4c
|
||||||
SwiftProtobuf: bcfd2bc231cf9ae552cdc7c4e877bd3b41fe57b1
|
SwiftProtobuf: bcfd2bc231cf9ae552cdc7c4e877bd3b41fe57b1
|
||||||
|
@ -32,9 +32,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
final TextEditingController _labelWidthInput = TextEditingController();
|
final TextEditingController _labelWidthInput = TextEditingController();
|
||||||
final TextEditingController _labelHeightInput = TextEditingController();
|
final TextEditingController _labelHeightInput = TextEditingController();
|
||||||
final TextEditingController _countInput = TextEditingController();
|
final TextEditingController _countInput = TextEditingController();
|
||||||
final TextEditingController _contentInput = TextEditingController();
|
|
||||||
final _printer = JcPrinter();
|
final _printer = JcPrinter();
|
||||||
int _count = 0;
|
|
||||||
ConnectState _connectState = ConnectState.none;
|
ConnectState _connectState = ConnectState.none;
|
||||||
StreamSubscription<ConnectState>? _connectStateSubs;
|
StreamSubscription<ConnectState>? _connectStateSubs;
|
||||||
StreamSubscription<int>? _printingCountSubs;
|
StreamSubscription<int>? _printingCountSubs;
|
||||||
@ -57,7 +55,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
_labelWidthInput.text = '40';
|
_labelWidthInput.text = '40';
|
||||||
_labelHeightInput.text = '30';
|
_labelHeightInput.text = '30';
|
||||||
_countInput.text = '1';
|
_countInput.text = '1';
|
||||||
_contentInput.text = '歪脖子';
|
|
||||||
_connectStateSubs = _printer.connectStateStream.listen(
|
_connectStateSubs = _printer.connectStateStream.listen(
|
||||||
_connectStateListener,
|
_connectStateListener,
|
||||||
);
|
);
|
||||||
@ -75,7 +72,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
_labelWidthInput.dispose();
|
_labelWidthInput.dispose();
|
||||||
_labelHeightInput.dispose();
|
_labelHeightInput.dispose();
|
||||||
_countInput.dispose();
|
_countInput.dispose();
|
||||||
_contentInput.dispose();
|
|
||||||
_connectStateSubs?.cancel();
|
_connectStateSubs?.cancel();
|
||||||
_printingCountSubs?.cancel();
|
_printingCountSubs?.cancel();
|
||||||
_errorInfoSubs?.cancel();
|
_errorInfoSubs?.cancel();
|
||||||
@ -89,7 +85,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _printingCountListener(int count) {
|
void _printingCountListener(int count) {
|
||||||
if (count == _count) _printer.endPrint();
|
print(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _errorInfoListener(Map<String, String> error) {
|
void _errorInfoListener(Map<String, String> error) {
|
||||||
@ -101,12 +97,17 @@ class _HomePageState extends State<HomePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _startPrint() async {
|
void _startPrint() async {
|
||||||
|
final count = int.tryParse(_countInput.value.text) ?? 0;
|
||||||
|
_printer.setTotalPrints(count);
|
||||||
|
await _printer.startPrint();
|
||||||
|
final data = await _getLabelData();
|
||||||
|
await _printer.commit(data: data, count: count);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> _getLabelData() async {
|
||||||
final labelWidth = double.tryParse(_labelWidthInput.value.text) ?? 0;
|
final labelWidth = double.tryParse(_labelWidthInput.value.text) ?? 0;
|
||||||
final labelHeight = double.tryParse(_labelHeightInput.value.text) ?? 0;
|
final labelHeight = double.tryParse(_labelHeightInput.value.text) ?? 0;
|
||||||
_count = int.tryParse(_countInput.value.text) ?? 0;
|
|
||||||
final content = _contentInput.value.text.trim();
|
|
||||||
if (content.isEmpty || _count <= 0) return;
|
|
||||||
_printer.setTotalPrints(1);
|
|
||||||
await _printer.initDrawingBoard(
|
await _printer.initDrawingBoard(
|
||||||
width: labelWidth,
|
width: labelWidth,
|
||||||
height: labelHeight,
|
height: labelHeight,
|
||||||
@ -115,7 +116,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
await _printer.drawLabelText(
|
await _printer.drawLabelText(
|
||||||
width: labelWidth,
|
width: labelWidth,
|
||||||
height: 7,
|
height: 7,
|
||||||
content: content,
|
content: '打印测试',
|
||||||
fontSize: 7,
|
fontSize: 7,
|
||||||
);
|
);
|
||||||
await _printer.drawLabelBarcode(
|
await _printer.drawLabelBarcode(
|
||||||
@ -127,8 +128,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
fontSize: 4,
|
fontSize: 4,
|
||||||
textHeight: 4,
|
textHeight: 4,
|
||||||
);
|
);
|
||||||
final data = await _printer.getLabelData();
|
return _printer.getLabelData();
|
||||||
_printer.startPrint(data: data, count: _count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -177,11 +177,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
),
|
),
|
||||||
TextField(
|
TextField(
|
||||||
controller: _countInput,
|
controller: _countInput,
|
||||||
decoration: const InputDecoration(label: Text('打印数量')),
|
decoration: const InputDecoration(label: Text('每份数量')),
|
||||||
),
|
|
||||||
TextField(
|
|
||||||
controller: _contentInput,
|
|
||||||
decoration: const InputDecoration(label: Text('内容')),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
|
@ -128,7 +128,7 @@ packages:
|
|||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "0.0.2"
|
version: "0.0.3"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -46,8 +46,10 @@
|
|||||||
[self getLabelData:result];
|
[self getLabelData:result];
|
||||||
} else if ([@"startJob" isEqualToString:call.method]) {
|
} else if ([@"startJob" isEqualToString:call.method]) {
|
||||||
[self startJob:call.arguments result:result];
|
[self startJob:call.arguments result:result];
|
||||||
} else if ([@"endJob" isEqualToString:call.method]) {
|
} else if ([@"cancelJob" isEqualToString:call.method]) {
|
||||||
[self endJob:result];
|
[self cancelJob:result];
|
||||||
|
} else if ([@"endPrint" isEqualToString:call.method]) {
|
||||||
|
[self endPrint:result];
|
||||||
} else if ([@"commit" isEqualToString:call.method]) {
|
} else if ([@"commit" isEqualToString:call.method]) {
|
||||||
[self commit:call.arguments result:result];
|
[self commit:call.arguments result:result];
|
||||||
} else {
|
} else {
|
||||||
@ -149,11 +151,17 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)endJob:(FlutterResult)result {
|
- (void)endPrint:(FlutterResult)result {
|
||||||
[JCAPI endPrint:^(BOOL isSuccess) {
|
[JCAPI endPrint:^(BOOL isSuccess) {
|
||||||
result(@(isSuccess));
|
result(@(isSuccess));
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)cancelJob:(FlutterResult)result {
|
||||||
|
[JCAPI cancelJob:^(BOOL isSuccess) {
|
||||||
|
result(@(isSuccess));
|
||||||
|
}];
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma mark - FlutterStreamHandler
|
#pragma mark - FlutterStreamHandler
|
||||||
|
@ -14,7 +14,7 @@ Pod::Spec.new do |s|
|
|||||||
s.source_files = 'Classes/**/*'
|
s.source_files = 'Classes/**/*'
|
||||||
s.public_header_files = 'Classes/**/*.h'
|
s.public_header_files = 'Classes/**/*.h'
|
||||||
|
|
||||||
s.vendored_framework = 'Frameworks/Simulator/JCPrinterSDK.framework'
|
s.vendored_frameworks = 'Frameworks/JCPrinterSDK.framework', 'Frameworks/CocoaAsyncSocket.framework'
|
||||||
|
|
||||||
s.dependency 'Flutter'
|
s.dependency 'Flutter'
|
||||||
s.platform = :ios, '11.0'
|
s.platform = :ios, '11.0'
|
||||||
|
@ -215,17 +215,28 @@ class JcPrinter {
|
|||||||
/// @param data 绘画数据。
|
/// @param data 绘画数据。
|
||||||
///
|
///
|
||||||
/// @param count 用于指定当前页的打印份数。
|
/// @param count 用于指定当前页的打印份数。
|
||||||
Future<bool> startPrint({
|
Future<bool> startPrint() async {
|
||||||
required String data,
|
return _printer.startJob(
|
||||||
int count = 1,
|
|
||||||
}) async {
|
|
||||||
final result = await _printer.startJob(
|
|
||||||
blackRules: 0,
|
blackRules: 0,
|
||||||
paperStyle: 1,
|
paperStyle: 1,
|
||||||
);
|
);
|
||||||
if (result != true) return false;
|
}
|
||||||
|
|
||||||
|
/// 提交打印任务
|
||||||
|
///
|
||||||
|
/// @param data 打印数据。
|
||||||
|
///
|
||||||
|
/// @param count 用于指定当前页的打印份数。
|
||||||
|
Future<bool> commit({
|
||||||
|
required String data,
|
||||||
|
int count = 1,
|
||||||
|
}) async {
|
||||||
return _printer.commit(data: data, count: count);
|
return _printer.commit(data: data, count: count);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> endPrint() async => _printer.endJob();
|
/// 取消打印任务(打印完成之前调用)
|
||||||
|
Future<bool> cancelPrint() async => _printer.cancelJob();
|
||||||
|
|
||||||
|
/// 结束打印任务(打印完成之后调用)
|
||||||
|
Future<bool> endPrint() async => _printer.endPrint();
|
||||||
}
|
}
|
||||||
|
@ -153,8 +153,14 @@ class MethodChannelJcPrinter extends JcPrinterPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> endJob() async {
|
Future<bool> cancelJob() async {
|
||||||
final result = await method.invokeMethod<bool>('endJob');
|
final result = await method.invokeMethod<bool>('cancelJob');
|
||||||
|
return result ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> endPrint() async {
|
||||||
|
final result = await method.invokeMethod<bool>('endPrint');
|
||||||
return result ?? false;
|
return result ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,8 +202,13 @@ abstract class JcPrinterPlatform extends PlatformInterface {
|
|||||||
throw UnimplementedError('startJob() has not been implemented.');
|
throw UnimplementedError('startJob() has not been implemented.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 结束打印任务
|
/// 取消打印任务(打印完成之前调用)
|
||||||
Future<bool> endJob() async {
|
Future<bool> cancelJob() async {
|
||||||
|
throw UnimplementedError('endJob() has not been implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 取消打印任务(打印完成之后调用)
|
||||||
|
Future<bool> endPrint() async {
|
||||||
throw UnimplementedError('endJob() has not been implemented.');
|
throw UnimplementedError('endJob() has not been implemented.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: jc_printer
|
name: jc_printer
|
||||||
description: 精臣打印机SDK
|
description: 精臣打印机SDK
|
||||||
version: 0.0.2
|
version: 0.0.4
|
||||||
homepage: https://git.nasme.cc:10443/rean/flutter_jc_printer_plugin
|
homepage: https://git.nasme.cc:10443/rean/flutter_jc_printer_plugin
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
Loading…
Reference in New Issue
Block a user