1- import { TouchableOpacity , StyleSheet } from 'react-native' ;
1+ import { StyleSheet } from 'react-native' ;
22import { useEffect , useState } from 'react' ;
33import { ParallaxScrollView , Surface , Text } from '@/components/common' ;
4- import { Card , IconButton , Searchbar } from 'react-native-paper' ;
4+ import { Card , Icon , IconButton , TouchableRipple } from 'react-native-paper' ;
55import { useTranslation } from 'react-i18next' ;
66import { getGreeting } from '@/utils' ;
77import { CategoryVO , DishVO } from '@/types' ;
88import { CategoryService } from '@/service' ;
99import { useThemeColor } from '@/hooks/useThemeColor' ;
1010import Animated from 'react-native-reanimated' ;
11+ import { router } from 'expo-router' ;
1112
1213export default function HomeLayout ( ) {
1314 const [ selectedCategory , setSelectedCategory ] = useState < number | undefined > ( undefined ) ;
14- const [ searchQuery , setSearchQuery ] = useState ( '' ) ;
1515 const { t } = useTranslation ( ) ;
1616 const colors = useThemeColor ( ) ;
1717
@@ -54,7 +54,17 @@ export default function HomeLayout() {
5454 </ Text >
5555 </ Surface >
5656
57- < Searchbar placeholder = "Search" onChangeText = { setSearchQuery } value = { searchQuery } />
57+ < TouchableRipple
58+ onPress = { ( ) => router . push ( '/search' ) }
59+ rippleColor = "rgba(0, 0, 0, .3)"
60+ style = { styles . searchBarContainer }
61+ borderless
62+ >
63+ < Surface style = { styles . searchBar } elevation = { 2 } >
64+ < Icon source = "magnify" size = { 24 } color = { colors . onSurfaceVariant } />
65+ < Text style = { [ styles . searchText , { color : colors . onSurfaceVariant } ] } > 热词</ Text >
66+ </ Surface >
67+ </ TouchableRipple >
5868
5969 { /* Categories */ }
6070 < Surface style = { styles . categoryContainer } >
@@ -65,11 +75,16 @@ export default function HomeLayout() {
6575 const textColor = isSelected ? colors . onPrimary : colors . onSurfaceVariant ;
6676
6777 return (
68- < TouchableOpacity key = { category . id } onPress = { ( ) => setSelectedCategory ( category . id ) } >
78+ < TouchableRipple
79+ borderless
80+ key = { category . id }
81+ onPress = { ( ) => setSelectedCategory ( category . id ) }
82+ style = { { marginRight : 16 , borderRadius : 25 } }
83+ >
6984 < Surface style = { [ styles . categoryButton , { backgroundColor } ] } >
7085 < Text style = { { color : textColor } } > { category . name } </ Text >
7186 </ Surface >
72- </ TouchableOpacity >
87+ </ TouchableRipple >
7388 ) ;
7489 } ) }
7590 </ Animated . ScrollView >
@@ -80,40 +95,45 @@ export default function HomeLayout() {
8095 </ Surface >
8196
8297 { /* Dish Cards */ }
83- < Animated . FlatList
84- data = { dishes }
85- numColumns = { 1 }
86- renderItem = { ( { item : dish } ) => (
87- < Surface style = { styles . dishCard } elevation = { 2 } >
88- < Card . Cover
89- source = { { uri : dish . image ?? 'https://picsum.photos/200/300' } }
90- style = { styles . dishImage }
91- resizeMode = "cover"
92- testID = "dish-image"
93- />
94- < Card . Content style = { styles . dishContent } >
95- < Surface style = { styles . dishInfo } elevation = { 0 } >
96- < Text variant = "titleMedium" ellipsizeMode = "tail" style = { styles . dishName } numberOfLines = { 2 } >
97- { dish . name } 10串鸭肠小船
98- </ Text >
99-
100- < Text variant = "bodySmall" style = { [ styles . dishDescription , { color : colors . secondary } ] } >
101- { dish . description }
102- </ Text >
103- </ Surface >
104-
105- < Surface style = { styles . dishPriceContainer } elevation = { 0 } >
106- < Text variant = "titleLarge" style = { styles . dishPrice } >
107- ¥{ dish . price }
108- </ Text >
109- < IconButton icon = "cart-outline" size = { 22 } onPress = { ( ) => console . log ( 'Pressed' ) } />
110- </ Surface >
111- </ Card . Content >
112- </ Surface >
113- ) }
114- keyExtractor = { ( item ) => item . id . toString ( ) }
115- showsVerticalScrollIndicator = { false }
116- />
98+ < Surface >
99+ < Animated . FlatList
100+ data = { dishes }
101+ numColumns = { 1 }
102+ renderItem = { ( { item : dish } ) => (
103+ < Surface style = { styles . dishCard } elevation = { 2 } >
104+ < Card . Cover
105+ source = { { uri : dish . image ?? 'https://picsum.photos/200/300' } }
106+ style = { styles . dishImage }
107+ resizeMode = "cover"
108+ testID = "dish-image"
109+ />
110+ < Card . Content style = { styles . dishContent } >
111+ < Surface style = { styles . dishInfo } elevation = { 0 } >
112+ < Text variant = "titleSmall" ellipsizeMode = "tail" style = { styles . dishName } numberOfLines = { 2 } >
113+ { dish . name }
114+ </ Text >
115+
116+ < Text variant = "labelSmall" style = { [ styles . dishDescription , { color : colors . secondary } ] } >
117+ { dish . description }
118+ </ Text >
119+ </ Surface >
120+
121+ < Surface style = { styles . dishPriceContainer } elevation = { 0 } >
122+ < Text >
123+ ¥{ ' ' }
124+ < Text variant = "titleLarge" style = { styles . dishPrice } >
125+ { dish . price }
126+ </ Text >
127+ </ Text >
128+ < IconButton icon = "cart-outline" size = { 22 } onPress = { ( ) => console . log ( 'Pressed' ) } />
129+ </ Surface >
130+ </ Card . Content >
131+ </ Surface >
132+ ) }
133+ keyExtractor = { ( item ) => item . id . toString ( ) }
134+ showsVerticalScrollIndicator = { false }
135+ />
136+ </ Surface >
117137 </ ParallaxScrollView >
118138 ) ;
119139}
@@ -126,16 +146,14 @@ const styles = StyleSheet.create({
126146 fontWeight : '600'
127147 } ,
128148 searchInput : {
129- flex : 1 ,
130- marginLeft : 8
149+ height : 20
131150 } ,
132151 categoryContainer : {
133152 flexDirection : 'row' ,
134153 justifyContent : 'space-between' ,
135154 alignItems : 'center'
136155 } ,
137156 categoryButton : {
138- marginRight : 16 ,
139157 paddingHorizontal : 24 ,
140158 paddingVertical : 8 ,
141159 borderRadius : 25 ,
@@ -177,5 +195,20 @@ const styles = StyleSheet.create({
177195 } ,
178196 dishDescription : {
179197 marginTop : 4
198+ } ,
199+ searchBarContainer : {
200+ borderRadius : 32 ,
201+ marginVertical : 8
202+ } ,
203+ searchBar : {
204+ flexDirection : 'row' ,
205+ alignItems : 'center' ,
206+ paddingHorizontal : 12 ,
207+ paddingVertical : 8 ,
208+ gap : 8
209+ } ,
210+ searchText : {
211+ height : 18 ,
212+ lineHeight : 18
180213 }
181214} ) ;
0 commit comments