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
48 changes: 30 additions & 18 deletions wallets/rn_cli_wallet/src/screens/Scan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export default function Scan({ navigation }: Props) {
navigation.goBack();
};

const showError = !(hasPermission && device);

useEffect(() => {
if (!hasPermission) {
requestPermission();
Expand All @@ -81,19 +83,13 @@ export default function Scan({ navigation }: Props) {

return (
<View style={[StyleSheet.absoluteFill, styles.container]}>
{hasPermission && device ? (
{showError ? null : (
<Camera
style={StyleSheet.absoluteFill}
device={device}
isActive={isActive}
codeScanner={codeScanner}
/>
) : (
<View style={styles.errorContainer}>
<Text variant="lg-400" color="text-invert">
Camera unavailable. Enable camera access in Settings.
</Text>
</View>
)}

{/* Dark overlay with rounded cutout */}
Expand Down Expand Up @@ -152,17 +148,33 @@ export default function Scan({ navigation }: Props) {
<SvgClose fill="white" height={14} width={14} />
</Button>

{/* Instruction text */}
<View
style={[
styles.instructionContainer,
{ top: scanAreaTop + SCAN_AREA_SIZE + Spacing[8] },
]}
>
<Text variant="lg-400" style={styles.instructionText}>
Scan a WalletConnect QR code
</Text>
</View>
{/* Camera unavailable message, drawn on top of the overlay so it stays
legible instead of being dimmed behind it */}
{showError ? (
<View
style={[
styles.errorContainer,
{ top: scanAreaTop + SCAN_AREA_SIZE + Spacing[8] },
]}
pointerEvents="none"
>
<Text variant="lg-400" color="text-invert" style={styles.errorText}>
Camera unavailable.{'\n'}Enable camera access in Settings.
</Text>
</View>
) : (
/* Instruction text */
<View
style={[
styles.instructionContainer,
{ top: scanAreaTop + SCAN_AREA_SIZE + Spacing[8] },
]}
>
<Text variant="lg-400" style={styles.instructionText}>
Scan a WalletConnect QR code
</Text>
</View>
)}
</View>
);
}
42 changes: 19 additions & 23 deletions wallets/rn_cli_wallet/src/screens/Scan/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,6 @@ export default function Scan({ navigation }: Props) {
<View style={[webStyles.corner, webStyles.cornerTopRight]} />
<View style={[webStyles.corner, webStyles.cornerBottomLeft]} />
<View style={[webStyles.corner, webStyles.cornerBottomRight]} />
{!isCameraEnabled && (
<View style={webStyles.errorContainer}>
<Text variant="lg-400" style={webStyles.errorText}>
{cameraError ||
'Camera unavailable. Allow camera access to scan codes.'}
</Text>
</View>
)}
</View>
</View>
)}
Expand Down Expand Up @@ -294,19 +286,27 @@ export default function Scan({ navigation }: Props) {
)}

{!isCameraEnabled && frameHeight > 0 && (
<Button
accessibilityLabel="Allow camera access"
onPress={requestCameraPermission}
<View
style={[
webStyles.allowCameraButton,
{ top: scanAreaTop + SCAN_AREA_SIZE + Spacing[12] },
webStyles.errorBelow,
{ top: scanAreaTop + SCAN_AREA_SIZE + Spacing[8] },
]}
testID="button-allow-camera"
>
<Text variant="md-500" style={webStyles.allowCameraText}>
Allow camera access
<Text variant="lg-400" style={webStyles.errorText}>
{cameraError ||
'Camera unavailable. Allow camera access to scan codes.'}
</Text>
</Button>
<Button
accessibilityLabel="Allow camera access"
onPress={requestCameraPermission}
style={webStyles.allowCameraButton}
testID="button-allow-camera"
>
<Text variant="md-500" style={webStyles.allowCameraText}>
Allow camera access
</Text>
</Button>
</View>
)}
</View>
);
Expand Down Expand Up @@ -356,15 +356,13 @@ const webStyles = StyleSheet.create({
borderRightWidth: CORNER_STROKE,
borderBottomRightRadius: CORNER_RADIUS,
},
errorContainer: {
errorBelow: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: Spacing[4],
gap: Spacing[4],
},
video: {
height: '100%',
Expand All @@ -376,8 +374,6 @@ const webStyles = StyleSheet.create({
textAlign: 'center',
},
allowCameraButton: {
position: 'absolute',
alignSelf: 'center',
borderColor: 'white',
borderWidth: 1,
borderRadius: BorderRadius[4],
Expand Down
10 changes: 8 additions & 2 deletions wallets/rn_cli_wallet/src/screens/Scan/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ export default StyleSheet.create({
alignItems: 'center',
},
errorContainer: {
flex: 1,
position: 'absolute',
left: 0,
right: 0,
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: Spacing[8],
},
errorText: {
color: 'white',
textAlign: 'center',
},
instructionText: {
color: 'white',
Expand Down
Loading