Fix map re-mount issue

feature/app-setup
vinay kumar 2025-07-14 19:26:44 +05:30
parent b0b0da447c
commit 7c99b629fc
6 changed files with 75 additions and 39 deletions

View File

@ -16,6 +16,9 @@
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBfz20PwTeQkeMonsgXETOViBAy9LOBlXY"/>
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

View File

@ -186,6 +186,7 @@ export default function HomeScreen() {
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
// customMapStyle={mapStyle}
>
<Marker
draggable

View File

@ -13,30 +13,60 @@ const BatteryDetails = () => {
const vimId = data?.batteries[0]?.vim_id ?? "---";
const serialNumber = data?.batteries[0]?.serial_no ?? "---";
const chargerUid = data?.batteries[0]?.charger_uid ?? "---";
const start = new Date(warrantyStartDate);
const end = new Date(warrantyEndDate);
const battery = data?.batteries?.[0];
const start = battery?.warranty_start_date
? new Date(battery.warranty_start_date)
: null;
const end = battery?.warranty_end_date
? new Date(battery.warranty_end_date)
: null;
const now = new Date();
let progress = 0;
let durationText = "---";
if (
start &&
end &&
!isNaN(start.getTime()) &&
!isNaN(end.getTime()) &&
now < end
) {
const totalDuration = end.getTime() - start.getTime();
const elapsed = now.getTime() - start.getTime();
const remaining = Math.max(end.getTime() - now.getTime(), 0);
const progress = Math.min(elapsed / totalDuration, 1);
progress = Math.min(elapsed / totalDuration, 1);
const yearsLeft = Math.floor(remaining / (365.25 * 24 * 60 * 60 * 1000));
const monthsLeft = Math.floor(
(remaining % (365.25 * 24 * 60 * 60 * 1000)) / (30.44 * 24 * 60 * 60 * 1000)
(remaining % (365.25 * 24 * 60 * 60 * 1000)) /
(30.44 * 24 * 60 * 60 * 1000)
);
const daysLeft = Math.floor(
(remaining % (30.44 * 24 * 60 * 60 * 1000)) / (24 * 60 * 60 * 1000)
);
const formatDate = (date: Date): string =>
date.toLocaleDateString("en-GB", {
durationText = `${yearsLeft} years, ${monthsLeft} months, ${daysLeft} days`;
}
const formatDate = (date?: Date | null): string =>
date && !isNaN(date.getTime())
? date.toLocaleDateString("en-GB", {
day: "2-digit",
month: "short",
year: "numeric",
});
})
: "---";
const isInWarranty =
start &&
end &&
now >= start &&
now <= end &&
!isNaN(start.getTime()) &&
!isNaN(end.getTime());
return (
<ScrollView contentContainerStyle={styles.container}>
@ -44,9 +74,11 @@ const BatteryDetails = () => {
<View style={styles.card}>
<View style={styles.cardHeader}>
<Text style={styles.cardTitle}>Battery</Text>
{isInWarranty && (
<View style={styles.badge}>
<Text style={styles.badgeText}>In Warranty</Text>
</View>
)}
</View>
<View style={styles.divider} />
<InfoRow label="Model" value={model} />
@ -60,10 +92,8 @@ const BatteryDetails = () => {
<View style={styles.divider} />
<InfoRow label="Start Date" value={formatDate(start)} />
<InfoRow label="End Date" value={formatDate(end)} />
<InfoRow
label="Duration Left"
value={`${yearsLeft} years, ${monthsLeft} months, ${daysLeft} days`}
/>
<InfoRow label="Duration Left" value={durationText} />
{start && end && !isNaN(start.getTime()) && !isNaN(end.getTime()) && (
<View style={styles.progressBarBackground}>
<View
style={[
@ -72,6 +102,7 @@ const BatteryDetails = () => {
]}
/>
</View>
)}
</View>
{/* VIM Details */}

View File

@ -17,6 +17,7 @@ export const BASE_URL = "https://dev-driver-saathi-api.vecmocon.com";
// const SERVER_URL =
// "http://dev.vec-tr.ai:8089/?dashboardId=deviceDashboardSocket&assetId=V16000868651064644504";
export const VECTOR_BASE_URL = "https://vec-tr.ai";
export const SOCKET_BASE_URL = "wss://vec-tr.ai";
export const STORAGE_KEYS = {
LANGUAGE: "userLanguage",

8
package-lock.json generated
View File

@ -36,7 +36,7 @@
"react-i18next": "^15.5.3",
"react-native": "0.79.4",
"react-native-element-dropdown": "^2.12.4",
"react-native-maps": "^1.24.3",
"react-native-maps": "1.24.2",
"react-native-otp-entry": "^1.8.5",
"react-native-paper": "^5.14.5",
"react-native-reanimated": "~3.17.4",
@ -11979,9 +11979,9 @@
}
},
"node_modules/react-native-maps": {
"version": "1.24.3",
"resolved": "https://registry.npmjs.org/react-native-maps/-/react-native-maps-1.24.3.tgz",
"integrity": "sha512-cF5oTA8z24QqGIRFfDcsXLEs/gCd0RhaJ9KPv/2HiogKD5gpjh1naimZUJQ6IsEcUngSSk8iov6p2jd7dB+/bQ==",
"version": "1.24.2",
"resolved": "https://registry.npmjs.org/react-native-maps/-/react-native-maps-1.24.2.tgz",
"integrity": "sha512-MiMKe/dUQe6g85Bdmr0QD+kNt9dXK/fuhTVx1NcfR5PWaWOD6K9Shs6RL522tXKfNorDmX3bkUdBYvn86yM+6w==",
"license": "MIT",
"dependencies": {
"@types/geojson": "^7946.0.13"

View File

@ -41,7 +41,7 @@
"react-i18next": "^15.5.3",
"react-native": "0.79.4",
"react-native-element-dropdown": "^2.12.4",
"react-native-maps": "^1.24.3",
"react-native-maps": "1.24.2",
"react-native-otp-entry": "^1.8.5",
"react-native-paper": "^5.14.5",
"react-native-reanimated": "~3.17.4",