1/** 2 * Copyright (c) 650 Industries. 3 * Copyright (c) Meta Platforms, Inc. and affiliates. 4 * 5 * This source code is licensed under the MIT license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8import React from 'react'; 9import { Image, Platform, StatusBar, StyleSheet, Text, View } from 'react-native'; 10import { useLogs } from '../Data/LogContext'; 11import { LogBoxButton } from '../UI/LogBoxButton'; 12import * as LogBoxStyle from '../UI/LogBoxStyle'; 13export function LogBoxInspectorHeader(props) { 14 const { selectedLogIndex: selectedIndex, logs } = useLogs(); 15 const total = logs.length; 16 if (props.level === 'syntax') { 17 return (React.createElement(View, { style: [styles.safeArea, styles[props.level]] }, 18 React.createElement(View, { style: styles.header }, 19 React.createElement(View, { style: styles.title }, 20 React.createElement(Text, { style: styles.titleText }, "Failed to compile"))))); 21 } 22 const prevIndex = selectedIndex - 1 < 0 ? total - 1 : selectedIndex - 1; 23 const nextIndex = selectedIndex + 1 > total - 1 ? 0 : selectedIndex + 1; 24 const titleText = `Log ${selectedIndex + 1} of ${total}`; 25 return (React.createElement(View, { style: [styles.safeArea, styles[props.level]] }, 26 React.createElement(View, { style: styles.header }, 27 React.createElement(LogBoxInspectorHeaderButton, { disabled: total <= 1, level: props.level, image: require('@expo/metro-runtime/assets/chevron-left.png'), onPress: () => props.onSelectIndex(prevIndex) }), 28 React.createElement(View, { style: styles.title }, 29 React.createElement(Text, { style: styles.titleText }, titleText)), 30 React.createElement(LogBoxInspectorHeaderButton, { disabled: total <= 1, level: props.level, image: require('@expo/metro-runtime/assets/chevron-right.png'), onPress: () => props.onSelectIndex(nextIndex) })))); 31} 32const backgroundForLevel = (level) => ({ 33 warn: { 34 default: 'transparent', 35 pressed: LogBoxStyle.getWarningDarkColor(), 36 }, 37 error: { 38 default: 'transparent', 39 pressed: LogBoxStyle.getErrorDarkColor(), 40 }, 41 fatal: { 42 default: 'transparent', 43 pressed: LogBoxStyle.getFatalDarkColor(), 44 }, 45 syntax: { 46 default: 'transparent', 47 pressed: LogBoxStyle.getFatalDarkColor(), 48 }, 49 static: { 50 default: 'transparent', 51 pressed: LogBoxStyle.getFatalDarkColor(), 52 }, 53}[level]); 54function LogBoxInspectorHeaderButton(props) { 55 return (React.createElement(LogBoxButton, { backgroundColor: backgroundForLevel(props.level), onPress: props.disabled ? undefined : props.onPress, style: headerStyles.button }, props.disabled ? null : (React.createElement(Image, { source: props.image, tintColor: LogBoxStyle.getTextColor(), style: headerStyles.buttonImage })))); 56} 57const headerStyles = StyleSheet.create({ 58 button: { 59 alignItems: 'center', 60 justifyContent: 'center', 61 aspectRatio: 1, 62 marginRight: 6, 63 marginLeft: 6, 64 borderRadius: 3, 65 }, 66 buttonImage: { 67 height: 14, 68 width: 8, 69 }, 70}); 71const styles = StyleSheet.create({ 72 syntax: { 73 backgroundColor: LogBoxStyle.getFatalColor(), 74 }, 75 static: { 76 backgroundColor: LogBoxStyle.getFatalColor(), 77 }, 78 fatal: { 79 backgroundColor: LogBoxStyle.getFatalColor(), 80 }, 81 warn: { 82 backgroundColor: LogBoxStyle.getWarningColor(), 83 }, 84 error: { 85 backgroundColor: LogBoxStyle.getErrorColor(), 86 }, 87 header: { 88 flexDirection: 'row', 89 alignItems: 'center', 90 paddingHorizontal: 8, 91 height: Platform.select({ 92 default: 48, 93 ios: 44, 94 }), 95 }, 96 title: { 97 alignItems: 'center', 98 flex: 1, 99 justifyContent: 'center', 100 }, 101 titleText: { 102 color: LogBoxStyle.getTextColor(), 103 fontSize: 16, 104 fontWeight: '600', 105 includeFontPadding: false, 106 lineHeight: 20, 107 }, 108 safeArea: { 109 paddingTop: Platform.OS !== 'ios' ? StatusBar.currentHeight : 40, 110 }, 111}); 112//# sourceMappingURL=LogBoxInspectorHeader.js.map