-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added code format to see type of code scanned (#633)
* added code format to see type of code scanned * Update ios/ReactNativeCameraKit/SimulatorCamera.swift Changed supported barcode types to list of CodeFormat Co-authored-by: David Bertet <[email protected]> * Update android/src/main/java/com/rncamerakit/CodeFormat.kt Added annotation for int type Co-authored-by: David Bertet <[email protected]> * Added CodeFormat types and fixed an indentation on a function to match other functions * Replaced AVMetadataObject with CodeFormat in all files * Updated code format to case Iterable and changed supportedBarcodeType to code format cases * Update src/Camera.d.ts --------- Co-authored-by: David Bertet <[email protected]> Co-authored-by: Seph Soliman <[email protected]>
- Loading branch information
1 parent
6c5ae90
commit 234e7f8
Showing
12 changed files
with
172 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.rncamerakit | ||
|
||
import com.google.mlkit.vision.barcode.common.Barcode | ||
|
||
enum class CodeFormat(val code: String) { | ||
CODE_128("code-128"), | ||
CODE_39("code-39"), | ||
CODE_93("code-93"), | ||
CODABAR("codabar"), | ||
EAN_13("ean-13"), | ||
EAN_8("ean-8"), | ||
ITF("itf"), | ||
UPC_E("upc-e"), | ||
QR("qr"), | ||
PDF_417("pdf-417"), | ||
AZTEC("aztec"), | ||
DATA_MATRIX("data-matrix"), | ||
UNKNOWN("unknown"); | ||
|
||
fun toBarcodeType(): Int { | ||
return when (this) { | ||
CODE_128 -> Barcode.FORMAT_CODE_128 | ||
CODE_39 -> Barcode.FORMAT_CODE_39 | ||
CODE_93 -> Barcode.FORMAT_CODE_93 | ||
CODABAR -> Barcode.FORMAT_CODABAR | ||
EAN_13 -> Barcode.FORMAT_EAN_13 | ||
EAN_8 -> Barcode.FORMAT_EAN_8 | ||
ITF -> Barcode.FORMAT_ITF | ||
UPC_E -> Barcode.FORMAT_UPC_E | ||
QR -> Barcode.FORMAT_QR_CODE | ||
PDF_417 -> Barcode.FORMAT_PDF417 | ||
AZTEC -> Barcode.FORMAT_AZTEC | ||
DATA_MATRIX -> Barcode.FORMAT_DATA_MATRIX | ||
UNKNOWN -> -1 // Or any other default value you prefer | ||
} | ||
} | ||
|
||
companion object { | ||
fun fromBarcodeType(@Barcode.BarcodeFormat barcodeType: Int): CodeFormat = | ||
when (barcodeType) { | ||
Barcode.FORMAT_CODE_128 -> CODE_128 | ||
Barcode.FORMAT_CODE_39 -> CODE_39 | ||
Barcode.FORMAT_CODE_93 -> CODE_93 | ||
Barcode.FORMAT_CODABAR -> CODABAR | ||
Barcode.FORMAT_EAN_13 -> EAN_13 | ||
Barcode.FORMAT_EAN_8 -> EAN_8 | ||
Barcode.FORMAT_ITF -> ITF | ||
Barcode.FORMAT_UPC_E -> UPC_E | ||
Barcode.FORMAT_QR_CODE -> QR | ||
Barcode.FORMAT_PDF417 -> PDF_417 | ||
Barcode.FORMAT_AZTEC -> AZTEC | ||
Barcode.FORMAT_DATA_MATRIX -> DATA_MATRIX | ||
else -> UNKNOWN | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// CodeFormat.swift | ||
// ReactNativeCameraKit | ||
// | ||
// Created by Imdad on 2023-12-22. | ||
// | ||
|
||
import Foundation | ||
import AVFoundation | ||
|
||
enum CodeFormat: String, CaseIterable { | ||
case code128 = "code-128" | ||
case code39 = "code-39" | ||
case code93 = "code-93" | ||
case ean13 = "ean-13" | ||
case ean8 = "ean-8" | ||
case itf14 = "itf-14" | ||
case upce = "upc-e" | ||
case qr = "qr" | ||
case pdf417 = "pdf-417" | ||
case aztec = "aztec" | ||
case dataMatrix = "data-matrix" | ||
case unknown = "unknown" | ||
|
||
// Convert from AVMetadataObject.ObjectType to CodeFormat | ||
static func fromAVMetadataObjectType(_ type: AVMetadataObject.ObjectType) -> CodeFormat { | ||
switch type { | ||
case .code128: return .code128 | ||
case .code39: return .code39 | ||
case .code93: return .code93 | ||
case .ean13: return .ean13 | ||
case .ean8: return .ean8 | ||
case .itf14: return .itf14 | ||
case .upce: return .upce | ||
case .qr: return .qr | ||
case .pdf417: return .pdf417 | ||
case .aztec: return .aztec | ||
case .dataMatrix: return .dataMatrix | ||
default: return .unknown | ||
} | ||
} | ||
|
||
// Convert from CodeFormat to AVMetadataObject.ObjectType | ||
func toAVMetadataObjectType() -> AVMetadataObject.ObjectType { | ||
switch self { | ||
case .code128: return .code128 | ||
case .code39: return .code39 | ||
case .code93: return .code93 | ||
case .ean13: return .ean13 | ||
case .ean8: return .ean8 | ||
case .itf14: return .itf14 | ||
case .upce: return .upce | ||
case .qr: return .qr | ||
case .pdf417: return .pdf417 | ||
case .aztec: return .aztec | ||
case .dataMatrix: return .dataMatrix | ||
case .unknown: return .init(rawValue: "unknown") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.