latest code with fix modal back Press problem

This commit is contained in:
rohit-kumar-fullstack
2026-01-13 11:53:07 +05:30
parent ffc7e4ead0
commit aa740a608e
11 changed files with 190 additions and 164 deletions
+3 -7
View File
@@ -19,13 +19,9 @@ const Auction = () => {
const { data: purchaseAuctionData = {} } = useFetchPurchaseAuction();
const SelectedPurchaseList = useSelector((state: any) => state.selectPurchaseAuction);
const liveCount = Array.isArray(liveAuctionData?.result)
? liveAuctionData?.pages[0]?.totalCount
: 0;
const liveCount = Array.isArray(liveAuctionData?.result) ? liveAuctionData?.pages[0]?.totalCount : 0;
const purchaseCount = Array.isArray(purchaseAuctionData?.data)
? purchaseAuctionData.data.length
: 0;
const purchaseCount = Array.isArray(purchaseAuctionData?.data) ? purchaseAuctionData.data.length : 0;
const [selectedTab, setSelectedTab] = useState<'live' | 'purchase'>('live');
@@ -44,7 +40,7 @@ const Auction = () => {
<View style={styles.container}>
<InsideHeader title="Auction" showArrow />
{/* Switch Tabs */}
{/* Tabs */}
<View style={{ flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center' }}>
<View style={styles.switchWrapper}>
<Animated.View
+17 -32
View File
@@ -1,16 +1,14 @@
import React, { memo, useEffect, useState } from 'react';
import { View, Text, StyleSheet, TouchableOpacity, ScrollView, SafeAreaView, Platform, StatusBar } from 'react-native';
import Modal from 'react-native-modal';
import moment from 'moment';
import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Platform, StatusBar, Modal } from 'react-native';
import { Briefcase, Calendar, FileText, Download, Eye, Layers, ArrowLeft, Clock } from 'lucide-react-native';
import colors from '../../../Constant/Color';
import { useAuctionItem, useGetAuciton, useGetAucitonDocument } from '../../../Services/BBPS/Hooks';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import AuctionItemDetail from './AuctionItemDetail';
import { useAucitonDocDownload, useAuctionItem, useGetAuciton, useGetAucitonDocument } from '../../../Services/BBPS/Hooks';
import { AUCTION_DOCUMENT_DOWNLOAD } from '../../../Services/BBPS/ApiUrls';
import ReactNativeBlobUtil from 'react-native-blob-util';
import { AUCTION_DOCUMENT_DOWNLOAD, ITEM_DOCUMENT_DOWNLOAD } from '../../../Services/BBPS/ApiUrls';
import { useSelector } from 'react-redux';
import AuctionItemDetail from './AuctionItemDetail';
import { Loader } from '../../../Component/Index';
import colors from '../../../Constant/Color';
import moment from 'moment';
interface Props { visible: boolean; onClose: () => void; data?: any }
@@ -20,8 +18,8 @@ const AuctionFullDetail: React.FC<Props> = ({ visible, onClose, data }) => {
const [aucitonDetail, setAuciotnDetail] = useState<any>(auctionData)
const [allBoolean, setAllBoolean] = useState({ showItemDetail: false, selectedItem: {}, fileLoading: false });
const { data: auctionDocuments } = useGetAucitonDocument({ auctionId: data?.auctionId })
const { mutate: downloadDocument, isPending } = useAucitonDocDownload()
const { mutate } = useAuctionItem()
const formatDate = (date?: string) => {
if (!date) return '-';
return moment(date, 'DD-MM-YYYY HH:mm:ss').format('DD MMM YYYY, hh:mm A');
@@ -47,23 +45,20 @@ const AuctionFullDetail: React.FC<Props> = ({ visible, onClose, data }) => {
);
const handleDownload = async (id: number, fileName: string) => {
try {
setAllBoolean((prev: any) => ({ ...prev, fileLoading: true }));
const { dirs } = ReactNativeBlobUtil.fs;
// ✅ PUBLIC DOWNLOADS DIRECTORY
const path = `${dirs.DownloadDir}/${fileName}.pdf`;
console.log('📂 Saving to:', path);
// console.log('Saving to:', path);
const downloadUrl = `${AUCTION_DOCUMENT_DOWNLOAD}?documentId=${id}&isAmendment=false`;
console.log('🌐 Download URL:', downloadUrl);
// console.log('Download URL:', downloadUrl);
const response = await ReactNativeBlobUtil.config({
fileCache: false, // important for public folder
fileCache: false,
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
@@ -71,23 +66,17 @@ const AuctionFullDetail: React.FC<Props> = ({ visible, onClose, data }) => {
mime: 'application/pdf',
title: `${fileName}.pdf`,
description: 'Downloading document',
mediaScannable: true, // 👈 makes it visible instantly
mediaScannable: true,
},
}).fetch('GET', downloadUrl, {
Accept: 'application/pdf',
});
console.log('✅ Download completed');
console.log('📦 Status:', response.info().status);
console.log('📦 Headers:', response.info().headers);
console.log('📍 Saved at:', path);
const stat = await ReactNativeBlobUtil.fs.stat(path);
console.log('📦 File size:', stat.size);
console.log('File size:', stat.size);
} catch (error: any) {
console.log('❌ Download failed');
console.log('❌ Error:', error?.message || error);
console.log('Error:', error?.message || error);
} finally {
setAllBoolean((prev: any) => ({ ...prev, fileLoading: false }));
}
@@ -106,15 +95,11 @@ const AuctionFullDetail: React.FC<Props> = ({ visible, onClose, data }) => {
return (
<Modal
isVisible={visible}
style={styles.fullModal}
animationIn="fadeIn"
animationOut="fadeOut"
animationInTiming={360}
animationOutTiming={280}
visible={visible}
transparent={false}
animationType="none"
statusBarTranslucent
backdropColor="transparent"
backdropOpacity={0}
onRequestClose={onClose}
>
<View style={styles.safeArea}>
<StatusBar barStyle="dark-content" />
+12 -25
View File
@@ -1,6 +1,5 @@
import React, { memo, useState } from 'react';
import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Platform } from 'react-native';
import Modal from 'react-native-modal';
import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Platform, Modal } from 'react-native';
import { Package, IndianRupee, FileText, Download, ArrowLeft, Info, } from 'lucide-react-native';
import colors from '../../../Constant/Color';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -40,16 +39,15 @@ const AuctionItemDetail: React.FC<Props> = ({ visible, onClose, data }) => {
setAllBoolean((prev: any) => ({ ...prev, fileLoading: true }));
const { dirs } = ReactNativeBlobUtil.fs;
// ✅ PUBLIC DOWNLOADS DIRECTORY
const path = `${dirs.DownloadDir}/${fileName}.pdf`;
console.log('📂 Saving to:', path);
// console.log('Saving to:', path);
const downloadUrl = `${AUCTION_ITEM_DOCUMENT_DOWNLOAD}?auctionItemId=${id}`;
console.log('🌐 Download URL:', downloadUrl);
// console.log('Download URL:', downloadUrl);
const response = await ReactNativeBlobUtil.config({
fileCache: false, // important for public folder
fileCache: false,
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
@@ -57,41 +55,30 @@ const AuctionItemDetail: React.FC<Props> = ({ visible, onClose, data }) => {
mime: 'application/pdf',
title: `${fileName}.pdf`,
description: 'Downloading document',
mediaScannable: true, // 👈 makes it visible instantly
mediaScannable: true,
},
}).fetch('GET', downloadUrl, {
Accept: 'application/pdf',
});
console.log('✅ Download completed');
console.log('📦 Status:', response.info().status);
console.log('📦 Headers:', response.info().headers);
console.log('📍 Saved at:', path);
const stat = await ReactNativeBlobUtil.fs.stat(path);
console.log('📦 File size:', stat.size);
console.log(' File size:', stat.size);
} catch (error: any) {
console.log('❌ Download failed');
console.log('❌ Error:', error?.message || error);
console.log('Error:', error?.message || error);
} finally {
setAllBoolean((prev: any) => ({ ...prev, fileLoading: false }));
}
};
console.log(data, 'kkkkk---');
return (
<Modal
isVisible={visible}
style={styles.fullModal}
animationIn="fadeIn"
animationOut="fadeOut"
animationInTiming={360}
animationOutTiming={280}
visible={visible}
transparent={false}
animationType="none"
statusBarTranslucent
backdropColor="transparent"
backdropOpacity={0}
useNativeDriver
onRequestClose={onClose}
>
<View style={styles.safeArea}>
+87 -23
View File
@@ -1,9 +1,9 @@
import React, { useEffect, useState, useCallback, memo } from 'react';
import { View, Text, StyleSheet, FlatList, RefreshControl } from 'react-native';
import React, { useEffect, useState, useCallback, memo, useRef } from 'react';
import { View, Text, StyleSheet, FlatList, RefreshControl, ActivityIndicator } from 'react-native';
import LiveAuctionTile from './LiveAuctionTile';
import { useNavigation } from '@react-navigation/native';
import moment from 'moment';
import { useFetchPurchaseAuction } from '../../Services/BBPS/Hooks';
import { useFetchLiveAuctionPage, useFetchPurchaseAuction } from '../../Services/BBPS/Hooks';
import PurchaseAuctionTile from './PurchaseAuctionTile';
import { useDispatch } from 'react-redux';
import { setAuction } from '../../Redux/Slices/SelectedAuction';
@@ -12,12 +12,14 @@ import { Skelton } from '../../Component/Index';
import { allBooleanProps } from './types/types';
import FilterModal from './Modal/FilterModal';
import NavigationString from '../../Constant/NavigationString';
import colors from '../../Constant/Color';
const PurchaseAuction = () => {
const navigation = useNavigation() as any;
const Dispatch = useDispatch()
const { data = {}, isPending } = useFetchPurchaseAuction();
const onEndReachedCalledDuringMomentum = useRef(true);
const { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading, isRefetching, refetch, isPending }: any = useFetchLiveAuctionPage();
const [allBoolean, setAllBoolean] = useState<allBooleanProps>({ isShowFilter: false })
const format = 'DD-MM-YYYY HH:mm:ss';
@@ -40,28 +42,90 @@ const PurchaseAuction = () => {
return now.isAfter(end);
}
const loadMore = useCallback(() => {
if (onEndReachedCalledDuringMomentum.current) return;
if (!hasNextPage || isFetchingNextPage) return;
fetchNextPage();
onEndReachedCalledDuringMomentum.current = true;
}, [hasNextPage, isFetchingNextPage, fetchNextPage]);
const renderFooter = useCallback(() => {
if (!isFetchingNextPage) return null;
return (
<View style={{ paddingVertical: 12 }}>
<ActivityIndicator size="small" color={colors.primary} />
</View>
);
}, [isFetchingNextPage]);
return (
<View style={{ flex: 1 }}>
<SearchInput onChange={() => { }} placeholder='Search....' filterPress={() => { setAllBoolean((prev: any) => ({ ...prev, isShowFilter: !prev.isShowFilter })) }} />
{isPending ? <Skelton /> : <FlatList
data={data?.data.slice(0, 10) || []}
keyExtractor={(_, index) => index.toString()}
showsVerticalScrollIndicator={false}
contentContainerStyle={{ paddingBottom: 200, paddingHorizontal: 10 }}
renderItem={({ item, index }) => (
<PurchaseAuctionTile
item={item}
onPressDetails={() => {
}}
onStartBidding={() => {
Dispatch(setAuction(item))
navigation.navigate(NavigationString.Emd)
}}
buttonEnable={isAuctionActive(item)}
isAuctionEnd={isAuctionEnd(item)}
/>
)}
/>}
{isPending ? <Skelton />
:
// <FlatList
// data={data.data ||[]}
// keyExtractor={(_, index) => index.toString()}
// showsVerticalScrollIndicator={false}
// contentContainerStyle={{ paddingBottom: 200, paddingHorizontal: 10 }}
// renderItem={({ item, index }) => (
// <PurchaseAuctionTile
// item={item}
// onPressDetails={() => {
// }}
// onStartBidding={() => {
// Dispatch(setAuction(item))
// navigation.navigate(NavigationString.Emd)
// }}
// buttonEnable={isAuctionActive(item)}
// isAuctionEnd={isAuctionEnd(item)}
// />
// )}
// />
<FlatList
data={data.result ?? []}
renderItem={({ item, index }) => (
<PurchaseAuctionTile
item={item}
onPressDetails={() => {
}}
onStartBidding={() => {
Dispatch(setAuction(item))
navigation.navigate(NavigationString.Emd)
}}
buttonEnable={isAuctionActive(item)}
isAuctionEnd={isAuctionEnd(item)}
/>
)}
showsVerticalScrollIndicator={false}
contentContainerStyle={{ paddingBottom: 50, paddingTop: 10 }}
onEndReached={loadMore}
onEndReachedThreshold={0.1}
onMomentumScrollBegin={() => {
onEndReachedCalledDuringMomentum.current = false;
}}
ListFooterComponent={renderFooter}
refreshControl={
<RefreshControl
refreshing={isRefetching}
onRefresh={refetch}
tintColor="transparent"
colors={[colors.primary]}
/>
}
initialNumToRender={6}
maxToRenderPerBatch={6}
windowSize={7}
removeClippedSubviews
/>
}
{allBoolean.isShowFilter && <View style={{ flex: 1 }}>
<FilterModal visible={allBoolean.isShowFilter} onClose={() => { setAllBoolean((prev: any) => ({ ...prev, isShowFilter: false })) }} onApply={() => { }} />
</View>}
-63
View File
@@ -1,63 +0,0 @@
export const spreadHtml = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link
href="https://cdn.grapecity.com/spreadjs/15.2.2/css/gc.spread.sheets.excel2013white.css"
rel="stylesheet"
/>
<script src="https://cdn.grapecity.com/spreadjs/15.2.2/gc.spread.sheets.all.min.js"></script>
<script src="https://cdn.grapecity.com/spreadjs/15.2.2/plugins/gc.spread.sheets.charts.min.js"></script>
<style>
html, body {
margin: 0;
height: 100%;
width: 100%;
overflow: hidden;
}
#spread {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="spread"></div>
<script>
let spread;
document.addEventListener('message', function (e) {
const base64 = e.data;
spread = new GC.Spread.Sheets.Workbook(
document.getElementById('spread'),
{ sheetCount: 1 }
);
GC.Spread.Excel.IO.open(base64, spread, function () {
console.log('Excel loaded');
});
});
function exportExcel() {
const excelIO = new GC.Spread.Excel.IO();
excelIO.save(spread, function (blob) {
const reader = new FileReader();
reader.onload = function () {
const base64 = reader.result.split(',')[1];
window.ReactNativeWebView.postMessage(base64);
};
reader.readAsDataURL(blob);
});
}
</script>
</body>
</html>
`;