@rdlabo/capacitor-brotherprint 8.2.1 → 8.2.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.
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +6 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/plugin.cjs.js +6 -8
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +6 -8
- package/dist/plugin.js.map +1 -1
- package/docs/connection-management.md +80 -44
- package/docs/helper-design.md +20 -4
- package/ios/Sources/BrotherPrintPlugin/BrotherPrintPlugin.swift +4 -4
- package/ios/Sources/BrotherPrintPlugin/Model/PrinterModel.swift +38 -68
- package/ios/Sources/BrotherPrintPlugin/Model/PrinterSettingsModel.swift +61 -65
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import Capacitor
|
|
|
4
4
|
|
|
5
5
|
class PrinterSettingsModel {
|
|
6
6
|
static func TDModelSettings(_ call: CAPPluginCall, printSettings: BRLMTDPrintSettings) -> BRLMTDPrintSettings {
|
|
7
|
-
let baseSettings = self.
|
|
7
|
+
let baseSettings = self.baseModelSettings(call, printSettings: printSettings)
|
|
8
8
|
|
|
9
9
|
let margins = BrotherModel.getMargin(call.getDouble("marginTop", 0), call.getDouble("marginRight", 0), call.getDouble("marginBottom", 0), call.getDouble("marginLeft", 0))
|
|
10
10
|
|
|
@@ -33,7 +33,7 @@ class PrinterSettingsModel {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
static func QLModelSettings(_ call: CAPPluginCall, printSettings: BRLMQLPrintSettings) -> BRLMQLPrintSettings {
|
|
36
|
-
let baseSettings = self.
|
|
36
|
+
let baseSettings = self.baseModelSettings(call, printSettings: printSettings)
|
|
37
37
|
baseSettings.labelSize = BrotherModel.getLabelSize(from: call.getString("labelName", "rollW62"))
|
|
38
38
|
|
|
39
39
|
if let autoCut = call.getBool("autoCut") ?? nil {
|
|
@@ -47,98 +47,94 @@ class PrinterSettingsModel {
|
|
|
47
47
|
return baseSettings
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
static func
|
|
50
|
+
static func baseModelSettings<T: BRLMPrintImageSettings>(_ call: CAPPluginCall, printSettings: T) -> T {
|
|
51
51
|
printSettings.numCopies = UInt(call.getInt("numberOfCopies", 1))
|
|
52
52
|
|
|
53
|
+
let scaleModes: [String: BRLMPrintSettingsScaleMode] = [
|
|
54
|
+
"ActualSize": .actualSize,
|
|
55
|
+
"FitPageAspect": .fitPageAspect,
|
|
56
|
+
"FitPaperAspect": .fitPaperAspect,
|
|
57
|
+
"ScaleValue": .scaleValue
|
|
58
|
+
]
|
|
53
59
|
if let scaleMode = call.getString("scaleMode") ?? nil {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
printSettings.scaleMode = BRLMPrintSettingsScaleMode.fitPaperAspect
|
|
61
|
-
case "ScaleValue":
|
|
62
|
-
printSettings.scaleMode = BRLMPrintSettingsScaleMode.scaleValue
|
|
63
|
-
if call.getInt("scaleValue") != nil {
|
|
64
|
-
printSettings.scaleValue = CGFloat(call.getFloat("scaleValue")!)
|
|
60
|
+
if let mapped = scaleModes[scaleMode] {
|
|
61
|
+
printSettings.scaleMode = mapped
|
|
62
|
+
if scaleMode == "ScaleValue" {
|
|
63
|
+
if call.getInt("scaleValue") != nil {
|
|
64
|
+
printSettings.scaleValue = CGFloat(call.getFloat("scaleValue")!)
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
|
-
default: break
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
let halftones: [String: BRLMPrintSettingsHalftone] = [
|
|
71
|
+
"Threshold": .threshold,
|
|
72
|
+
"ErrorDiffusion": .errorDiffusion,
|
|
73
|
+
"PatternDither": .patternDither
|
|
74
|
+
]
|
|
70
75
|
if let halftone = call.getString("halftone") ?? nil {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
if let mapped = halftones[halftone] {
|
|
77
|
+
printSettings.halftone = mapped
|
|
78
|
+
if halftone == "Threshold" {
|
|
79
|
+
if call.getInt("halftoneThreshold") != nil {
|
|
80
|
+
printSettings.halftoneThreshold = UInt8(call.getInt("halftoneThreshold")!)
|
|
81
|
+
}
|
|
76
82
|
}
|
|
77
|
-
case "ErrorDiffusion":
|
|
78
|
-
printSettings.halftone = BRLMPrintSettingsHalftone.errorDiffusion
|
|
79
|
-
case "PatternDither":
|
|
80
|
-
printSettings.halftone = BRLMPrintSettingsHalftone.patternDither
|
|
81
|
-
default: break
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
let imageRotations: [String: BRLMPrintSettingsRotation] = [
|
|
87
|
+
"Rotate0": .rotate0,
|
|
88
|
+
"Rotate90": .rotate90,
|
|
89
|
+
"Rotate180": .rotate180,
|
|
90
|
+
"Rotate270": .rotate270
|
|
91
|
+
]
|
|
85
92
|
if let imageRotation = call.getString("imageRotation") ?? nil {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
printSettings.imageRotation = BRLMPrintSettingsRotation.rotate0
|
|
89
|
-
case "Rotate90":
|
|
90
|
-
printSettings.imageRotation = BRLMPrintSettingsRotation.rotate90
|
|
91
|
-
case "Rotate180":
|
|
92
|
-
printSettings.imageRotation = BRLMPrintSettingsRotation.rotate180
|
|
93
|
-
case "Rotate270":
|
|
94
|
-
printSettings.imageRotation = BRLMPrintSettingsRotation.rotate270
|
|
95
|
-
default: break
|
|
93
|
+
if let mapped = imageRotations[imageRotation] {
|
|
94
|
+
printSettings.imageRotation = mapped
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
|
|
98
|
+
let verticalAlignments: [String: BRLMPrintSettingsVerticalAlignment] = [
|
|
99
|
+
"Top": .top,
|
|
100
|
+
"Center": .center,
|
|
101
|
+
"Bottom": .bottom
|
|
102
|
+
]
|
|
99
103
|
if let verticalAlignment = call.getString("verticalAlignment") ?? nil {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
printSettings.vAlignment = BRLMPrintSettingsVerticalAlignment.top
|
|
103
|
-
case "Center":
|
|
104
|
-
printSettings.vAlignment = BRLMPrintSettingsVerticalAlignment.center
|
|
105
|
-
case "Bottom":
|
|
106
|
-
printSettings.vAlignment = BRLMPrintSettingsVerticalAlignment.bottom
|
|
107
|
-
default: break
|
|
104
|
+
if let mapped = verticalAlignments[verticalAlignment] {
|
|
105
|
+
printSettings.vAlignment = mapped
|
|
108
106
|
}
|
|
109
107
|
}
|
|
110
108
|
|
|
109
|
+
let horizontalAlignments: [String: BRLMPrintSettingsHorizontalAlignment] = [
|
|
110
|
+
"Left": .left,
|
|
111
|
+
"Center": .center,
|
|
112
|
+
"Right": .right
|
|
113
|
+
]
|
|
111
114
|
if let horizontalAlignment = call.getString("horizontalAlignment") ?? nil {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
printSettings.hAlignment = BRLMPrintSettingsHorizontalAlignment.left
|
|
115
|
-
case "Center":
|
|
116
|
-
printSettings.hAlignment = BRLMPrintSettingsHorizontalAlignment.center
|
|
117
|
-
case "Right":
|
|
118
|
-
printSettings.hAlignment = BRLMPrintSettingsHorizontalAlignment.right
|
|
119
|
-
default: break
|
|
115
|
+
if let mapped = horizontalAlignments[horizontalAlignment] {
|
|
116
|
+
printSettings.hAlignment = mapped
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
119
|
|
|
120
|
+
let compressModes: [String: BRLMPrintSettingsCompressMode] = [
|
|
121
|
+
"None": .none,
|
|
122
|
+
"Tiff": .tiff,
|
|
123
|
+
"Mode9": .mode9
|
|
124
|
+
]
|
|
123
125
|
if let compressMode = call.getString("compressMode") ?? nil {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
printSettings.compress = BRLMPrintSettingsCompressMode.none
|
|
127
|
-
case "Tiff":
|
|
128
|
-
printSettings.compress = BRLMPrintSettingsCompressMode.tiff
|
|
129
|
-
case "Mode9":
|
|
130
|
-
printSettings.compress = BRLMPrintSettingsCompressMode.mode9
|
|
131
|
-
default: break
|
|
126
|
+
if let mapped = compressModes[compressMode] {
|
|
127
|
+
printSettings.compress = mapped
|
|
132
128
|
}
|
|
133
129
|
}
|
|
134
130
|
|
|
131
|
+
let printQualities: [String: BRLMPrintSettingsPrintQuality] = [
|
|
132
|
+
"Best": .best,
|
|
133
|
+
"Fast": .fast
|
|
134
|
+
]
|
|
135
135
|
if let printQuality = call.getString("printQuality") ?? nil {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
printSettings.printQuality = BRLMPrintSettingsPrintQuality.best
|
|
139
|
-
case "Fast":
|
|
140
|
-
printSettings.printQuality = BRLMPrintSettingsPrintQuality.fast
|
|
141
|
-
default: break
|
|
136
|
+
if let mapped = printQualities[printQuality] {
|
|
137
|
+
printSettings.printQuality = mapped
|
|
142
138
|
}
|
|
143
139
|
}
|
|
144
140
|
|