resultDetailPage.tsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 Svg, { Path, Rect } from 'react-native-svg';
  14. import { router } from 'expo-router';
  15. interface ChargingStationTabViewProps {
  16. titles: string[];
  17. }
  18. const CheckLogoSvg = () => (
  19. <Svg width="20" height="20" viewBox="0 0 20 20" fill="none">
  20. <Rect width="20" height="20" rx="10" fill="#02677D" />
  21. <Path
  22. d="M7.95837 15L3.20837 10.25L4.39587 9.06251L7.95837 12.625L15.6042 4.97917L16.7917 6.16667L7.95837 15Z"
  23. fill="white"
  24. />
  25. </Svg>
  26. );
  27. const DirectionLogoSvg = () => (
  28. <Svg width="20" height="20" viewBox="0 0 20 20" fill="none">
  29. <Path
  30. d="M6.87502 12.2917H8.12498V9.79166H11.4584V11.5785L13.8702 9.16668L11.4584 6.74685V8.5417H7.62821C7.41481 8.5417 7.23592 8.61358 7.09156 8.75733C6.9472 8.90108 6.87502 9.0792 6.87502 9.29168V12.2917ZM10.0016 17.8045C9.81357 17.8045 9.62831 17.7668 9.44581 17.6915C9.26331 17.6162 9.09655 17.5032 8.94552 17.3525L2.64748 11.0545C2.49684 10.9041 2.38386 10.738 2.30854 10.5562C2.23321 10.3745 2.19554 10.1896 2.19554 10.0016C2.19554 9.81358 2.23321 9.62833 2.30854 9.44583C2.38386 9.26333 2.49684 9.09656 2.64748 8.94554L8.94552 2.64749C9.09594 2.49686 9.26202 2.38388 9.44377 2.30856C9.62552 2.23322 9.8104 2.19556 9.99842 2.19556C10.1864 2.19556 10.3717 2.23322 10.5542 2.30856C10.7367 2.38388 10.9035 2.49686 11.0545 2.64749L17.3525 8.94554C17.5032 9.09595 17.6161 9.26204 17.6915 9.44379C17.7668 9.62554 17.8045 9.81042 17.8045 9.99843C17.8045 10.1864 17.7668 10.3717 17.6915 10.5542C17.6161 10.7367 17.5032 10.9035 17.3525 11.0545L11.0545 17.3525C10.9041 17.5032 10.738 17.6162 10.5562 17.6915C10.3745 17.7668 10.1896 17.8045 10.0016 17.8045ZM6.66667 13.3333L9.82371 16.4904C9.87179 16.5385 9.93056 16.5625 10 16.5625C10.0694 16.5625 10.1282 16.5385 10.1763 16.4904L16.4904 10.1763C16.5385 10.1282 16.5625 10.0695 16.5625 10C16.5625 9.93057 16.5385 9.87181 16.4904 9.82372L10.1763 3.50964C10.1282 3.46156 10.0694 3.43752 10 3.43752C9.93056 3.43752 9.87179 3.46156 9.82371 3.50964L3.50962 9.82372C3.46154 9.87181 3.4375 9.93057 3.4375 10C3.4375 10.0695 3.46154 10.1282 3.50962 10.1763L6.66667 13.3333Z"
  31. fill="black"
  32. />
  33. </Svg>
  34. );
  35. const PreviousPageSvg = () => (
  36. <Svg width="28" height="28" viewBox="0 0 28 28" fill="none">
  37. <Path
  38. d="M7.04166 15.6667L16.375 25L14 27.3334L0.666656 14L14 0.666687L16.375 3.00002L7.04166 12.3334H27.3333V15.6667H7.04166Z"
  39. fill="white"
  40. />
  41. </Svg>
  42. );
  43. const ChargingStationTabView: React.FC<ChargingStationTabViewProps> = ({
  44. titles
  45. }) => {
  46. const layout = useWindowDimensions();
  47. //tab 1
  48. const FirstRoute = () => (
  49. <ScrollView style={{ flex: 1, marginHorizontal: '5%' }}>
  50. <Text className="text-lg" style={styles.text}>
  51. 這是一段有關充電站的說明
  52. </Text>
  53. </ScrollView>
  54. );
  55. //tab 2
  56. const SecondRoute = () => (
  57. <ScrollView style={{ flex: 1, marginHorizontal: '5%' }}>
  58. <Text className="text-lg " style={styles.text}>
  59. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
  60. eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
  61. enim ad minim veniam, quis nostrud exercitation ullamco laboris
  62. nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
  63. in reprehenderit in voluptate velit esse cillum dolore eu fugiat
  64. nulla pariatur. Excepteur sint occaecat cupidatat non proident
  65. </Text>
  66. </ScrollView>
  67. );
  68. const renderScene = SceneMap({
  69. firstRoute: FirstRoute,
  70. secondRoute: SecondRoute
  71. });
  72. const [routes] = React.useState([
  73. { key: 'firstRoute', title: titles[0] },
  74. { key: 'secondRoute', title: titles[1] }
  75. ]);
  76. const [index, setIndex] = React.useState(0);
  77. const renderTabBar = (props: any) => (
  78. <TabBar
  79. {...props}
  80. renderLabel={({ route, focused }) => (
  81. <Text
  82. style={{
  83. color: focused ? '#000000' : '#CCCCCC',
  84. fontWeight: focused ? '300' : 'thin',
  85. fontSize: 17
  86. }}
  87. >
  88. {route.title}
  89. </Text>
  90. )}
  91. indicatorStyle={{
  92. backgroundColor: '#000000',
  93. height: 1
  94. }}
  95. style={{
  96. backgroundColor: 'white',
  97. elevation: 0,
  98. marginHorizontal: 15,
  99. borderBottomWidth: 0.5
  100. }}
  101. />
  102. );
  103. return (
  104. <TabView
  105. navigationState={{ index, routes }}
  106. renderScene={renderScene}
  107. onIndexChange={setIndex}
  108. initialLayout={{ width: layout.width }}
  109. renderTabBar={renderTabBar}
  110. />
  111. );
  112. };
  113. const ResultDetailPage = () => {
  114. return (
  115. <ScrollView className="flex-1 bg-white">
  116. <View className="h-[30vh] relative">
  117. <Image
  118. source={require('../../assets/dummyStationPicture.png')}
  119. resizeMode="cover"
  120. style={{ flex: 1, width: '100%' }}
  121. />
  122. <View className="absolute top-14 left-8 ">
  123. <Pressable
  124. onPress={() => {
  125. if (router.canGoBack()) {
  126. router.back();
  127. } else {
  128. router.replace('./');
  129. }
  130. }}
  131. >
  132. <PreviousPageSvg />
  133. </Pressable>
  134. </View>
  135. </View>
  136. <View className="h-[40vh] flex-column mx-[5%] mt-[5%]">
  137. <View>
  138. <Text className="text-3xl">上環街市充電站</Text>
  139. </View>
  140. <View className="flex-row justify-between items-center">
  141. <Text className="text-base" style={{ color: '#888888' }}>
  142. 香港上環皇后大道中345號
  143. </Text>
  144. <NormalButton
  145. title={
  146. <View className="flex-row items-center justify-center text-center space-x-1">
  147. <DirectionLogoSvg />
  148. <Text className="text-base ">路線</Text>
  149. </View>
  150. }
  151. onPress={() => console.log('abc')}
  152. extendedStyle={{
  153. backgroundColor: '#E3F2F8',
  154. borderRadius: 61,
  155. paddingHorizontal: 30,
  156. paddingVertical: 10
  157. }}
  158. />
  159. </View>
  160. <View className="flex-row space-x-2 items-center pb-6 ">
  161. <CheckLogoSvg />
  162. <Text>Walk-In</Text>
  163. <Text>400米</Text>
  164. </View>
  165. <NormalButton
  166. title={
  167. <View className="pr-2">
  168. <Text
  169. style={{
  170. color: '#FFFFFF',
  171. fontWeight: 700,
  172. fontSize: 20
  173. }}
  174. >
  175. + 新增預約
  176. </Text>
  177. </View>
  178. }
  179. onPress={() => console.log('ab')}
  180. extendedStyle={{ flex: 0.5 }}
  181. />
  182. <View
  183. className="flex-1 flex-row min-h-[20px] border-slate-300 my-6 rounded-2xl"
  184. style={{ borderWidth: 1 }}
  185. >
  186. <View className="flex-1 m-4">
  187. <View className="flex-1 flex-row ">
  188. <View className=" flex-1 flex-column justify-between">
  189. <Text className="text-xl " style={styles.text}>
  190. 收費
  191. </Text>
  192. <View className="flex-row items-center space-x-2">
  193. <Text className="text-3xl text-[#02677D]">
  194. $20
  195. </Text>
  196. <Text style={styles.text}>每15分鐘</Text>
  197. </View>
  198. </View>
  199. <View className="items-center justify-center">
  200. <View className="w-[1px] h-[60%] bg-[#CCCCCC]" />
  201. </View>
  202. <View className="flex-1 flex-column ">
  203. <View className="flex-1"></View>
  204. <View className="flex-row items-center ml-4 space-x-2 ">
  205. <Text className="text-3xl text-[#02677D]">
  206. $3.5
  207. </Text>
  208. <Text style={styles.text}>每度電</Text>
  209. </View>
  210. </View>
  211. </View>
  212. </View>
  213. </View>
  214. </View>
  215. <View className="h-[30vh] ">
  216. <Text className="text-xl pb-2 mx-[5%]" style={styles.text}>
  217. 充電站資訊
  218. </Text>
  219. <ChargingStationTabView titles={['充電插頭', '其他']} />
  220. </View>
  221. </ScrollView>
  222. );
  223. };
  224. export default ResultDetailPage;
  225. const styles = StyleSheet.create({
  226. text: {
  227. fontWeight: 300,
  228. color: '#000000'
  229. }
  230. });