searchPageComponent.tsx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. import { ScrollView, Text, View, StyleSheet, Pressable } from 'react-native';
  2. import NormalInput from '../global/normal_input';
  3. import NormalButton from '../global/normal_button';
  4. import { FlashList } from '@shopify/flash-list';
  5. import { ArrowIconSvg } from '../global/SVG';
  6. import { SafeAreaView } from 'react-native-safe-area-context';
  7. import { useEffect, useRef } from 'react';
  8. import { router } from 'expo-router';
  9. interface BookingHistory {
  10. charingStationName: string;
  11. chargingStationAddress: string;
  12. }
  13. interface SearchPageComponentProps {}
  14. const bookingHistoryData: BookingHistory[] = [
  15. {
  16. charingStationName: '充電站#1',
  17. chargingStationAddress: '充電站地址#1'
  18. },
  19. {
  20. charingStationName: '充電站#2',
  21. chargingStationAddress: '充電站地址#2'
  22. },
  23. {
  24. charingStationName: '充電站#3',
  25. chargingStationAddress: '充電站地址#3'
  26. },
  27. {
  28. charingStationName: '充電站#4',
  29. chargingStationAddress: '充電站地址#4'
  30. }
  31. ];
  32. const SearchPageComponent: React.FC<SearchPageComponentProps> = () => {
  33. const inputRef = useRef(null);
  34. useEffect(() => {
  35. if (inputRef.current) {
  36. inputRef.current.focus();
  37. }
  38. }, []);
  39. return (
  40. <SafeAreaView className="flex-1 bg-white">
  41. <ScrollView className=" flex-1 px-[5%] pt-6 ">
  42. <View className="flex-column gap-4 ">
  43. <View className=" flex-1 flex-row ">
  44. <Pressable
  45. style={styles.leftArrowBackButton}
  46. onPress={() => {
  47. if (router.canGoBack()) {
  48. router.back();
  49. } else {
  50. router.replace('/(auth)/(tabs)/(home)');
  51. }
  52. }}
  53. >
  54. <ArrowIconSvg />
  55. </Pressable>
  56. <NormalInput
  57. placeholder="搜尋這裡"
  58. onChangeText={(abc) => console.log(abc)}
  59. extendedStyle={styles.textInput}
  60. ref={inputRef}
  61. />
  62. </View>
  63. <ScrollView
  64. horizontal={true}
  65. className="space-x-4"
  66. showsHorizontalScrollIndicator={false}
  67. >
  68. <View>
  69. <NormalButton
  70. title={
  71. <Text style={{ color: '#061E25' }}>
  72. 附近的充電站
  73. </Text>
  74. }
  75. onPress={() => console.log('附近的充電站')}
  76. buttonPressedStyle={{
  77. backgroundColor: '#CFDEE4'
  78. }}
  79. extendedStyle={{
  80. backgroundColor: '#E3F2F8',
  81. borderRadius: 8,
  82. paddingVertical: 12
  83. }}
  84. />
  85. </View>
  86. <View>
  87. <NormalButton
  88. title={
  89. <Text style={{ color: '#061E25' }}>
  90. 可Walk-in的充電站
  91. </Text>
  92. }
  93. onPress={() => console.log('可Walk-in的充電站')}
  94. buttonPressedStyle={{
  95. backgroundColor: '#CFDEE4'
  96. }}
  97. extendedStyle={{
  98. backgroundColor: '#E3F2F8',
  99. borderRadius: 8,
  100. paddingVertical: 12
  101. }}
  102. />
  103. </View>
  104. <View>
  105. <NormalButton
  106. title={
  107. <Text style={{ color: '#061E25' }}>
  108. Test Tab #1
  109. </Text>
  110. }
  111. onPress={() => console.log('Test Tab #1')}
  112. buttonPressedStyle={{
  113. backgroundColor: '#CFDEE4'
  114. }}
  115. extendedStyle={{
  116. backgroundColor: '#E3F2F8',
  117. borderRadius: 8,
  118. paddingVertical: 12
  119. }}
  120. />
  121. </View>
  122. <View>
  123. <NormalButton
  124. title={
  125. <Text style={{ color: '#061E25' }}>
  126. Test Tab #2
  127. </Text>
  128. }
  129. onPress={() => console.log('Test Tab #2')}
  130. buttonPressedStyle={{
  131. backgroundColor: '#CFDEE4'
  132. }}
  133. extendedStyle={{
  134. backgroundColor: '#E3F2F8',
  135. borderRadius: 8,
  136. paddingVertical: 12
  137. }}
  138. />
  139. </View>
  140. </ScrollView>
  141. <View>
  142. <Text
  143. style={{
  144. fontWeight: 400,
  145. fontSize: 16,
  146. color: '#222222',
  147. paddingTop: 6
  148. }}
  149. >
  150. 預約記錄
  151. </Text>
  152. <FlashList
  153. estimatedItemSize={10}
  154. data={bookingHistoryData}
  155. renderItem={({ item }) => (
  156. <View className="flex-column space-y-1 py-4 border-b border-gray-300">
  157. <Text className="text-base text-[#222222]">
  158. {item.charingStationName}
  159. </Text>
  160. <Text className="text-base text-[#888888]">
  161. {item.chargingStationAddress}
  162. </Text>
  163. </View>
  164. )}
  165. />
  166. </View>
  167. </View>
  168. </ScrollView>
  169. </SafeAreaView>
  170. );
  171. };
  172. export default SearchPageComponent;
  173. const styles = StyleSheet.create({
  174. leftArrowBackButton: {
  175. width: '15%',
  176. maxWidth: '100%',
  177. fontSize: 16,
  178. padding: 20,
  179. paddingLeft: 30,
  180. borderBottomLeftRadius: 12,
  181. borderTopLeftRadius: 12,
  182. borderColor: '#bbbbbb',
  183. borderTopWidth: 1,
  184. borderBottomWidth: 1,
  185. borderLeftWidth: 1,
  186. alignItems: 'center',
  187. justifyContent: 'center'
  188. },
  189. textInput: {
  190. width: '85%',
  191. maxWidth: '100%',
  192. fontSize: 16,
  193. padding: 20,
  194. paddingLeft: 0,
  195. borderLeftWidth: 0,
  196. borderTopWidth: 1,
  197. borderBottomWidth: 1,
  198. borderRightWidth: 1,
  199. borderBottomRightRadius: 12,
  200. borderTopRightRadius: 12,
  201. borderRadius: 0,
  202. borderColor: '#bbbbbb'
  203. }
  204. });