Fix Android elevation bug causing overlays to render behind the canvas
This commit is contained in:
@@ -153,6 +153,7 @@ const styles = StyleSheet.create({
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
zIndex: 100,
|
||||
elevation: 21,
|
||||
},
|
||||
emojiText: {
|
||||
fontSize: 48,
|
||||
|
||||
@@ -1,37 +1,21 @@
|
||||
import React from 'react';
|
||||
import { StyleSheet, ImageBackground, View } from 'react-native';
|
||||
import { Asset } from 'expo-asset';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { StyleSheet, View, Image } from 'react-native';
|
||||
|
||||
interface FrameOverlayProps {
|
||||
frameAsset: any; // require() asset
|
||||
isCapturing?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a frame PNG overlay on top of the photo.
|
||||
* The frame PNG must have a transparent center (alpha=0) so the photo shows through.
|
||||
* Positioned absolutely to cover the entire photo canvas.
|
||||
*/
|
||||
export default function FrameOverlay({ frameAsset, isCapturing = false }: FrameOverlayProps) {
|
||||
const [localUri, setLocalUri] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (frameAsset) {
|
||||
Asset.fromModule(frameAsset).downloadAsync().then(asset => {
|
||||
setLocalUri(asset.localUri || asset.uri);
|
||||
});
|
||||
}
|
||||
}, [frameAsset]);
|
||||
|
||||
if (!localUri) return null;
|
||||
if (!frameAsset) return null;
|
||||
|
||||
return (
|
||||
<View style={styles.container} pointerEvents={isCapturing ? "auto" : "none"} collapsable={false}>
|
||||
<ImageBackground
|
||||
source={{ uri: localUri }}
|
||||
<Image
|
||||
source={frameAsset}
|
||||
style={styles.frameImage}
|
||||
resizeMode="stretch"
|
||||
fadeDuration={0}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@@ -44,6 +28,8 @@ const styles = StyleSheet.create({
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
zIndex: 50,
|
||||
elevation: 20,
|
||||
},
|
||||
frameImage: {
|
||||
width: '100%',
|
||||
|
||||
@@ -931,6 +931,8 @@ const styles = StyleSheet.create({
|
||||
// ── Date Overlay ──
|
||||
dateOverlay: {
|
||||
position: 'absolute',
|
||||
elevation: 22,
|
||||
zIndex: 12,
|
||||
},
|
||||
dateOverlayText: {
|
||||
fontSize: 11,
|
||||
|
||||
Reference in New Issue
Block a user