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
@@ -0,0 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=
jvm.arguments=
offline.mode=false
override.workspace.settings=false
show.console.view=false
show.executions.view=false
+18 -12
View File
@@ -2,13 +2,13 @@ import React, { useEffect } from 'react';
import { View, Text, StyleSheet, TouchableOpacity, Dimensions, Image } from 'react-native';
import Modal from 'react-native-modal';
import Animated, { useSharedValue, useAnimatedStyle, withTiming, withDelay } from 'react-native-reanimated';
import { X, Home, Gavel, FileText, User, LogOut, ChevronRight } from 'lucide-react-native';
import { Home, Gavel, FileText, User, LogOut, ChevronRight } from 'lucide-react-native';
import { CommonActions, useNavigation } from '@react-navigation/native';
import { useDispatch } from 'react-redux';
import { removeToken } from '../../Redux/Slices/Token';
import NavigationString from '../../Constant/NavigationString';
const { width } = Dimensions.get('window');
const { width, height } = Dimensions.get('window');
const DRAWER_WIDTH = width * 0.78;
interface Props { visible: boolean; onClose: () => void; }
@@ -22,7 +22,7 @@ const SideDrawer: React.FC<Props> = ({ visible, onClose }) => {
useEffect(() => {
translateX.value = visible
? withTiming(0, { duration: 300 })
? withTiming(0, { duration: 0 })
: withTiming(-DRAWER_WIDTH, { duration: 250 });
}, [visible]);
@@ -45,12 +45,12 @@ const SideDrawer: React.FC<Props> = ({ visible, onClose }) => {
label: 'Tenders',
icon: FileText,
onPress: () => navigation.navigate(NavigationString.Tender),
},
{
label: 'Profile',
icon: User,
onPress: () => { },
},
}
// {
// label: 'Profile',
// icon: User,
// onPress: () => { },
// },
];
return (
@@ -63,13 +63,17 @@ const SideDrawer: React.FC<Props> = ({ visible, onClose }) => {
animationOut="fadeOut"
style={styles.modal}
useNativeDriver
coverScreen={false}
propagateSwipe
>
<Animated.View style={[styles.drawer, drawerStyle]}>
{/* ================= Header / Profile ================= */}
<View style={styles.profileHeader}>
<TouchableOpacity style={styles.closeBtn} onPress={onClose}>
{/* <TouchableOpacity style={styles.closeBtn} onPress={() => {
console.log('sdfadsfdsf');
}}>
<X size={20} color="#111827" />
</TouchableOpacity>
</TouchableOpacity> */}
<Image source={{ uri: user.avatar }} style={styles.avatar} />
@@ -151,7 +155,7 @@ const styles = StyleSheet.create({
drawer: {
width: DRAWER_WIDTH,
height: '100%',
height: height - 80,
backgroundColor: '#FFFFFF',
borderTopRightRadius: 24,
borderBottomRightRadius: 24,
@@ -171,6 +175,8 @@ const styles = StyleSheet.create({
position: 'absolute',
top: 20,
right: 16,
padding: 10,
zIndex: 20
},
avatar: {
+1
View File
@@ -16,5 +16,6 @@ const NavigationString = {
TenderBidding:'TenderBidding',
ProceedToBidDetail:'ProceedToBidDetail',
LiveTenderDetail:'LiveTenderDetail',
AuctionDetail: 'AuctionDetail',
}
export default NavigationString
+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>
`;
+2
View File
@@ -28,6 +28,7 @@ const GET_MASTER_DATA = `${BASE_URL}contractor/masterdata/all`
const LOG_IN_URL = `${BASE_URL_Auction}auction/loginWithoutDecryption`
const LIVE_TENDER = `${BASE_URL}liveTender/getAllLiveTenders`
const LIVE_AUCTION = `${BASE_URL_Auction}api/auction/getLiveAuctionForMobile`
const PURCHASE_AUCTION_PAGE = `${BASE_URL_Auction}api/auction/getMyAuctionForMobile`
const PROCEED_PURCHASE_AUCTION = `${BASE_URL_Auction}api/auction/proceedToPurchase`
const PURCHASE_AUCTION = `${BASE_URL_Auction}api/auction/purchaseAuction`
const PURCHASE_OFFLINE_AUCTION = `${BASE_URL_Auction}api/auction/purchaseAuctionOffline`
@@ -83,6 +84,7 @@ const SUBMIT_ENVELOPE_FILE_B = `${BASE_URL}tenderBidding/addDocumentsEnvelopeB?r
export {
// Rohit
PURCHASE_AUCTION_PAGE,
VIEW_AUCTION_ITEM_DETAIL,
AUCTION_ITEM_DOCUMENT_DOWNLOAD,
AUCTION_DOCUMENT_DOWNLOAD,
+31 -1
View File
@@ -1,5 +1,5 @@
import { useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query';
import { fetchAuctionItem, fetchDashboard, fetchEmdCheck, fetchLiveAuction, fetchLiveTender, fetchPurchaseAuction, fetchPurchaseAuctionList, fetchPurchaseTender, getAuction, offlineAuctionPurchase, userLogin, offlineTenderPurchase, fetchTenderById, proceedToBid, viewAuctionDocumentDownload, viewAuctionDocuments, viewAuctionItemDocuments } from './apis';
import { fetchAuctionItem, fetchDashboard, fetchEmdCheck, fetchLiveAuction, fetchLiveTender, fetchPurchaseAuction, fetchPurchaseAuctionList, fetchPurchaseTender, getAuction, offlineAuctionPurchase, userLogin, offlineTenderPurchase, fetchTenderById, proceedToBid, viewAuctionDocumentDownload, viewAuctionDocuments, viewAuctionItemDocuments, fetchPurchaseAuctionPage } from './apis';
// User
@@ -63,6 +63,36 @@ export const useFetchPurchaseAuction = () => {
});
};
export const useFetchLiveAuctionPage = () => {
return useInfiniteQuery<any>({
queryKey: ['fetchPurchaseAuctionPage'],
queryFn: ({ pageParam = 0 }) =>
fetchPurchaseAuctionPage({
page: pageParam,
size: 10,
}),
initialPageParam: 0,
getNextPageParam: (lastPage, allPages) => {
const { size, totalCount } = lastPage;
const totalPages = Math.ceil(totalCount / size);
const nextPage = allPages.length;
return nextPage < totalPages ? nextPage : undefined;
},
select: (data) => {
const mergedResults = data.pages.flatMap(
(page: any) => page?.data ?? []
);
return {
...data,
result: mergedResults,
};
},
});
};
export const useFetchLiveAuction = () => {
return useInfiniteQuery<any>({
queryKey: ['fetchLiveAuction'],
+6 -1
View File
@@ -1,5 +1,5 @@
import axios from "axios";
import { AUCTION_DOCUMENT_DOWNLOAD, DASHBOARD_COUNT, EMD_CHECK, FORARD_AUCTION_ITEM, GET_AUCTION_DETAILS, GET_MY_AUCTION, GET_MY_TENDER, GET_TENDER_DETAILS, LIVE_AUCTION, LIVE_TENDER, LOG_IN_URL, PROCEED_PURCHASE_AUCTION, PROCEED_TO_BID, PURCHASE_TENDER_OFFLINE, TENDER_LOGIN, PURCHASE_AUCTION_LIST, PURCHASE_OFFLINE_AUCTION, REVERSE_AUCTION_ITEM, VIEW_AUCTION_DOCUMENTS, VIEW_AUCTION_ITEM_DETAIL } from "./ApiUrls";
import { AUCTION_DOCUMENT_DOWNLOAD, DASHBOARD_COUNT, EMD_CHECK, FORARD_AUCTION_ITEM, GET_AUCTION_DETAILS, GET_MY_AUCTION, GET_MY_TENDER, GET_TENDER_DETAILS, LIVE_AUCTION, LIVE_TENDER, LOG_IN_URL, PROCEED_PURCHASE_AUCTION, PROCEED_TO_BID, PURCHASE_TENDER_OFFLINE, TENDER_LOGIN, PURCHASE_AUCTION_LIST, PURCHASE_OFFLINE_AUCTION, REVERSE_AUCTION_ITEM, VIEW_AUCTION_DOCUMENTS, VIEW_AUCTION_ITEM_DETAIL, PURCHASE_AUCTION_PAGE } from "./ApiUrls";
import { apiCall } from "../../Axios/Axios";
// User
@@ -23,6 +23,11 @@ export const fetchPurchaseAuction = async (): Promise<any> => {
const data = await apiCall<any>('get', `${GET_MY_AUCTION}`);
return data
}
export const fetchPurchaseAuctionPage = async (payload: any): Promise<any> => {
const data = await apiCall<any>('get', `${PURCHASE_AUCTION_PAGE}`, {}, payload);
return data
}
export const fetchLiveAuction = async (payload: any): Promise<any> => {
const data = await apiCall<any>('get', `${LIVE_AUCTION}`, {}, payload);
return data