Skip to content

Commit

Permalink
Merge branch 'feature/ONE-2932-qr-code-scanner-footer' into 'main'
Browse files Browse the repository at this point in the history
[ONE-2932] Added footer param to qr code scanner screen

See merge request procivis/one/one-react-native-components!132
  • Loading branch information
procivisAG committed Aug 21, 2024
2 parents fd2f69f + 7c39b06 commit 3e40585
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@procivis/one-react-native-components",
"version": "0.1.30",
"version": "0.1.31",
"description": "Common Procivis ONE UI components for react-native",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
2 changes: 1 addition & 1 deletion src/camera/qr-code-scanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const QRCodeScanner: FunctionComponent<QRCodeScannerProps> = ({
}
if (React.isValidElement(cameraOverlay)) {
return cameraOverlay;
} else if (cameraOverlay) {
} else {
const CameraOverlayComponent = cameraOverlay as React.ComponentType<any>;
return <CameraOverlayComponent />;
}
Expand Down
2 changes: 1 addition & 1 deletion src/credential/card/credential-details-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
}
if (React.isValidElement(footer)) {
return footer;
} else if (footer) {
} else {
const FooterComponent = footer as React.ComponentType<any>;
return <FooterComponent />;
}
Expand Down
4 changes: 2 additions & 2 deletions src/credential/card/credential-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const CredentialHeader: FC<CredentialHeaderProps> = ({
}
if (React.isValidElement(statusIcon)) {
return statusIcon;
} else if (statusIcon) {
} else {
const StatusIconComponent = statusIcon as React.ComponentType<any>;
return <StatusIconComponent />;
}
Expand All @@ -58,7 +58,7 @@ const CredentialHeader: FC<CredentialHeaderProps> = ({
}
if (React.isValidElement(accessory)) {
return accessory;
} else if (accessory) {
} else {
const AccessoryComponent = accessory as React.ComponentType<any>;
return <AccessoryComponent />;
}
Expand Down
2 changes: 1 addition & 1 deletion src/entity/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Avatar: FunctionComponent<AvatarProps> = ({ avatar, placeholderText, statu
}
if (React.isValidElement(statusIcon)) {
return statusIcon;
} else if (statusIcon) {
} else {
const StatusIconComponent = statusIcon as React.ComponentType<any>;
return <StatusIconComponent />;
}
Expand Down
27 changes: 24 additions & 3 deletions src/screens/qr-code-scanner-screen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent, memo, ReactElement } from 'react';
import React, { FunctionComponent, memo, ReactElement, useMemo } from 'react';
import { StyleSheet, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useCameraDevice } from 'react-native-vision-camera';
Expand All @@ -15,6 +15,7 @@ import { colorWithAlphaComponent } from '../utils/color';

export interface QRCodeScannerScreenProps {
codeTypes?: QRCodeScannerProps['codeTypes'];
footer?: React.ComponentType<any> | React.ReactElement;
onQRCodeRead: QRCodeScannerProps['onQRCodeRead'];
onClose: () => void;
noCameraView?: JSX.Element;
Expand All @@ -23,6 +24,7 @@ export interface QRCodeScannerScreenProps {

const QRCodeScannerScreen: FunctionComponent<QRCodeScannerScreenProps> = ({
codeTypes,
footer,
onQRCodeRead,
noCameraView = null,
onClose,
Expand All @@ -32,6 +34,18 @@ const QRCodeScannerScreen: FunctionComponent<QRCodeScannerScreenProps> = ({
const insets = useSafeAreaInsets();
const colorScheme = useAppColorScheme();

const footerView: React.ReactElement | undefined = useMemo(() => {
if (!footer) {
return undefined;
}
if (React.isValidElement(footer)) {
return footer;
} else {
const FooterComponent = footer as React.ComponentType<any>;
return <FooterComponent />;
}
}, [footer]);

const device = useCameraDevice('back');
if (!device) {
return noCameraView;
Expand All @@ -56,18 +70,25 @@ const QRCodeScannerScreen: FunctionComponent<QRCodeScannerScreenProps> = ({
<BlurView
darkMode={true}
blurStyle="soft"
style={[styles.bottomBlurView, { backgroundColor: colorWithAlphaComponent(colorScheme.black, 0.5) }]}>
style={[
styles.bottomBlurView,
{
backgroundColor: colorWithAlphaComponent(colorScheme.black, 0.5),
paddingBottom: Math.max(insets.bottom, 32),
},
]}>
<Typography align="center" style={styles.title} color={colorScheme.white}>
{title}
</Typography>
{footerView}
</BlurView>
</View>
);
};
const styles = StyleSheet.create({
bottomBlurView: {
bottom: 0,
height: '15%',
minHeight: '15%',
position: 'absolute',
width: '100%',
},
Expand Down

0 comments on commit 3e40585

Please sign in to comment.