@@ -5,7 +5,6 @@ import { useColorScheme } from 'nativewind';
55import React , { useEffect , useState } from 'react' ;
66import { useTranslation } from 'react-i18next' ;
77import { ScrollView , StyleSheet , useWindowDimensions , View } from 'react-native' ;
8- import WebView from 'react-native-webview' ;
98
109import { Loading } from '@/components/common/loading' ;
1110import ZeroState from '@/components/common/zero-state' ;
@@ -16,6 +15,7 @@ import { Box } from '@/components/ui/box';
1615import { Button , ButtonIcon , ButtonText } from '@/components/ui/button' ;
1716import { Heading } from '@/components/ui/heading' ;
1817import { HStack } from '@/components/ui/hstack' ;
18+ import { HtmlRenderer } from '@/components/ui/html-renderer' ;
1919import { SharedTabs , type TabItem } from '@/components/ui/shared-tabs' ;
2020import { Text } from '@/components/ui/text' ;
2121import { VStack } from '@/components/ui/vstack' ;
@@ -145,17 +145,26 @@ export default function CallDetail() {
145145
146146 useEffect ( ( ) => {
147147 if ( call ) {
148+ // Try Latitude/Longitude first, but validate they are real coordinates
148149 if ( call . Latitude && call . Longitude ) {
149- setCoordinates ( {
150- latitude : parseFloat ( call . Latitude ) ,
151- longitude : parseFloat ( call . Longitude ) ,
152- } ) ;
153- } else if ( call . Geolocation ) {
154- const [ lat , lng ] = call . Geolocation . split ( ',' ) ;
155- setCoordinates ( {
156- latitude : parseFloat ( lat ) ,
157- longitude : parseFloat ( lng ) ,
158- } ) ;
150+ const lat = parseFloat ( call . Latitude ) ;
151+ const lng = parseFloat ( call . Longitude ) ;
152+ if ( ! isNaN ( lat ) && ! isNaN ( lng ) && ( lat !== 0 || lng !== 0 ) ) {
153+ setCoordinates ( { latitude : lat , longitude : lng } ) ;
154+ return ;
155+ }
156+ }
157+
158+ // Fall through to Geolocation if Latitude/Longitude are missing or invalid
159+ if ( call . Geolocation ) {
160+ const parts = call . Geolocation . split ( ',' ) ;
161+ if ( parts . length === 2 ) {
162+ const lat = parseFloat ( parts [ 0 ] . trim ( ) ) ;
163+ const lng = parseFloat ( parts [ 1 ] . trim ( ) ) ;
164+ if ( ! isNaN ( lat ) && ! isNaN ( lng ) ) {
165+ setCoordinates ( { latitude : lat , longitude : lng } ) ;
166+ }
167+ }
159168 }
160169 }
161170 } , [ call ] ) ;
@@ -186,7 +195,7 @@ export default function CallDetail() {
186195 * Opens the device's native maps application with directions to the call location
187196 */
188197 const handleRoute = async ( ) => {
189- if ( ! coordinates . latitude || ! coordinates . longitude ) {
198+ if ( coordinates . latitude === null || coordinates . longitude === null ) {
190199 showToast ( 'error' , t ( 'call_detail.no_location_for_routing' ) ) ;
191200 return ;
192201 }
@@ -300,37 +309,7 @@ export default function CallDetail() {
300309 < Box className = "border-b border-outline-100 pb-2" >
301310 < Text className = "text-sm text-gray-500" > { t ( 'call_detail.note' ) } </ Text >
302311 < Box >
303- < WebView
304- style = { [ styles . container , { height : 200 } ] }
305- originWhitelist = { [ '*' ] }
306- scrollEnabled = { false }
307- showsVerticalScrollIndicator = { false }
308- source = { {
309- html : `
310- <!DOCTYPE html>
311- <html>
312- <head>
313- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
314- <style>
315- body {
316- color: ${ textColor } ;
317- font-family: system-ui, -apple-system, sans-serif;
318- margin: 0;
319- padding: 0;
320- font-size: 16px;
321- line-height: 1.5;
322- }
323- * {
324- max-width: 100%;
325- }
326- </style>
327- </head>
328- <body>${ call . Note } </body>
329- </html>
330- ` ,
331- } }
332- androidLayerType = "software"
333- />
312+ < HtmlRenderer html = { call . Note ?? '' } style = { StyleSheet . flatten ( [ styles . container , { height : 200 } ] ) } />
334313 </ Box >
335314 </ Box >
336315 </ VStack >
@@ -377,37 +356,7 @@ export default function CallDetail() {
377356 < Text className = "font-semibold" > { protocol . Name } </ Text >
378357 < Text className = "text-sm text-gray-600" > { protocol . Description } </ Text >
379358 < Box >
380- < WebView
381- style = { [ styles . container , { height : 200 } ] }
382- originWhitelist = { [ '*' ] }
383- scrollEnabled = { false }
384- showsVerticalScrollIndicator = { false }
385- source = { {
386- html : `
387- <!DOCTYPE html>
388- <html>
389- <head>
390- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
391- <style>
392- body {
393- color: ${ textColor } ;
394- font-family: system-ui, -apple-system, sans-serif;
395- margin: 0;
396- padding: 0;
397- font-size: 16px;
398- line-height: 1.5;
399- }
400- * {
401- max-width: 100%;
402- }
403- </style>
404- </head>
405- <body>${ protocol . ProtocolText } </body>
406- </html>
407- ` ,
408- } }
409- androidLayerType = "software"
410- />
359+ < HtmlRenderer html = { protocol . ProtocolText ?? '' } style = { StyleSheet . flatten ( [ styles . container , { height : 200 } ] ) } />
411360 </ Box >
412361 </ Box >
413362 ) ) }
@@ -506,45 +455,17 @@ export default function CallDetail() {
506455 </ HStack >
507456 < VStack className = "space-y-1" >
508457 < Box style = { { height : 80 } } >
509- < WebView
510- style = { [ styles . container , { height : 80 } ] }
511- originWhitelist = { [ '*' ] }
512- scrollEnabled = { false }
513- showsVerticalScrollIndicator = { false }
514- source = { {
515- html : `
516- <!DOCTYPE html>
517- <html>
518- <head>
519- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
520- <style>
521- body {
522- color: ${ textColor } ;
523- font-family: system-ui, -apple-system, sans-serif;
524- margin: 0;
525- padding: 0;
526- font-size: 16px;
527- line-height: 1.5;
528- }
529- * {
530- max-width: 100%;
531- }
532- </style>
533- </head>
534- <body>${ call . Nature } </body>
535- </html>
536- ` ,
537- } }
538- androidLayerType = "software"
539- />
458+ < HtmlRenderer html = { call . Nature ?? '' } style = { StyleSheet . flatten ( [ styles . container , { height : 80 } ] ) } />
540459 </ Box >
541460 </ VStack >
542461 </ Box >
543462
544- { /* Map */ }
545- < Box className = "w-full" >
546- { coordinates . latitude && coordinates . longitude ? < StaticMap latitude = { coordinates . latitude } longitude = { coordinates . longitude } address = { call . Address } zoom = { 15 } height = { 200 } showUserLocation = { true } /> : null }
547- </ Box >
463+ { /* Map - only show when valid coordinates exist */ }
464+ { coordinates . latitude !== null && coordinates . longitude !== null ? (
465+ < Box className = "w-full" >
466+ < StaticMap latitude = { coordinates . latitude } longitude = { coordinates . longitude } address = { call . Address } zoom = { 15 } height = { 200 } showUserLocation = { true } />
467+ </ Box >
468+ ) : null }
548469
549470 { /* Action Buttons */ }
550471 < HStack className = { `justify-around p-4 shadow-sm ${ colorScheme === 'dark' ? 'bg-neutral-900' : 'bg-neutral-100' } ` } >
0 commit comments