1bf6e62f2S猫头猫/** 2bf6e62f2S猫头猫 * 搜索结果面板 一级页 3bf6e62f2S猫头猫 */ 4d139abf1S猫头猫import React, {memo, useState} from 'react'; 54060c00aS猫头猫import {Text} from 'react-native'; 6c446f2b8S猫头猫import rpx, {vw} from '@/utils/rpx'; 7bf6e62f2S猫头猫import {SceneMap, TabBar, TabView} from 'react-native-tab-view'; 8bf6e62f2S猫头猫import ResultSubPanel from './resultSubPanel'; 9bf6e62f2S猫头猫import results from './results'; 10bf6e62f2S猫头猫import {fontWeightConst} from '@/constants/uiConst'; 11e650bfb3S猫头猫import useColors from '@/hooks/useColors'; 12bf6e62f2S猫头猫 13bf6e62f2S猫头猫const routes = results; 14bf6e62f2S猫头猫 15d139abf1S猫头猫const getRouterScene = ( 16d139abf1S猫头猫 routes: Array<{key: ICommon.SupportMediaType; title: string}>, 17d139abf1S猫头猫) => { 18bf6e62f2S猫头猫 const scene: Record<string, () => JSX.Element> = {}; 19bf6e62f2S猫头猫 routes.forEach(r => { 204060c00aS猫头猫 scene[r.key] = () => <ResultSubPanel tab={r.key} />; 21bf6e62f2S猫头猫 }); 22bf6e62f2S猫头猫 return SceneMap(scene); 23bf6e62f2S猫头猫}; 24bf6e62f2S猫头猫 25bf6e62f2S猫头猫const renderScene = getRouterScene(routes); 26bf6e62f2S猫头猫 274060c00aS猫头猫function ResultPanel() { 28bf6e62f2S猫头猫 const [index, setIndex] = useState(0); 29e650bfb3S猫头猫 const colors = useColors(); 30bf6e62f2S猫头猫 31bf6e62f2S猫头猫 return ( 32bf6e62f2S猫头猫 <TabView 330b940038S猫头猫 lazy 34bf6e62f2S猫头猫 navigationState={{ 35bf6e62f2S猫头猫 index, 36bf6e62f2S猫头猫 routes, 37bf6e62f2S猫头猫 }} 38bf6e62f2S猫头猫 renderTabBar={props => ( 39bf6e62f2S猫头猫 <TabBar 40bf6e62f2S猫头猫 {...props} 41771839b6S猫头猫 scrollEnabled 42bf6e62f2S猫头猫 style={{ 43*277c5280S猫头猫 backgroundColor: colors.tabBar, 44bf6e62f2S猫头猫 shadowColor: 'transparent', 45bf6e62f2S猫头猫 borderColor: 'transparent', 46bf6e62f2S猫头猫 }} 471119c2eaS猫头猫 inactiveColor={colors.text} 481119c2eaS猫头猫 activeColor={colors.primary} 49bf6e62f2S猫头猫 tabStyle={{ 501119c2eaS猫头猫 width: 'auto', 51bf6e62f2S猫头猫 }} 52bf6e62f2S猫头猫 renderLabel={({route, focused, color}) => ( 53bf6e62f2S猫头猫 <Text 541119c2eaS猫头猫 numberOfLines={1} 55bf6e62f2S猫头猫 style={{ 561119c2eaS猫头猫 width: rpx(160), 57d139abf1S猫头猫 fontWeight: focused 58d139abf1S猫头猫 ? fontWeightConst.bolder 591119c2eaS猫头猫 : fontWeightConst.medium, 60bf6e62f2S猫头猫 color, 611119c2eaS猫头猫 textAlign: 'center', 62bf6e62f2S猫头猫 }}> 63bf6e62f2S猫头猫 {route.title} 64bf6e62f2S猫头猫 </Text> 65bf6e62f2S猫头猫 )} 66bf6e62f2S猫头猫 indicatorStyle={{ 671119c2eaS猫头猫 backgroundColor: colors.primary, 68bf6e62f2S猫头猫 height: rpx(4), 694060c00aS猫头猫 }} 704060c00aS猫头猫 /> 71bf6e62f2S猫头猫 )} 72bf6e62f2S猫头猫 renderScene={renderScene} 73bf6e62f2S猫头猫 onIndexChange={setIndex} 74c446f2b8S猫头猫 initialLayout={{width: vw(100)}} 754060c00aS猫头猫 /> 76bf6e62f2S猫头猫 ); 77bf6e62f2S猫头猫} 78bf6e62f2S猫头猫 79d139abf1S猫头猫export default memo(ResultPanel); 80