resultDetailPageComponent.tsx 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. import {
  2. View,
  3. Text,
  4. ScrollView,
  5. Image,
  6. useWindowDimensions,
  7. StyleSheet,
  8. Pressable
  9. } from 'react-native';
  10. import React from 'react';
  11. import { SceneMap, TabBar, TabView } from 'react-native-tab-view';
  12. import NormalButton from '../global/normal_button';
  13. import { router } from 'expo-router';
  14. import {
  15. CheckMarkLogoSvg,
  16. DirectionLogoSvg,
  17. PreviousPageSvg
  18. } from '../global/SVG';
  19. import { SafeAreaView } from 'react-native-safe-area-context';
  20. interface ChargingStationTabViewProps {
  21. titles: string[];
  22. }
  23. const ChargingStationTabView: React.FC<ChargingStationTabViewProps> = ({
  24. titles
  25. }) => {
  26. const layout = useWindowDimensions();
  27. //tab 1
  28. const FirstRoute = () => (
  29. <ScrollView style={{ flex: 1, marginHorizontal: '5%' }}>
  30. <Text className="text-lg" style={styles.text}>
  31. 這是一段有關充電站的說明
  32. </Text>
  33. </ScrollView>
  34. );
  35. //tab 2
  36. const SecondRoute = () => (
  37. <ScrollView style={{ flex: 1, marginHorizontal: '5%' }}>
  38. <Text className="text-lg " style={styles.text}>
  39. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
  40. eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
  41. enim ad minim veniam, quis nostrud exercitation ullamco laboris
  42. nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
  43. in reprehenderit in voluptate velit esse cillum dolore eu fugiat
  44. nulla pariatur. Excepteur sint occaecat cupidatat non proident
  45. </Text>
  46. </ScrollView>
  47. );
  48. const renderScene = SceneMap({
  49. firstRoute: FirstRoute,
  50. secondRoute: SecondRoute
  51. });
  52. const [routes] = React.useState([
  53. { key: 'firstRoute', title: titles[0] },
  54. { key: 'secondRoute', title: titles[1] }
  55. ]);
  56. const [index, setIndex] = React.useState(0);
  57. const renderTabBar = (props: any) => (
  58. <TabBar
  59. {...props}
  60. renderLabel={({ route, focused }) => (
  61. <Text
  62. style={{
  63. color: focused ? '#000000' : '#CCCCCC',
  64. fontWeight: focused ? '300' : 'thin',
  65. fontSize: 17
  66. }}
  67. >
  68. {route.title}
  69. </Text>
  70. )}
  71. indicatorStyle={{
  72. backgroundColor: '#000000',
  73. height: 1
  74. }}
  75. style={{
  76. backgroundColor: 'white',
  77. elevation: 0,
  78. marginHorizontal: 15,
  79. borderBottomWidth: 0.5
  80. }}
  81. />
  82. );
  83. return (
  84. <TabView
  85. navigationState={{ index, routes }}
  86. renderScene={renderScene}
  87. onIndexChange={setIndex}
  88. initialLayout={{ width: layout.width }}
  89. renderTabBar={renderTabBar}
  90. />
  91. );
  92. };
  93. const ResultDetailPageComponent = () => {
  94. return (
  95. <SafeAreaView
  96. edges={['top', 'left', 'right']}
  97. className="flex-1 bg-white"
  98. >
  99. <ScrollView className="flex-1 ">
  100. <View className="relative">
  101. <Image
  102. source={require('../../assets/dummyStationPicture.png')}
  103. resizeMode="cover"
  104. style={{ flex: 1, width: '100%' }}
  105. />
  106. <View className="absolute top-8 left-7 ">
  107. <Pressable
  108. onPress={() => {
  109. if (router.canGoBack()) {
  110. router.back();
  111. } else {
  112. router.replace('./');
  113. }
  114. }}
  115. >
  116. <PreviousPageSvg />
  117. </Pressable>
  118. </View>
  119. </View>
  120. <View className="flex-column mx-[5%] mt-[5%]">
  121. <View>
  122. <Text className="text-3xl">上環街市充電站</Text>
  123. </View>
  124. <View className="flex-row justify-between items-center">
  125. <Text
  126. className="text-base"
  127. style={{ color: '#888888' }}
  128. >
  129. 香港上環皇后大道中345號
  130. </Text>
  131. <NormalButton
  132. title={
  133. <View className="flex-row items-center justify-center text-center space-x-1">
  134. <DirectionLogoSvg />
  135. <Text className="text-base ">路線</Text>
  136. </View>
  137. }
  138. onPress={() => console.log('路線')}
  139. extendedStyle={{
  140. backgroundColor: '#E3F2F8',
  141. borderRadius: 61,
  142. paddingHorizontal: 30,
  143. paddingVertical: 10
  144. }}
  145. />
  146. </View>
  147. <View className="flex-row space-x-2 items-center pb-6 ">
  148. <CheckMarkLogoSvg />
  149. <Text>Walk-In</Text>
  150. <Text>400米</Text>
  151. </View>
  152. <NormalButton
  153. title={
  154. <View className="pr-2">
  155. <Text
  156. style={{
  157. color: '#FFFFFF',
  158. fontWeight: 700,
  159. fontSize: 20
  160. }}
  161. >
  162. + 新增預約
  163. </Text>
  164. </View>
  165. }
  166. // onPress={() => console.log('ab')}
  167. onPress={()=>router.push('makingBookingPage')}
  168. extendedStyle={{ flex: 0.5 }}
  169. />
  170. <View
  171. className="flex-1 flex-row min-h-[20px] border-slate-300 my-6 rounded-2xl"
  172. style={{ borderWidth: 1 }}
  173. >
  174. <View className="flex-1 m-4">
  175. <View className="flex-1 flex-row ">
  176. <View className=" flex-1 flex-column justify-between">
  177. <Text
  178. className="text-xl "
  179. style={styles.text}
  180. >
  181. 收費
  182. </Text>
  183. <View className="flex-row items-center space-x-2">
  184. <Text className="text-3xl text-[#02677D]">
  185. $20
  186. </Text>
  187. <Text style={styles.text}>
  188. 每15分鐘
  189. </Text>
  190. </View>
  191. </View>
  192. <View className="items-center justify-center">
  193. <View className="w-[1px] h-[60%] bg-[#CCCCCC]" />
  194. </View>
  195. <View className="flex-1 flex-column ">
  196. <View className="flex-1"></View>
  197. <View className="flex-row items-center ml-4 space-x-2 ">
  198. <Text className="text-3xl text-[#02677D]">
  199. $3.5
  200. </Text>
  201. <Text style={styles.text}>每度電</Text>
  202. </View>
  203. </View>
  204. </View>
  205. </View>
  206. </View>
  207. </View>
  208. <View className="min-h-[300px]">
  209. <Text className="text-xl pb-2 mx-[5%]" style={styles.text}>
  210. 充電站資訊
  211. </Text>
  212. <ChargingStationTabView titles={['充電插頭', '其他']} />
  213. </View>
  214. </ScrollView>
  215. </SafeAreaView>
  216. );
  217. };
  218. export default ResultDetailPageComponent;
  219. const styles = StyleSheet.create({
  220. text: {
  221. fontWeight: 300,
  222. color: '#000000'
  223. }
  224. });