Skip to content

Commit b152d94

Browse files
committed
fmt
1 parent 9097b9b commit b152d94

File tree

5 files changed

+50
-37
lines changed

5 files changed

+50
-37
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ let package = Package(
2525
dependencies: ["CodeScannerPlugin"],
2626
path: "ios/Tests/CodeScannerPluginTests")
2727
]
28-
)
28+
)

ios/Sources/CodeScannerPlugin/CodeScannerPlugin.swift

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import AVFoundation
88
*/
99
@objc(CodeScannerPlugin)
1010
public class CodeScannerPlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegate, CAPBridgedPlugin {
11-
public let identifier = "CodeScannerPlugin"
12-
public let jsName = "CodeScanner"
11+
public let identifier = "CodeScannerPlugin"
12+
public let jsName = "CodeScanner"
1313
public let pluginMethods: [CAPPluginMethod] = [
14-
CAPPluginMethod(name: "present", returnType: CAPPluginReturnPromise),
15-
]
16-
// セッションのインスタンス生成
14+
CAPPluginMethod(name: "present", returnType: CAPPluginReturnPromise)
15+
]
16+
// セッションのインスタンス生成
1717
let captureSession = AVCaptureSession()
1818
var videoLayer: AVCaptureVideoPreviewLayer?
1919

@@ -101,7 +101,7 @@ public class CodeScannerPlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegat
101101
}
102102

103103
metadataOutput.metadataObjectTypes = metadataObjectTypes
104-
metadataOutput.rectOfInterest = CGRect(x: y,y: 1-x-width,width: height,height: width)
104+
metadataOutput.rectOfInterest = CGRect(x: y, y: 1-x-width, width: height, height: width)
105105
self.isReady = true
106106
}
107107

@@ -147,7 +147,6 @@ public class CodeScannerPlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegat
147147
let closeGesture = UITapGestureRecognizer(target: self, action: #selector(self.closeGesture))
148148
btnClose.addGestureRecognizer(closeGesture)
149149

150-
151150
DispatchQueue.global(qos: .userInitiated).async {
152151
if !self.captureSession.isRunning {
153152
self.captureSession.startRunning()
@@ -160,8 +159,7 @@ public class CodeScannerPlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegat
160159
}
161160
}
162161

163-
164-
@objc func closeGesture(sender:UITapGestureRecognizer) {
162+
@objc func closeGesture(sender: UITapGestureRecognizer) {
165163
self.closeCamera()
166164
}
167165

@@ -177,7 +175,6 @@ public class CodeScannerPlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegat
177175
}
178176
}
179177

180-
181178
public func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
182179
for metadata in metadataObjects as! [AVMetadataMachineReadableCodeObject] {
183180
// コード内容の確認
@@ -200,26 +197,25 @@ public class CodeScannerPlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegat
200197
}
201198
}
202199

203-
204200
public func toggleLight(launch: Bool) {
205201
DispatchQueue.main.async {
206-
let avCaptureDevice = AVCaptureDevice.default(for: AVMediaType.video)
207-
if avCaptureDevice!.hasTorch, avCaptureDevice!.isTorchAvailable {
208-
do {
209-
try avCaptureDevice!.lockForConfiguration()
210-
211-
if (launch) {
212-
print("light launch")
213-
avCaptureDevice!.torchMode = .on
214-
} else {
215-
print("light dissmiss")
216-
avCaptureDevice!.torchMode = .off
202+
let avCaptureDevice = AVCaptureDevice.default(for: AVMediaType.video)
203+
if avCaptureDevice!.hasTorch, avCaptureDevice!.isTorchAvailable {
204+
do {
205+
try avCaptureDevice!.lockForConfiguration()
206+
207+
if launch {
208+
print("light launch")
209+
avCaptureDevice!.torchMode = .on
210+
} else {
211+
print("light dissmiss")
212+
avCaptureDevice!.torchMode = .off
213+
}
214+
avCaptureDevice!.unlockForConfiguration()
215+
} catch let error {
216+
print(error)
217217
}
218-
avCaptureDevice!.unlockForConfiguration()
219-
} catch let error {
220-
print(error)
221218
}
222-
}
223219
}
224-
}
220+
}
225221
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"verify:android": "cd android && ./gradlew clean build test && cd ..",
3737
"verify:web": "npm run build",
3838
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
39-
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- autocorrect --format",
39+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
4040
"eslint": "eslint . --ext ts",
4141
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
4242
"swiftlint": "node-swiftlint",

src/definitions.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,36 @@ import type { PluginListenerHandle } from '@capacitor/core';
22

33
export interface CodeScannerPlugin {
44
present(scannerOption: ScannerOption): Promise<void>;
5-
addListener(eventName: 'CodeScannerCatchEvent', listenerFunc: (event: {
6-
code: string;
7-
}) => void): Promise<PluginListenerHandle>;
5+
addListener(
6+
eventName: 'CodeScannerCatchEvent',
7+
listenerFunc: (event: { code: string }) => void,
8+
): Promise<PluginListenerHandle>;
89
}
910

10-
export type MetadataObjectTypes = 'aztec' | 'code128' | 'code39' | 'code39Mod43' | 'code93' | 'dataMatrix'
11-
| 'ean13' | 'ean8' | 'face' | 'interleaved2of5' | 'itf14' | 'pdf417'
12-
| 'qr' | 'upce' | 'catBody' | 'dogBody' | 'humanBody' | 'salientObject';
11+
export type MetadataObjectTypes =
12+
| 'aztec'
13+
| 'code128'
14+
| 'code39'
15+
| 'code39Mod43'
16+
| 'code93'
17+
| 'dataMatrix'
18+
| 'ean13'
19+
| 'ean8'
20+
| 'face'
21+
| 'interleaved2of5'
22+
| 'itf14'
23+
| 'pdf417'
24+
| 'qr'
25+
| 'upce'
26+
| 'catBody'
27+
| 'dogBody'
28+
| 'humanBody'
29+
| 'salientObject';
1330

1431
export interface ScannerOption {
1532
detectionX?: number;
1633
detectionY?: number;
1734
detectionWidth?: number;
1835
detectionHeight?: number;
19-
metadataObjectTypes?: MetadataObjectTypes[]
36+
metadataObjectTypes?: MetadataObjectTypes[];
2037
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { registerPlugin } from '@capacitor/core';
33
import type { CodeScannerPlugin } from './definitions';
44

55
const CodeScanner = registerPlugin<CodeScannerPlugin>('CodeScanner', {
6-
web: () => import('./web').then(m => new m.CodeScannerWeb()),
6+
web: () => import('./web').then((m) => new m.CodeScannerWeb()),
77
});
88

99
export * from './definitions';

0 commit comments

Comments
 (0)