@rdlabo/capacitor-brotherprint 6.2.0-0 → 6.2.0-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ import BRLMPrinterKit
2
+ import BRPtouchPrinterKit
3
+ import Foundation
4
+ import Capacitor
5
+
6
+ class PrinterSettingsModel {
7
+ static func initialize(_ call: CAPPluginCall, printSettings: BRLMQLPrintSettings) -> BRLMQLPrintSettings {
8
+
9
+ printSettings.labelSize = BrotherModel.getLabelSize(from: call.getString("labelName", "rollW62"))
10
+ printSettings.numCopies = UInt(call.getInt("numberOfCopies", 1))
11
+
12
+ if let autoCut = call.getBool("autoCut") ?? nil {
13
+ printSettings.autoCut = autoCut
14
+ }
15
+
16
+ if let scaleMode = call.getString("scaleMode") ?? nil {
17
+ switch scaleMode {
18
+ case "ActualSize":
19
+ printSettings.scaleMode = BRLMPrintSettingsScaleMode.actualSize
20
+ case "FitPageAspect":
21
+ printSettings.scaleMode = BRLMPrintSettingsScaleMode.fitPageAspect
22
+ case "FitPaperAspect":
23
+ printSettings.scaleMode = BRLMPrintSettingsScaleMode.fitPaperAspect
24
+ case "ScaleValue":
25
+ printSettings.scaleMode = BRLMPrintSettingsScaleMode.scaleValue
26
+ if call.getInt("scaleValue") != nil {
27
+ printSettings.scaleValue = CGFloat(call.getFloat("scaleValue")!)
28
+ }
29
+ default: break
30
+ }
31
+ }
32
+
33
+ if let halftone = call.getString("halftone") ?? nil {
34
+ switch halftone {
35
+ case "Threshold":
36
+ printSettings.halftone = BRLMPrintSettingsHalftone.threshold
37
+ if call.getInt("halftoneThreshold") != nil {
38
+ printSettings.halftoneThreshold = UInt8(call.getInt("halftoneThreshold")!)
39
+ }
40
+ case "ErrorDiffusion":
41
+ printSettings.halftone = BRLMPrintSettingsHalftone.errorDiffusion
42
+ case "PatternDither":
43
+ printSettings.halftone = BRLMPrintSettingsHalftone.patternDither
44
+ default: break
45
+ }
46
+ }
47
+
48
+ if let imageRotation = call.getString("imageRotation") ?? nil {
49
+ switch imageRotation {
50
+ case "Rotate0":
51
+ printSettings.imageRotation = BRLMPrintSettingsRotation.rotate0
52
+ case "Rotate90":
53
+ printSettings.imageRotation = BRLMPrintSettingsRotation.rotate90
54
+ case "Rotate180":
55
+ printSettings.imageRotation = BRLMPrintSettingsRotation.rotate180
56
+ case "Rotate270":
57
+ printSettings.imageRotation = BRLMPrintSettingsRotation.rotate270
58
+ default: break
59
+ }
60
+ }
61
+
62
+ if let verticalAlignment = call.getString("verticalAlignment") ?? nil {
63
+ switch verticalAlignment {
64
+ case "Top":
65
+ printSettings.vAlignment = BRLMPrintSettingsVerticalAlignment.top
66
+ case "Center":
67
+ printSettings.vAlignment = BRLMPrintSettingsVerticalAlignment.center
68
+ case "Bottom":
69
+ printSettings.vAlignment = BRLMPrintSettingsVerticalAlignment.bottom
70
+ default: break
71
+ }
72
+ }
73
+
74
+ if let horizontalAlignment = call.getString("horizontalAlignment") ?? nil {
75
+ switch horizontalAlignment {
76
+ case "Left":
77
+ printSettings.hAlignment = BRLMPrintSettingsHorizontalAlignment.left
78
+ case "Center":
79
+ printSettings.hAlignment = BRLMPrintSettingsHorizontalAlignment.center
80
+ case "Right":
81
+ printSettings.hAlignment = BRLMPrintSettingsHorizontalAlignment.right
82
+ default: break
83
+ }
84
+ }
85
+
86
+ if let compressMode = call.getString("compressMode") ?? nil {
87
+ switch compressMode {
88
+ case "None":
89
+ printSettings.compress = BRLMPrintSettingsCompressMode.none
90
+ case "Tiff":
91
+ printSettings.compress = BRLMPrintSettingsCompressMode.tiff
92
+ case "Mode9":
93
+ printSettings.compress = BRLMPrintSettingsCompressMode.mode9
94
+ default: break
95
+ }
96
+ }
97
+
98
+ if let printQuality = call.getString("printQuality") ?? nil {
99
+ switch printQuality {
100
+ case "Best":
101
+ printSettings.printQuality = BRLMPrintSettingsPrintQuality.best
102
+ case "Fast":
103
+ printSettings.printQuality = BRLMPrintSettingsPrintQuality.fast
104
+ default: break
105
+ }
106
+ }
107
+
108
+ if let resolution = call.getString("resolution") ?? nil {
109
+ switch resolution {
110
+ case "Low":
111
+ printSettings.resolution = BRLMPrintSettingsResolution.high
112
+ case "Normal":
113
+ printSettings.resolution = BRLMPrintSettingsResolution.normal
114
+ case "High":
115
+ printSettings.resolution = BRLMPrintSettingsResolution.high
116
+ default: break
117
+ }
118
+ }
119
+
120
+ return printSettings
121
+ }
122
+ }
@@ -26,10 +26,8 @@ public class BrotherPrint: CAPPlugin {
26
26
  let localName: String = call.getString("localName", "")
27
27
  let ipAddress: String = call.getString("ipAddress", "")
28
28
  let serialNumber: String = call.getString("serialNumber", "")
29
- let autoCut: Bool = call.getBool("autoCut", true)
30
29
 
31
30
  let modelName = BrotherModel.getModelName(from: call.getString("modelName", "QL-820NWB"))
32
- let labelSize = BrotherModel.getLabelSize(from: call.getString("labelName", "rollW62"))
33
31
 
34
32
  NSLog(call.getString("modelName", "not set"))
35
33
  NSLog(call.getString("labelName", "not set"))
@@ -75,7 +73,7 @@ public class BrotherPrint: CAPPlugin {
75
73
  }
76
74
 
77
75
  guard
78
- let printSettings = BRLMQLPrintSettings(defaultPrintSettingsWith: modelName)
76
+ let _printSettings = BRLMQLPrintSettings(defaultPrintSettingsWith: modelName)
79
77
  else {
80
78
  printerDriver.closeChannel()
81
79
  self.notifyListeners(BrotherPrinterEvent.onPrintError.rawValue, data: [
@@ -86,10 +84,7 @@ public class BrotherPrint: CAPPlugin {
86
84
  return
87
85
  }
88
86
 
89
- printSettings.labelSize = labelSize
90
- printSettings.autoCut = autoCut
91
- printSettings.numCopies = UInt(call.getInt("numberOfCopies", 1))
92
-
87
+ let printSettings = PrinterSettingsModel.initialize(call, printSettings: _printSettings)
93
88
  let printError = printerDriver.printImage(with: decodedByte.cgImage!, settings: printSettings)
94
89
 
95
90
  if printError.code != .noError {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdlabo/capacitor-brotherprint",
3
- "version": "6.2.0-0",
3
+ "version": "6.2.0-2",
4
4
  "description": "Capacitor plugin for Brother Print SDK",
5
5
  "main": "dist/plugin.js",
6
6
  "module": "dist/esm/index.js",