makingBookingPage.tsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. import {
  2. View,
  3. Text,
  4. ScrollView,
  5. Pressable,
  6. StyleSheet,
  7. Image,
  8. useWindowDimensions
  9. } from 'react-native';
  10. import React from 'react';
  11. import { SafeAreaView } from 'react-native-safe-area-context';
  12. import Svg, { Path, Rect } from 'react-native-svg';
  13. import { router } from 'expo-router';
  14. import NormalButton from '../global/normal_button';
  15. import { SceneMap, TabBar, TabView } from 'react-native-tab-view';
  16. interface ChargingStationTabViewProps {
  17. titles: string[];
  18. }
  19. const ChargingStationTabView: React.FC<ChargingStationTabViewProps> = ({
  20. titles
  21. }) => {
  22. const layout = useWindowDimensions();
  23. //tab 1
  24. const FirstRoute = () => (
  25. <ScrollView style={{ flex: 1, marginHorizontal: '5%' }}>
  26. <Text className="text-lg" style={styles.text}>
  27. 這是一段有關充電站的說明
  28. </Text>
  29. </ScrollView>
  30. );
  31. //tab 2
  32. const SecondRoute = () => (
  33. <ScrollView style={{ flex: 1, marginHorizontal: '5%' }}>
  34. <Text className="text-lg " style={styles.text}>
  35. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
  36. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
  37. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
  38. </Text>
  39. </ScrollView>
  40. );
  41. const renderScene = SceneMap({
  42. firstRoute: FirstRoute,
  43. secondRoute: SecondRoute
  44. });
  45. const [routes] = React.useState([
  46. { key: 'firstRoute', title: titles[0] },
  47. { key: 'secondRoute', title: titles[1] }
  48. ]);
  49. const [index, setIndex] = React.useState(0);
  50. const renderTabBar = (props: any) => (
  51. <TabBar
  52. {...props}
  53. renderLabel={({ route, focused }) => (
  54. <Text
  55. style={{
  56. color: focused ? '#000000' : '#CCCCCC',
  57. fontWeight: focused ? '300' : 'thin',
  58. fontSize: 17
  59. }}
  60. >
  61. {route.title}
  62. </Text>
  63. )}
  64. indicatorStyle={{
  65. backgroundColor: '#000000',
  66. height: 1
  67. }}
  68. style={{
  69. backgroundColor: 'white',
  70. elevation: 0,
  71. marginHorizontal: 15,
  72. borderBottomWidth: 0.5
  73. }}
  74. />
  75. );
  76. return (
  77. <TabView
  78. navigationState={{ index, routes }}
  79. renderScene={renderScene}
  80. onIndexChange={setIndex}
  81. initialLayout={{ width: layout.width }}
  82. renderTabBar={renderTabBar}
  83. />
  84. );
  85. };
  86. const PreviousPageSvg = () => (
  87. <Svg width="28" height="28" viewBox="0 0 28 28" fill="none">
  88. <Path
  89. d="M7.04167 15.6667L16.375 25L14 27.3334L0.666672 14L14 0.666687L16.375 3.00002L7.04167 12.3334H27.3333V15.6667H7.04167Z"
  90. fill="black"
  91. />
  92. </Svg>
  93. );
  94. const CheckLogoSvg = () => (
  95. <Svg width="20" height="20" viewBox="0 0 20 20" fill="none">
  96. <Rect width="20" height="20" rx="10" fill="#02677D" />
  97. <Path
  98. d="M7.95837 15L3.20837 10.25L4.39587 9.06251L7.95837 12.625L15.6042 4.97917L16.7917 6.16667L7.95837 15Z"
  99. fill="white"
  100. />
  101. </Svg>
  102. );
  103. const DirectionLogoSvg = () => (
  104. <Svg width="20" height="20" viewBox="0 0 20 20" fill="none">
  105. <Path
  106. 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"
  107. fill="black"
  108. />
  109. </Svg>
  110. );
  111. const StarSvg = () => (
  112. <Svg width="16" height="15" viewBox="0 0 16 15" fill="none">
  113. <Path
  114. d="M3.32507 14.9663L4.56544 9.65284L0.442368 6.08167L5.87314 5.61052L8.00007 0.600891L10.127 5.61052L15.5578 6.08167L11.4347 9.65284L12.6751 14.9663L8.00007 12.1451L3.32507 14.9663Z"
  115. fill="white"
  116. />
  117. </Svg>
  118. );
  119. const MakingBookingPage = () => (
  120. <SafeAreaView
  121. style={{
  122. flex: 1,
  123. backgroundColor: 'white'
  124. }}
  125. edges={['right', 'top', 'left']}
  126. >
  127. <ScrollView className="flex-1 bg-white ">
  128. <View className="h-[23vh] ">
  129. <View className="pl-8 pt-8">
  130. <Pressable
  131. style={{ alignSelf: 'flex-start' }}
  132. onPress={() => {
  133. if (router.canGoBack()) {
  134. router.back();
  135. } else {
  136. router.replace('./');
  137. }
  138. }}
  139. >
  140. <PreviousPageSvg />
  141. </Pressable>
  142. <Text className="text-3xl mt-8">上環街市充電站</Text>
  143. <View className="flex-column">
  144. <View className="flex-row justify-between items-center mr-[5%]">
  145. <Text
  146. className="text-base"
  147. style={styles.grayColor}
  148. >
  149. 香港上環皇后大道中345號
  150. </Text>
  151. <NormalButton
  152. title={
  153. <View className="flex-row items-center justify-center text-center space-x-1">
  154. <DirectionLogoSvg />
  155. <Text className="text-base ">路線</Text>
  156. </View>
  157. }
  158. onPress={() => console.log('abc')}
  159. extendedStyle={{
  160. backgroundColor: '#E3F2F8',
  161. borderRadius: 61,
  162. paddingHorizontal: 20,
  163. paddingVertical: 8
  164. }}
  165. />
  166. </View>
  167. <View className="flex-row space-x-2 items-center">
  168. <CheckLogoSvg />
  169. <Text>Walk-In</Text>
  170. <Text>400米</Text>
  171. </View>
  172. </View>
  173. </View>
  174. </View>
  175. <View className="h-[50vh] bg-[#FAFAFA]">
  176. <View className="h-[30vh] bg-[#e7f5f8]">
  177. <View className="flex-1 mx-[5%] ">
  178. <Text className="text-xl pt-4">選擇充電車輛</Text>
  179. <ScrollView
  180. horizontal={true}
  181. contentContainerStyle={{
  182. alignItems: 'center',
  183. flexDirection: 'row',
  184. marginVertical: 8
  185. }}
  186. className="space-x-2 flex-1 "
  187. >
  188. <View className="relative bg-white w-44 h-[90%] overflow-hidden rounded-lg items-center justify-center ">
  189. <View style={styles.topLeftTriangle} />
  190. <View className="absolute top-1 left-1">
  191. <StarSvg />
  192. </View>
  193. <View className="items-center justify-center pt-4 space-y-2 ">
  194. <Image
  195. source={require('../../assets/car1.png')}
  196. style={{ height: 72, width: 140 }}
  197. />
  198. <Text className="text-base text-[#222222]">
  199. TESLA - Model 3
  200. </Text>
  201. </View>
  202. </View>
  203. <View className="relative bg-white w-44 h-[90%] overflow-hidden rounded-lg items-center justify-center ">
  204. <View className="items-center justify-center pt-4 space-y-2 ">
  205. <Image
  206. source={require('../../assets/car2.png')}
  207. style={{ height: 72, width: 140 }}
  208. />
  209. <Text className="text-base text-[#222222]">
  210. TESLA - Model 3
  211. </Text>
  212. </View>
  213. </View>
  214. <View className="relative bg-white w-44 h-[90%] overflow-hidden rounded-lg items-center justify-center ">
  215. <View className="items-center justify-center pt-4 space-y-2 ">
  216. <Image
  217. source={require('../../assets/car1.png')}
  218. style={{ height: 72, width: 140 }}
  219. />
  220. <Text className="text-base text-[#222222]">
  221. TESLA - Model 3
  222. </Text>
  223. </View>
  224. </View>
  225. <View className="relative bg-white w-44 h-[90%] overflow-hidden rounded-lg items-center justify-center ">
  226. <View className="items-center justify-center pt-4 space-y-2 ">
  227. <Image
  228. source={require('../../assets/car2.png')}
  229. style={{ height: 72, width: 140 }}
  230. />
  231. <Text className="text-base text-[#222222]">
  232. TESLA - Model 3
  233. </Text>
  234. </View>
  235. </View>
  236. <View className="relative bg-white w-44 h-[90%] overflow-hidden rounded-lg items-center justify-center ">
  237. <View className="items-center justify-center pt-4 space-y-2 ">
  238. <Image
  239. source={require('../../assets/car1.png')}
  240. style={{ height: 72, width: 140 }}
  241. />
  242. <Text className="text-base text-[#222222]">
  243. TESLA - Model 3
  244. </Text>
  245. </View>
  246. </View>
  247. </ScrollView>
  248. </View>
  249. </View>
  250. <View className="h-[20vh] mx-[5%]">
  251. <View className="flex-1 justify-center">
  252. <Pressable
  253. style={{ alignSelf: 'flex-start' }}
  254. onPress={() => console.log('選擇充電方案')}
  255. >
  256. <Text className="text-lg" style={styles.grayColor}>
  257. 選擇充電方案
  258. </Text>
  259. </Pressable>
  260. </View>
  261. <View className="flex-1 justify-center">
  262. <Pressable
  263. style={{ alignSelf: 'flex-start' }}
  264. onPress={() => console.log('選擇日期時間')}
  265. >
  266. <Text className="text-lg" style={styles.grayColor}>
  267. 選擇日期時間
  268. </Text>
  269. </Pressable>
  270. </View>
  271. <View className="flex-1 justify-center">
  272. <Pressable
  273. style={{ alignSelf: 'flex-start' }}
  274. onPress={() => console.log('選擇充電座')}
  275. >
  276. <Text className="text-lg" style={styles.grayColor}>
  277. 選擇充電座
  278. </Text>
  279. </Pressable>
  280. </View>
  281. </View>
  282. </View>
  283. <View className="h-[50vh] bg-white mx-[5%]">
  284. <View
  285. className="flex-1 flex-row max-h-[100px] border-slate-300 my-6 rounded-2xl"
  286. style={{ borderWidth: 1 }}
  287. >
  288. <View className="flex-1 m-4">
  289. <View className="flex-1 flex-row ">
  290. <View className=" flex-1 flex-column justify-between">
  291. <Text className="text-xl " style={styles.text}>
  292. 收費
  293. </Text>
  294. <View className="flex-row items-center space-x-2">
  295. <Text className="text-3xl text-[#02677D]">
  296. $20
  297. </Text>
  298. <Text style={styles.text}>每15分鐘</Text>
  299. </View>
  300. </View>
  301. <View className="items-center justify-center">
  302. <View className="w-[1px] h-[60%] bg-[#CCCCCC]" />
  303. </View>
  304. <View className="flex-1 flex-column ">
  305. <View className="flex-1"></View>
  306. <View className="flex-row items-center ml-4 space-x-2 ">
  307. <Text className="text-3xl text-[#02677D]">
  308. $3.5
  309. </Text>
  310. <Text style={styles.text}>每度電</Text>
  311. </View>
  312. </View>
  313. </View>
  314. </View>
  315. </View>
  316. <Text className="text-xl pb-2 mx-[5%]" style={styles.text}>
  317. 充電站資訊
  318. </Text>
  319. <ChargingStationTabView titles={['充電插頭', '其他']} />
  320. </View>
  321. </ScrollView>
  322. </SafeAreaView>
  323. );
  324. export default MakingBookingPage;
  325. const styles = StyleSheet.create({
  326. grayColor: {
  327. color: '#888888'
  328. },
  329. topLeftTriangle: {
  330. width: 0,
  331. height: 0,
  332. borderLeftWidth: 50,
  333. borderBottomWidth: 50,
  334. borderLeftColor: '#02677D',
  335. borderBottomColor: 'transparent',
  336. position: 'absolute',
  337. top: 0,
  338. left: 0
  339. },
  340. text: {
  341. fontWeight: 300,
  342. color: '#000000'
  343. }
  344. });