import React from 'react' import {StyleSheet, TouchableOpacity, View} from 'react-native' import {useFocusEffect} from '@react-navigation/native' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types' import {ScrollView} from '../com/util/Views' import {s} from 'lib/styles' import {ViewHeader} from '../com/util/ViewHeader' import {Text} from '../com/util/text/Text' import {usePalette} from 'lib/hooks/usePalette' import {getEntries} from '#/logger/logDump' import {ago} from 'lib/strings/time' import {useLingui} from '@lingui/react' import {msg} from '@lingui/macro' import {useSetMinimalShellMode} from '#/state/shell' export function LogScreen({}: NativeStackScreenProps< CommonNavigatorParams, 'Log' >) { const pal = usePalette('default') const {_} = useLingui() const setMinimalShellMode = useSetMinimalShellMode() const [expanded, setExpanded] = React.useState([]) useFocusEffect( React.useCallback(() => { setMinimalShellMode(false) }, [setMinimalShellMode]), ) const toggler = (id: string) => () => { if (expanded.includes(id)) { setExpanded(expanded.filter(v => v !== id)) } else { setExpanded([...expanded, id]) } } return ( {getEntries() .slice(0) .map(entry => { return ( {entry.level === 'debug' ? ( ) : ( )} {String(entry.message)} {entry.metadata && Object.keys(entry.metadata).length ? ( ) : undefined} {ago(entry.timestamp)} {expanded.includes(entry.id) ? ( {JSON.stringify(entry.metadata, null, 2)} ) : undefined} ) })} ) } const styles = StyleSheet.create({ entry: { flexDirection: 'row', borderTopWidth: 1, paddingVertical: 10, paddingHorizontal: 6, }, summary: { flex: 1, }, ts: { width: 40, }, details: { paddingVertical: 10, paddingHorizontal: 6, }, })