Added back the banner for emailScreen
This commit is contained in:
@@ -21,6 +21,8 @@ const EmailScreen: React.FC = () => {
|
|||||||
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
|
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
|
||||||
const [messageToDelete, setMessageToDelete] = useState(null);
|
const [messageToDelete, setMessageToDelete] = useState(null);
|
||||||
const [emptyMessage, setEmptyMessage] = useState('');
|
const [emptyMessage, setEmptyMessage] = useState('');
|
||||||
|
const [bannerOpacity] = useState(new Animated.Value(0));
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchUserEmail();
|
fetchUserEmail();
|
||||||
@@ -50,6 +52,8 @@ const EmailScreen: React.FC = () => {
|
|||||||
|
|
||||||
const startInboxScanning = async () => {
|
const startInboxScanning = async () => {
|
||||||
setRescanLoading(true);
|
setRescanLoading(true);
|
||||||
|
showBanner(); // Show the scanning banner
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { tokens } = await fetchAuthSession();
|
const { tokens } = await fetchAuthSession();
|
||||||
const idToken = tokens.idToken.toString();
|
const idToken = tokens.idToken.toString();
|
||||||
@@ -75,6 +79,7 @@ const EmailScreen: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const startPollingForScannedEmails = useCallback(() => {
|
const startPollingForScannedEmails = useCallback(() => {
|
||||||
const pollingInterval = setInterval(async () => {
|
const pollingInterval = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -169,6 +174,23 @@ const EmailScreen: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showBanner = () => {
|
||||||
|
Animated.timing(bannerOpacity, {
|
||||||
|
toValue: 1,
|
||||||
|
duration: 500,
|
||||||
|
useNativeDriver: true,
|
||||||
|
}).start(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
Animated.timing(bannerOpacity, {
|
||||||
|
toValue: 0,
|
||||||
|
duration: 500,
|
||||||
|
useNativeDriver: true,
|
||||||
|
}).start();
|
||||||
|
}, 3000);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
{/* Header with Email and Refresh Button */}
|
{/* Header with Email and Refresh Button */}
|
||||||
@@ -224,6 +246,13 @@ const EmailScreen: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
|
{/* Banner when scanning inbox */}
|
||||||
|
<Animated.View style={[styles.banner, { opacity: bannerOpacity }]} pointerEvents="none">
|
||||||
|
<Text style={styles.bannerText}>Scanning emails in the background. This may take a while...</Text>
|
||||||
|
</Animated.View>
|
||||||
|
|
||||||
|
|
||||||
{/* Modal for ScannedDataBox */}
|
{/* Modal for ScannedDataBox */}
|
||||||
<Modal
|
<Modal
|
||||||
visible={isModalVisible}
|
visible={isModalVisible}
|
||||||
@@ -275,6 +304,25 @@ const EmailScreen: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
banner: {
|
||||||
|
position: 'absolute',
|
||||||
|
top: screenHeight * 0.50,
|
||||||
|
left: screenWidth * 0.1,
|
||||||
|
right: screenWidth * 0.1,
|
||||||
|
backgroundColor: '#ff69b4',
|
||||||
|
paddingVertical: screenHeight * 0.02,
|
||||||
|
paddingHorizontal: screenWidth * 0.05,
|
||||||
|
borderRadius: screenWidth * 0.05,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
zIndex: 10,
|
||||||
|
},
|
||||||
|
bannerText: {
|
||||||
|
color: '#fff',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
textAlign: 'center',
|
||||||
|
fontSize: screenWidth * 0.04,
|
||||||
|
},
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: '#f8f0fc',
|
backgroundColor: '#f8f0fc',
|
||||||
|
|||||||
Reference in New Issue
Block a user