Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void onSuccess(List<Barcode> barcodes) {
WritableMap map = Arguments.createMap();
map.putString("value", barcode.getRawValue());
map.putDouble("format", barcode.getFormat());
map.putString("displayValue", barcode.getDisplayValue());
map.putString("rawValue", barcode.getRawValue());
result.pushMap(map);
}
promise.resolve(result);
Expand Down
7 changes: 6 additions & 1 deletion barcode-scanning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export enum BarcodeFormat {

export interface Barcode {
format: BarcodeFormat;
/**
* @deprecated `value` is deprecated and will be removed in a future release please use `displayValue` or `rawValue` instead
*/
value: string;
rawValue: string;
displayValue: string;
}

interface IBarcodeScanning {
Expand All @@ -44,4 +49,4 @@ const BarcodeScanning: IBarcodeScanning = NativeModules.BarcodeScanning
}
);

export default BarcodeScanning;
export default BarcodeScanning;
15 changes: 8 additions & 7 deletions barcode-scanning/ios/BarcodeScanning.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ @implementation BarcodeScanning

RCT_EXPORT_MODULE()

RCT_EXPORT_METHOD(scan
: (nonnull NSString *)url resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(scan:(nonnull NSString *)url
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
NSURL *_url = [NSURL URLWithString:url];
NSData *imageData = [NSData dataWithContentsOfURL:_url];
UIImage *image = [UIImage imageWithData:imageData];
Expand Down Expand Up @@ -40,10 +39,12 @@ @implementation BarcodeScanning
default:
format = @(barcode.format);
}

[result addObject:@{
@"value": barcode.displayValue,
@"format": format
@"value" : barcode.displayValue,
@"format" : format,
@"rawValue" : barcode.rawValue,
@"displayValue" : barcode.displayValue
}];
}

Expand Down
8 changes: 5 additions & 3 deletions example/src/barcode-scanning/BarcodeScanningScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ const BarcodeScanningScreen = () => {
<FlatList
data={barcodes}
style={styles.list}
keyExtractor={barcode => `${barcode.format}-${barcode.value}`}
renderItem={({item}) => (
keyExtractor={barcode =>
`${barcode.format}-${barcode.displayValue}-${barcode.rawValue}`
}
renderItem={({ item }) => (
<LabelTile>
{item.value} - {item.format}
{JSON.stringify(item, undefined, 2)}
</LabelTile>
)}
/>
Expand Down