Fix form keyboard issues and sticky footers in agent screens

This commit is contained in:
Abin Toppo
2026-05-26 16:34:05 +05:30
commit 9ac5e95d52
410 changed files with 86650 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
import { Linking, Platform } from 'react-native';
/**
* Calculate distance between two coordinates using the Haversine formula.
* Returns distance in kilometers.
*/
export const haversineDistance = (
lat1: number,
lng1: number,
lat2: number,
lng2: number,
): number => {
const R = 6371; // Earth's radius in km
const dLat = toRad(lat2 - lat1);
const dLng = toRad(lng2 - lng1);
const a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(toRad(lat1)) *
Math.cos(toRad(lat2)) *
Math.sin(dLng / 2) *
Math.sin(dLng / 2);
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return R * c;
};
const toRad = (deg: number): number => deg * (Math.PI / 180);
/**
* Format a distance in km to a human-readable string.
*/
export const formatDistance = (km: number): string => {
if (km < 1) {
return `${Math.round(km * 1000)} m`;
}
if (km < 10) {
return `${km.toFixed(1)} km`;
}
return `${Math.round(km)} km`;
};
/**
* Open external navigation (Google Maps) to the given destination.
*/
export const openDirections = (lat: number, lng: number): void => {
const url = `https://www.google.com/maps/dir/?api=1&destination=${lat},${lng}`;
Linking.openURL(url).catch(() => {
// Fallback for devices without Google Maps
const fallback =
Platform.OS === 'ios'
? `http://maps.apple.com/?daddr=${lat},${lng}`
: url;
Linking.openURL(fallback);
});
};
/**
* Open the phone dialer with the given number.
*/
export const callBranch = (phone: string): void => {
const cleaned = phone.replace(/\s/g, '');
Linking.openURL(`tel:${cleaned}`);
};
@@ -0,0 +1,12 @@
import type { ServiceStatus } from '../../../types/app';
export const getServiceStatusTone = (status: ServiceStatus) => {
switch (status) {
case 'resolved':
return '#35D6A3';
case 'in-progress':
return '#59C6FF';
default:
return '#F6B26B';
}
};