chore: add types (#505)

This commit is contained in:
Patrick Kabwe 2023-05-22 22:28:42 +02:00 committed by GitHub
parent 90b8b733d8
commit e01d4aa834
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 134 additions and 118 deletions

View File

@ -8,7 +8,7 @@ Add the `kotlin_version` to `buildscript.ext`
buildscript { buildscript {
ext { ext {
... ...
kotlin_version = '1.5.10' kotlin_version = '1.7.20'
} }
``` ```

View File

@ -201,7 +201,7 @@
); );
inputPaths = ( inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-CameraKitExample/Pods-CameraKitExample-frameworks.sh", "${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"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (

View File

@ -294,7 +294,7 @@ PODS:
- React-Core (= 0.63.4) - React-Core (= 0.63.4)
- React-cxxreact (= 0.63.4) - React-cxxreact (= 0.63.4)
- React-jsi (= 0.63.4) - React-jsi (= 0.63.4)
- ReactNativeCameraKit (11.2.0): - ReactNativeCameraKit (13.0.0):
- React-Core - React-Core
- Yoga (1.14.0) - Yoga (1.14.0)
- YogaKit (1.18.1): - YogaKit (1.18.1):
@ -458,10 +458,10 @@ SPEC CHECKSUMS:
React-RCTText: 5c51df3f08cb9dedc6e790161195d12bac06101c React-RCTText: 5c51df3f08cb9dedc6e790161195d12bac06101c
React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d
ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
ReactNativeCameraKit: c25ef4c32abd8918578a9ece01c90233f478c97c ReactNativeCameraKit: 9d46a5d7dd544ca64aa9c03c150d2348faf437eb
Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6 Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
PODFILE CHECKSUM: f9ef8a8a0dbf13b0a1ceaa5b4c54937559d74e9e PODFILE CHECKSUM: f9ef8a8a0dbf13b0a1ceaa5b4c54937559d74e9e
COCOAPODS: 1.10.1 COCOAPODS: 1.11.3

View File

@ -10,6 +10,7 @@ import {
Platform, Platform,
SafeAreaView, SafeAreaView,
ImageStyle, ImageStyle,
ImageSourcePropType,
} from 'react-native'; } from 'react-native';
import _ from 'lodash'; import _ from 'lodash';
import Camera from './Camera'; import Camera from './Camera';
@ -22,44 +23,61 @@ const { width, height } = Dimensions.get('window');
export enum CameraType { export enum CameraType {
Front = 'front', 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 = { export type Props = {
focusMode?: string, actions?: ActionsT;
zoomMode?: string, flashImages?: FlashImagesT;
ratioOverlay?: string, focusMode?: string;
ratioOverlayColor?: string, zoomMode?: string;
allowCaptureRetake: boolean, ratioOverlay?: string;
cameraRatioOverlay: any, ratioOverlayColor?: string;
showCapturedImageCount?: boolean, allowCaptureRetake?: boolean;
captureButtonImage: any, cameraRatioOverlay?: CameraRatioOverlayT;
captureButtonImageStyle: ImageStyle, showCapturedImageCount?: boolean;
cameraFlipImage: any, captureButtonImage?: ImageSourcePropType;
cameraFlipImageStyle: ImageStyle, captureButtonImageStyle?: ImageStyle;
hideControls: any, cameraFlipImage?: ImageSourcePropType;
showFrame: any, cameraFlipImageStyle?: ImageStyle;
scanBarcode: any, hideControls?: boolean;
laserColor: any, showFrame?: boolean;
frameColor: any, scanBarcode?: boolean;
torchOnImage: any, laserColor?: string;
torchOffImage: any, frameColor?: string;
torchOnImage?: any;
torchImageStyle: ImageStyle, torchOffImage?: any;
onReadCode: (event: any) => void; cameraType?: CameraType;
onBottomButtonPressed: (event: any) => void; torchImageStyle?: ImageStyle;
} onReadCode?: (event: any) => void;
onBottomButtonPressed?: (event: any) => void;
};
type State = { type State = {
captureImages: any[], captureImages: any[];
flashData: any, flashData: any;
torchMode: boolean, torchMode: boolean;
ratios: any[], ratios: any[];
ratioArrayPosition: number, ratioArrayPosition: number;
imageCaptured: any, imageCaptured: any;
captured: boolean, captured: boolean;
cameraType: CameraType, cameraType: CameraType;
} };
export default class CameraScreen extends Component<Props, State> { export default class CameraScreen extends Component<Props, State> {
static propTypes = { static propTypes = {
@ -105,7 +123,7 @@ export default class CameraScreen extends Component<Props, State> {
} }
componentDidMount() { componentDidMount() {
let ratios = []; let ratios: string | any[] = [];
if (this.props.cameraRatioOverlay) { if (this.props.cameraRatioOverlay) {
ratios = this.props.cameraRatioOverlay.ratios || []; ratios = this.props.cameraRatioOverlay.ratios || [];
} }
@ -127,7 +145,7 @@ export default class CameraScreen extends Component<Props, State> {
<Image <Image
style={[{ flex: 1, justifyContent: 'center' }, this.props.torchImageStyle]} style={[{ flex: 1, justifyContent: 'center' }, this.props.torchImageStyle]}
source={this.state.flashData.image} source={this.state.flashData.image}
resizeMode="contain" resizeMode='contain'
/> />
</TouchableOpacity> </TouchableOpacity>
) )
@ -141,7 +159,7 @@ export default class CameraScreen extends Component<Props, State> {
<Image <Image
style={[{ flex: 1, justifyContent: 'center' }, this.props.torchImageStyle]} style={[{ flex: 1, justifyContent: 'center' }, this.props.torchImageStyle]}
source={this.state.torchMode ? this.props.torchOnImage : this.props.torchOffImage} source={this.state.torchMode ? this.props.torchOnImage : this.props.torchOffImage}
resizeMode="contain" resizeMode='contain'
/> />
</TouchableOpacity> </TouchableOpacity>
) )
@ -156,7 +174,7 @@ export default class CameraScreen extends Component<Props, State> {
<Image <Image
style={{ flex: 1, justifyContent: 'center' }} style={{ flex: 1, justifyContent: 'center' }}
source={this.props.cameraFlipImage} source={this.props.cameraFlipImage}
resizeMode="contain" resizeMode='contain'
/> />
</TouchableOpacity> </TouchableOpacity>
) )
@ -195,7 +213,6 @@ export default class CameraScreen extends Component<Props, State> {
laserColor={this.props.laserColor} laserColor={this.props.laserColor}
frameColor={this.props.frameColor} frameColor={this.props.frameColor}
onReadCode={this.props.onReadCode} onReadCode={this.props.onReadCode}
/> />
)} )}
</View> </View>
@ -222,7 +239,7 @@ export default class CameraScreen extends Component<Props, State> {
<Image <Image
source={this.props.captureButtonImage} source={this.props.captureButtonImage}
style={this.props.captureButtonImageStyle} style={this.props.captureButtonImageStyle}
resizeMode="contain" resizeMode='contain'
/> />
{this.props.showCapturedImageCount && ( {this.props.showCapturedImageCount && (
<View style={styles.textNumberContainer}> <View style={styles.textNumberContainer}>
@ -351,77 +368,76 @@ export default class CameraScreen extends Component<Props, State> {
} }
} }
const styles = StyleSheet.create( const styles = StyleSheet.create({
{ bottomButtons: {
bottomButtons: { flex: 2,
flex: 2, flexDirection: 'row',
flexDirection: 'row', justifyContent: 'space-between',
justifyContent: 'space-between', padding: 14,
padding: 14, },
}, textStyle: {
textStyle: { color: 'white',
color: 'white', fontSize: 20,
fontSize: 20, },
}, ratioBestText: {
ratioBestText: { color: 'white',
color: 'white', fontSize: 18,
fontSize: 18, },
}, ratioText: {
ratioText: { color: '#ffc233',
color: '#ffc233', fontSize: 18,
fontSize: 18, },
}, topButtons: {
topButtons: { flex: 1,
flex: 1, flexDirection: 'row',
flexDirection: 'row', justifyContent: 'space-between',
justifyContent: 'space-between', paddingTop: 8,
paddingTop: 8, paddingBottom: 0,
paddingBottom: 0, },
}, cameraContainer: {
cameraContainer: { ...Platform.select({
...Platform.select({ android: {
android: { position: 'absolute',
position: 'absolute', top: 0,
top: 0, left: 0,
left: 0, width,
width, height,
height, },
}, default: {
default: { flex: 10,
flex: 10, flexDirection: 'column',
flexDirection: 'column', },
}, }),
}), },
}, captureButtonContainer: {
captureButtonContainer: { flex: 1,
flex: 1, justifyContent: 'center',
justifyContent: 'center', alignItems: 'center',
alignItems: 'center', },
}, textNumberContainer: {
textNumberContainer: { position: 'absolute',
position: 'absolute', top: 0,
top: 0, left: 0,
left: 0, bottom: 0,
bottom: 0, right: 0,
right: 0, justifyContent: 'center',
justifyContent: 'center', alignItems: 'center',
alignItems: 'center', },
}, bottomButton: {
bottomButton: { flex: 1,
flex: 1, flexDirection: 'row',
flexDirection: 'row', alignItems: 'center',
alignItems: 'center', padding: 10,
padding: 10, },
}, bottomContainerGap: {
bottomContainerGap: { flex: 1,
flex: 1, flexDirection: 'row',
flexDirection: 'row', justifyContent: 'flex-end',
justifyContent: 'flex-end', alignItems: 'center',
alignItems: 'center', padding: 10,
padding: 10, },
}, gap: {
gap: { flex: 10,
flex: 10, flexDirection: 'column',
flexDirection: 'column', },
}, });
});