Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add types #505

Merged
merged 1 commit into from
May 22, 2023
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
2 changes: 1 addition & 1 deletion docs/kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Add the `kotlin_version` to `buildscript.ext`
buildscript {
ext {
...
kotlin_version = '1.5.10'
kotlin_version = '1.7.20'
}
```

Expand Down
2 changes: 1 addition & 1 deletion example/ios/CameraKitExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-CameraKitExample/Pods-CameraKitExample-frameworks.sh",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL/OpenSSL.framework/OpenSSL",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ PODS:
- React-Core (= 0.63.4)
- React-cxxreact (= 0.63.4)
- React-jsi (= 0.63.4)
- ReactNativeCameraKit (11.2.0):
- ReactNativeCameraKit (13.0.0):
- React-Core
- Yoga (1.14.0)
- YogaKit (1.18.1):
Expand Down Expand Up @@ -458,10 +458,10 @@ SPEC CHECKSUMS:
React-RCTText: 5c51df3f08cb9dedc6e790161195d12bac06101c
React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d
ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
ReactNativeCameraKit: c25ef4c32abd8918578a9ece01c90233f478c97c
ReactNativeCameraKit: 9d46a5d7dd544ca64aa9c03c150d2348faf437eb
Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: f9ef8a8a0dbf13b0a1ceaa5b4c54937559d74e9e

COCOAPODS: 1.10.1
COCOAPODS: 1.11.3
242 changes: 129 additions & 113 deletions src/CameraScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Platform,
SafeAreaView,
ImageStyle,
ImageSourcePropType,
} from 'react-native';
import _ from 'lodash';
import Camera from './Camera';
Expand All @@ -22,44 +23,61 @@ const { width, height } = Dimensions.get('window');

export enum CameraType {
Front = 'front',
Back = 'back'
Back = 'back',
}

export type ActionsT = {
leftButtonText?: string;
rightButtonText?: string;
};

export type CameraRatioOverlayT = {
ratios: string[];
};

export type FlashImagesT = {
on: number | string;
off: number | string;
auto: number | string;
};

export type Props = {
focusMode?: string,
zoomMode?: string,
ratioOverlay?: string,
ratioOverlayColor?: string,
allowCaptureRetake: boolean,
cameraRatioOverlay: any,
showCapturedImageCount?: boolean,
captureButtonImage: any,
captureButtonImageStyle: ImageStyle,
cameraFlipImage: any,
cameraFlipImageStyle: ImageStyle,
hideControls: any,
showFrame: any,
scanBarcode: any,
laserColor: any,
frameColor: any,
torchOnImage: any,
torchOffImage: any,

torchImageStyle: ImageStyle,
onReadCode: (event: any) => void;
onBottomButtonPressed: (event: any) => void;
}
actions?: ActionsT;
flashImages?: FlashImagesT;
focusMode?: string;
zoomMode?: string;
ratioOverlay?: string;
ratioOverlayColor?: string;
allowCaptureRetake?: boolean;
cameraRatioOverlay?: CameraRatioOverlayT;
showCapturedImageCount?: boolean;
captureButtonImage?: ImageSourcePropType;
captureButtonImageStyle?: ImageStyle;
cameraFlipImage?: ImageSourcePropType;
cameraFlipImageStyle?: ImageStyle;
hideControls?: boolean;
showFrame?: boolean;
scanBarcode?: boolean;
laserColor?: string;
frameColor?: string;
torchOnImage?: any;
torchOffImage?: any;
cameraType?: CameraType;
torchImageStyle?: ImageStyle;
onReadCode?: (event: any) => void;
onBottomButtonPressed?: (event: any) => void;
};

type State = {
captureImages: any[],
flashData: any,
torchMode: boolean,
ratios: any[],
ratioArrayPosition: number,
imageCaptured: any,
captured: boolean,
cameraType: CameraType,
}
captureImages: any[];
flashData: any;
torchMode: boolean;
ratios: any[];
ratioArrayPosition: number;
imageCaptured: any;
captured: boolean;
cameraType: CameraType;
};

export default class CameraScreen extends Component<Props, State> {
static propTypes = {
Expand Down Expand Up @@ -105,7 +123,7 @@ export default class CameraScreen extends Component<Props, State> {
}

componentDidMount() {
let ratios = [];
let ratios: string | any[] = [];
if (this.props.cameraRatioOverlay) {
ratios = this.props.cameraRatioOverlay.ratios || [];
}
Expand All @@ -127,7 +145,7 @@ export default class CameraScreen extends Component<Props, State> {
<Image
style={[{ flex: 1, justifyContent: 'center' }, this.props.torchImageStyle]}
source={this.state.flashData.image}
resizeMode="contain"
resizeMode='contain'
/>
</TouchableOpacity>
)
Expand All @@ -141,7 +159,7 @@ export default class CameraScreen extends Component<Props, State> {
<Image
style={[{ flex: 1, justifyContent: 'center' }, this.props.torchImageStyle]}
source={this.state.torchMode ? this.props.torchOnImage : this.props.torchOffImage}
resizeMode="contain"
resizeMode='contain'
/>
</TouchableOpacity>
)
Expand All @@ -156,7 +174,7 @@ export default class CameraScreen extends Component<Props, State> {
<Image
style={{ flex: 1, justifyContent: 'center' }}
source={this.props.cameraFlipImage}
resizeMode="contain"
resizeMode='contain'
/>
</TouchableOpacity>
)
Expand Down Expand Up @@ -195,7 +213,6 @@ export default class CameraScreen extends Component<Props, State> {
laserColor={this.props.laserColor}
frameColor={this.props.frameColor}
onReadCode={this.props.onReadCode}

/>
)}
</View>
Expand All @@ -222,7 +239,7 @@ export default class CameraScreen extends Component<Props, State> {
<Image
source={this.props.captureButtonImage}
style={this.props.captureButtonImageStyle}
resizeMode="contain"
resizeMode='contain'
/>
{this.props.showCapturedImageCount && (
<View style={styles.textNumberContainer}>
Expand Down Expand Up @@ -351,77 +368,76 @@ export default class CameraScreen extends Component<Props, State> {
}
}

const styles = StyleSheet.create(
{
bottomButtons: {
flex: 2,
flexDirection: 'row',
justifyContent: 'space-between',
padding: 14,
},
textStyle: {
color: 'white',
fontSize: 20,
},
ratioBestText: {
color: 'white',
fontSize: 18,
},
ratioText: {
color: '#ffc233',
fontSize: 18,
},
topButtons: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
paddingTop: 8,
paddingBottom: 0,
},
cameraContainer: {
...Platform.select({
android: {
position: 'absolute',
top: 0,
left: 0,
width,
height,
},
default: {
flex: 10,
flexDirection: 'column',
},
}),
},
captureButtonContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
textNumberContainer: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
justifyContent: 'center',
alignItems: 'center',
},
bottomButton: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
padding: 10,
},
bottomContainerGap: {
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'center',
padding: 10,
},
gap: {
flex: 10,
flexDirection: 'column',
},
});
const styles = StyleSheet.create({
bottomButtons: {
flex: 2,
flexDirection: 'row',
justifyContent: 'space-between',
padding: 14,
},
textStyle: {
color: 'white',
fontSize: 20,
},
ratioBestText: {
color: 'white',
fontSize: 18,
},
ratioText: {
color: '#ffc233',
fontSize: 18,
},
topButtons: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
paddingTop: 8,
paddingBottom: 0,
},
cameraContainer: {
...Platform.select({
android: {
position: 'absolute',
top: 0,
left: 0,
width,
height,
},
default: {
flex: 10,
flexDirection: 'column',
},
}),
},
captureButtonContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
textNumberContainer: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
justifyContent: 'center',
alignItems: 'center',
},
bottomButton: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
padding: 10,
},
bottomContainerGap: {
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'center',
padding: 10,
},
gap: {
flex: 10,
flexDirection: 'column',
},
});