import React from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { Colors } from '../../ui/theme/colors';
import { FontSize, FontWeight, Radius, Spacing } from '../../ui/theme/layout';
import { CopyButton } from '../../ui/shared/CopyButton';
import { LogRow } from '../../ui/shared/LogRow';
import type { DebugFeatureRenderProps, NavigationLogEntry } from '../../types';
import { t } from '../../i18n';
export function renderNavigationLogRow(item: NavigationLogEntry) {
return (
{item.action}}
trailingMetadata={(
<>
{item.duration != null && {item.duration}ms}
{new Date(item.timestamp).toLocaleTimeString()}
>
)}
/>
);
}
export const NavigationLogTab: React.FC> = React.memo(({
snapshot,
}) => {
const data = snapshot;
const renderItem = ({ item }: { item: NavigationLogEntry }) => renderNavigationLogRow(item);
return (
{data.length === 0 ? (
{t('navigation.noEvents')}
) : (
item.id}
initialNumToRender={20}
maxToRenderPerBatch={10}
windowSize={5}
removeClippedSubviews={true}
contentContainerStyle={styles.listContent}
/>
)}
);
});
const styles = StyleSheet.create({
container: { flex: 1, backgroundColor: Colors.background },
listContent: { padding: Spacing.SM },
emptyWrap: { flex: 1, alignItems: 'center', justifyContent: 'center' },
empty: { textAlign: 'center', color: Colors.textMuted, fontSize: FontSize.SM },
logItem: {
marginBottom: Spacing.SM,
backgroundColor: Colors.surface,
borderRadius: Radius.LG,
},
action: { fontSize: FontSize.MD, fontWeight: FontWeight.bold, color: Colors.primary },
duration: { fontSize: FontSize.SM, color: Colors.textMuted },
routeValue: { fontSize: FontSize.SM, color: Colors.text, lineHeight: 18 },
time: { fontSize: FontSize.XS, color: Colors.textMuted },
});