Repository navigation
Android does not render a Mask at all #241
Copy link
Copy link
Closed
Description
Activity
I am facing the same issue with RN 0.79 and new arch enabled; did you find a solution since? :)
I am facing the same issue with RN 0.79 and new arch enabled; did you find a solution since? :)
Yes. Ditched this library
Reacted by Pierre, Daniel Rauhut and James Holcombsounds like a solution indeed.
did you find an alternative or just forgot the idea? I'm open to alternatives :DWoops needs to be reopened
sounds like a solution indeed. did you find an alternative or just forgot the idea? I'm open to alternatives :D
import React from 'react'; import { Dimensions, StyleSheet, View } from 'react-native'; import { ComponentWithChildren } from '@/types'; const { width: screenWidth, height: screenHeight } = Dimensions.get('window'); const viewfinderSize = screenWidth / 1.25; const topAreaHeight = screenHeight * 0.75; // Calculate the center position const centerX = (screenWidth - viewfinderSize) / 2; const centerY = (topAreaHeight - viewfinderSize) / 2; const styles = StyleSheet.create({ container: { flex: 1, }, childrenContainer: { ...StyleSheet.absoluteFillObject, }, maskContainer: { ...StyleSheet.absoluteFillObject, }, topArea: { position: 'absolute', top: 0, left: 0, width: screenWidth, height: centerY, backgroundColor: 'black', }, leftArea: { position: 'absolute', top: centerY, left: 0, width: centerX, height: viewfinderSize, backgroundColor: 'black', }, rightArea: { position: 'absolute', top: centerY, left: centerX + viewfinderSize, width: centerX, height: viewfinderSize, backgroundColor: 'black', }, bottomArea: { position: 'absolute', top: centerY + viewfinderSize, left: 0, width: screenWidth, height: screenHeight - (centerY + viewfinderSize), backgroundColor: 'black', }, viewfinderBorder: { position: 'absolute', top: centerY, left: centerX, width: viewfinderSize, height: viewfinderSize, backgroundColor: 'transparent', }, }); export const Mask = ({ children }: ComponentWithChildren) => { return ( <View style={styles.container}> {/* Camera/content layer */} <View style={styles.childrenContainer}>{children}</View> {/* Mask elements that cover everything except the viewfinder */} <View style={styles.maskContainer}> <View style={[styles.topArea, { opacity: 0.5 }]} /> <View style={[styles.leftArea, { opacity: 0.5 }]} /> <View style={[styles.rightArea, { opacity: 0.5 }]} /> <View style={[styles.bottomArea, { opacity: 0.5 }]} /> <View style={styles.viewfinderBorder} /> </View> </View> ); };
Had the same issue, what worked for me on android was adding height and width to the MaskedView.
<MaskedView style={{ height: MASK_SIZE.height, width: MASK_SIZE.width }} maskElement={<YourMask />}> ...whatever </MaskedView>Apparently without it the mask isn't rendered at all but the contents are
Reacted by Lumaz1
Metadata
Metadata
Assignees
Labels
No labels
Description
I am using:
here is my code snippet:
I saw some other issues that seem related: #226 and #233 but I don't believe it's quite the same or something new has been introduced to cause a break??
Results
Screenshots:
Notes
androidRenderingModetosoftwareand then the entire screen is gray, with no mask applied.Any ideas?