1import {ROUTE_PATH} from '@/entry/router'; 2import {useNavigation} from '@react-navigation/native'; 3import React from 'react'; 4import {Pressable, StyleSheet, View} from 'react-native'; 5import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; 6import rpx from '@/utils/rpx'; 7import useColors from '@/hooks/useColors'; 8import ThemeText from '@/components/base/themeText'; 9import Color from 'color'; 10import IconButton from '@/components/base/iconButton'; 11 12// todo icon: = musicFree(引入自定义字体 居中) search 13export default function NavBar() { 14 const navigation = useNavigation<any>(); 15 const colors = useColors(); 16 return ( 17 <View style={styles.appbar}> 18 <IconButton 19 accessibilityLabel="打开侧边栏" 20 name="menu" 21 style={styles.menu} 22 color={colors.text} 23 onPress={() => { 24 navigation?.openDrawer(); 25 }} 26 /> 27 28 <Pressable 29 style={[ 30 styles.searchBar, 31 { 32 backgroundColor: colors.placeholder, 33 }, 34 ]} 35 accessible 36 accessibilityLabel="点击这里开始搜索" 37 onPress={() => { 38 navigation.navigate(ROUTE_PATH.SEARCH_PAGE); 39 }}> 40 <Icon 41 accessible={false} 42 name="magnify" 43 size={rpx(32)} 44 color={Color(colors.text).alpha(0.6).toString()} 45 /> 46 <ThemeText 47 accessible={false} 48 fontSize="subTitle" 49 style={[styles.text]}> 50 点击这里开始搜索 51 </ThemeText> 52 </Pressable> 53 </View> 54 ); 55} 56 57const styles = StyleSheet.create({ 58 appbar: { 59 backgroundColor: 'transparent', 60 shadowColor: 'transparent', 61 flexDirection: 'row', 62 alignItems: 'center', 63 width: '100%', 64 height: rpx(88), 65 }, 66 searchBar: { 67 marginHorizontal: rpx(24), 68 flexDirection: 'row', 69 alignItems: 'center', 70 flex: 1, 71 height: '72%', 72 maxHeight: rpx(64), 73 borderRadius: rpx(36), 74 paddingHorizontal: rpx(20), 75 }, 76 text: { 77 marginLeft: rpx(12), 78 opacity: 0.6, 79 }, 80 menu: { 81 marginLeft: rpx(24), 82 }, 83}); 84