Skip to content

Commit 59d9fc5

Browse files
committed
fix: use defaults where needed
1 parent 0dd4950 commit 59d9fc5

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

example-app/ios/App/App.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@
349349
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
350350
CODE_SIGN_STYLE = Automatic;
351351
CURRENT_PROJECT_VERSION = 1;
352+
DEVELOPMENT_TEAM = 9YN2HU59K8;
352353
INFOPLIST_FILE = App/Info.plist;
353354
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
354355
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -369,6 +370,7 @@
369370
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
370371
CODE_SIGN_STYLE = Automatic;
371372
CURRENT_PROJECT_VERSION = 1;
373+
DEVELOPMENT_TEAM = 9YN2HU59K8;
372374
INFOPLIST_FILE = App/Info.plist;
373375
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
374376
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

example-app/ios/App/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PODS:
33
- CapacitorCordova
44
- CapacitorApp (6.0.0):
55
- Capacitor
6-
- CapacitorBarcodeScanner (1.0.0-alpha.0):
6+
- CapacitorBarcodeScanner (1.0.0):
77
- Capacitor
88
- OSBarcodeLib (~> 1.1.0)
99
- CapacitorCordova (6.0.0)
@@ -47,7 +47,7 @@ EXTERNAL SOURCES:
4747
SPEC CHECKSUMS:
4848
Capacitor: 559d073c4ca6c27f8e7002c807eea94c3ba435a9
4949
CapacitorApp: 9d53aec7101f7b030a950c5bdc4df8612576b279
50-
CapacitorBarcodeScanner: 80444aa11d911dac09a6af454560db735de81ee6
50+
CapacitorBarcodeScanner: 3780aa09a86e526b2903d3b804bd867100f4c924
5151
CapacitorCordova: 8c4bfdf69368512e85b1d8b724dd7546abeb30af
5252
CapacitorHaptics: 9ebc9363f0e9b8eb4295088a0b474530acf1859b
5353
CapacitorKeyboard: deacbd09d8d1029c3681197fb05d206b721d5f73

example-app/src/pages/Home.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
import { IonButton, IonContent, IonHeader, IonInput, IonPage, IonTitle, IonToolbar } from '@ionic/react';
22
import './Home.css';
33
import { useState } from 'react';
4-
import { CapacitorBarcodeScanner, CapacitorBarcodeScannerTypeHint, CapacitorBarcodeScannerCameraDirection, CapacitorBarcodeScannerScanOrientation, CapacitorBarcodeScannerAndroidScanningLibrary } from '@capacitor/barcode-scanner';
4+
import { CapacitorBarcodeScanner, CapacitorBarcodeScannerTypeHint } from '@capacitor/barcode-scanner';
55

66
const Home: React.FC = () => {
77
const [scannerResult, setScannerResult] = useState<string>('No Data...');
88

99
const scanBarcode = async () => {
1010
const result = await CapacitorBarcodeScanner.scanBarcode({
11-
hint: CapacitorBarcodeScannerTypeHint.ALL,
12-
scanInstructions: 'Hold your device over the barcode to scan.',
13-
scanButton: true, // TODO: Not implemented yet in the web implementation
14-
scanText: 'Press To Start Scanning', // TODO: Not implemented yet in the web implementation
15-
cameraDirection: CapacitorBarcodeScannerCameraDirection.BACK,
16-
scanOrientation: CapacitorBarcodeScannerScanOrientation.ADAPTIVE, // TODO: Not implemented yet in the web implementation
17-
android: {
18-
scanningLibrary: CapacitorBarcodeScannerAndroidScanningLibrary.MLKIT,
19-
},
20-
web: {
21-
showCameraSelection: false, // TODO: Not implemented yet in the web implementation
22-
scannerFPS: 30
23-
}
11+
hint: CapacitorBarcodeScannerTypeHint.ALL
2412
});
2513
setScannerResult(result.ScanResult);
2614
};

plugin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Defines the structure of the result returned from a barcode scan.
8080

8181
Defines the options for configuring a barcode scan.
8282

83-
<code>{ hint: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>, scanInstructions?: string, scanButton?: boolean, scanText?: string, cameraDirection?: <a href="#capacitorbarcodescannercameradirection">CapacitorBarcodeScannerCameraDirection</a>, scanOrientation?: <a href="#capacitorbarcodescannerscanorientation">CapacitorBarcodeScannerScanOrientation</a>, android?: { scanningLibrary?: <a href="#capacitorbarcodescannerandroidscanninglibrary">CapacitorBarcodeScannerAndroidScanningLibrary</a>, }, web?: { showCameraSelection?: boolean, scannerFPS?: number } }</code>
83+
<code>{ hint: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>; scanInstructions?: string; scanButton?: boolean; scanText?: string; cameraDirection?: <a href="#capacitorbarcodescannercameradirection">CapacitorBarcodeScannerCameraDirection</a>; scanOrientation?: <a href="#capacitorbarcodescannerscanorientation">CapacitorBarcodeScannerScanOrientation</a>; android?: { scanningLibrary?: <a href="#capacitorbarcodescannerandroidscanninglibrary">CapacitorBarcodeScannerAndroidScanningLibrary</a>; }; web?: { showCameraSelection?: boolean; scannerFPS?: number; }; }</code>
8484

8585

8686
#### CapacitorBarcodeScannerTypeHint

plugin/src/index.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
import { registerPlugin } from '@capacitor/core';
22

3-
import type { CapacitorBarcodeScannerPlugin } from './definitions'; // Importing the interface for type checking.
3+
import {
4+
CapacitorBarcodeScannerCameraDirection,
5+
CapacitorBarcodeScannerScanOrientation,
6+
type CapacitorBarcodeScannerOptions,
7+
type CapacitorBarcodeScannerPlugin,
8+
type CapacitorBarcodeScannerScanResult,
9+
} from './definitions'; // Importing the interface for type checking.
410
import { applyCss, barcodeScannerCss } from './utils'; // Import utilities for applying CSS.
511

612
/**
713
* Registers the `OSBarcode` plugin with Capacitor.
814
* For web platforms, it applies necessary CSS for the barcode scanner and dynamically imports the web implementation.
915
* This allows for lazy loading of the web code only when needed, optimizing overall bundle size.
1016
*/
11-
const CapacitorBarcodeScanner = registerPlugin<CapacitorBarcodeScannerPlugin>('CapacitorBarcodeScanner', {
17+
const CapacitorBarcodeScannerImpl = registerPlugin<CapacitorBarcodeScannerPlugin>('CapacitorBarcodeScanner', {
1218
web: () => {
1319
applyCss(barcodeScannerCss); // Apply the CSS styles necessary for the web implementation of the barcode scanner.
1420
return import('./web').then((m) => new m.CapacitorBarcodeScannerWeb()); // Dynamically import the web implementation and instantiate it.
1521
},
1622
});
1723

24+
class CapacitorBarcodeScanner {
25+
public static async scanBarcode(options: CapacitorBarcodeScannerOptions): Promise<CapacitorBarcodeScannerScanResult> {
26+
options.scanInstructions = options.scanInstructions || ' '; // Ensure scanInstructions is at least a space.
27+
options.scanButton = options.scanButton || false; // Set scanButton to false if not provided.
28+
options.scanText = options.scanText || ' '; // Ensure scanText is at least a space.
29+
options.cameraDirection = options.cameraDirection || CapacitorBarcodeScannerCameraDirection.BACK; // Set cameraDirection to 'BACK' if not provided.
30+
options.scanOrientation = options.scanOrientation || CapacitorBarcodeScannerScanOrientation.ADAPTIVE; // Set scanOrientation to 'ADAPTIVE' if not provided.
31+
return CapacitorBarcodeScannerImpl.scanBarcode(options);
32+
}
33+
}
34+
35+
export { CapacitorBarcodeScanner }; // Export the `CapacitorBarcodeScanner` class.
1836
export * from './definitions'; // Re-export all exports from the definitions file.
19-
export { CapacitorBarcodeScanner }; // Export the OSBarcode plugin for use in Capacitor projects.

0 commit comments

Comments
 (0)