import React from 'react'; import { ScrollView, StyleSheet, Text, View } 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 { LogListScreen } from '../../ui/shared/LogListScreen'; import { LogRow, LogRowMetaText } from '../../ui/shared/LogRow'; import { fmt } from '../../utils/copyToComputer'; import type { DebugFeatureRenderProps, NativeLogEntry } from '../../types'; import { t } from '../../i18n'; const LEVEL_COLORS: Record = { trace: Colors.textMuted, debug: Colors.textMuted, info: Colors.primary, warn: Colors.warning, error: Colors.error, fatal: Colors.error, unknown: Colors.textMuted, }; export function renderNativeLogRow(item: NativeLogEntry) { const source = [item.platform, item.source, item.tag].filter(Boolean).join(' / '); return ( {item.level.slice(0, 1).toUpperCase()} {!!source && {source}} )} trailingMetadata={( {new Date(item.timestamp).toLocaleTimeString()} )} /> ); } export const NativeLogTab: React.FC> = React.memo(({ snapshot }) => ( ( <> {item.level.toUpperCase()} {new Date(item.timestamp).toLocaleString()} )} renderDetailBody={(item) => ( {item.message} {fmt(item)} )} /> )); const s = StyleSheet.create({ level: { width: 22, height: 22, borderRadius: 11, alignItems: 'center', justifyContent: 'center', }, levelText: { color: Colors.textInverse, fontSize: FontSize.XS, fontWeight: FontWeight.bold }, message: { fontSize: FontSize.MD, color: Colors.text, lineHeight: 20 }, meta: { fontSize: FontSize.XS, color: Colors.textSecondary }, time: { fontSize: FontSize.XS, color: Colors.textSecondary }, badge: { paddingHorizontal: Spacing.MD, paddingVertical: Spacing.XXS, borderRadius: Radius.SM }, badgeText: { color: Colors.textInverse, fontSize: FontSize.SM, fontWeight: FontWeight.bold }, detailTime: { flex: 1, fontSize: FontSize.SM, color: Colors.textSecondary, textAlign: 'right' }, detailBody: { flex: 1 }, detailContent: { padding: Spacing.MD, gap: Spacing.MD }, copyRow: { alignItems: 'flex-end' }, messageBlock: { fontFamily: 'Courier', fontSize: FontSize.SM, color: Colors.text, lineHeight: 20 }, rawBlock: { fontFamily: 'Courier', fontSize: FontSize.XS, color: Colors.textSecondary, lineHeight: 18 }, });