homePage.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import { View, Text, ScrollView, FlatList, Pressable, ActivityIndicator, Image } from 'react-native';
  2. import NormalButton from '../global/normal_button';
  3. import { SafeAreaView } from 'react-native-safe-area-context';
  4. import { router } from 'expo-router';
  5. import RecentlyBookedScrollView from '../global/recentlyBookedScrollView';
  6. import {
  7. BellIconSvg,
  8. HomeIconSvg,
  9. MyBookingIconSvg,
  10. MyVehicleIconSvg,
  11. QrCodeIconSvg,
  12. VipCodeIconSvg
  13. } from '../global/SVG';
  14. import { AuthContext } from '../../context/AuthProvider';
  15. import { useContext, useEffect, useState } from 'react';
  16. import { authenticationService } from '../../service/authService';
  17. import { chargeStationService } from '../../service/chargeStationService';
  18. import { walletService } from '../../service/walletService';
  19. interface HomePageProps {}
  20. const HomePage: React.FC<HomePageProps> = () => {
  21. const now = new Date();
  22. console.log(now);
  23. const { user } = useContext(AuthContext);
  24. return (
  25. <SafeAreaView edges={['top', 'left', 'right']} className="flex-1 bg-white">
  26. <ScrollView showsVerticalScrollIndicator={false} className="flex-1 mx-[5%] ">
  27. <View className=" flex-1 pt-8 ">
  28. <View className="flex-row items-center pb-4">
  29. <HomeIconSvg />
  30. <View className="pl-2 flex-1 flex-column ">
  31. <View className="flex-row justify-between">
  32. <Text className="text-lg pb-1">你好!</Text>
  33. <BellIconSvg />
  34. </View>
  35. <Text className="text-4xl font-light ">{user?.nickname}</Text>
  36. </View>
  37. </View>
  38. <View className=" flex-1 justify-center ">
  39. <Pressable onPress={() => router.push('searchPage')}>
  40. <View
  41. style={{
  42. borderWidth: 1,
  43. padding: 24,
  44. borderRadius: 12,
  45. borderColor: '#bbbbbb',
  46. maxWidth: '100%'
  47. }}
  48. >
  49. <Text style={{ color: '#888888', fontSize: 16 }}>搜尋充電站或地區..</Text>
  50. </View>
  51. </Pressable>
  52. </View>
  53. </View>
  54. <View className="flex-1">
  55. <RecentlyBookedScrollView />
  56. </View>
  57. <View className="flex-1">
  58. <View className=" mb-4">
  59. <NormalButton
  60. // onPress={() => console.log('掃瞄及充電')}
  61. onPress={() => router.push('scanQrPage')}
  62. title={
  63. <View className="flex flex-row space-x-2 items-center">
  64. <QrCodeIconSvg />
  65. <Text className="text-white font-bold text-lg">掃描及充電</Text>
  66. </View>
  67. }
  68. extendedStyle={{
  69. alignItems: 'flex-start',
  70. padding: 24
  71. }}
  72. />
  73. </View>
  74. <View className="flex-1 flex-row justify-between gap-6">
  75. <View className="flex-1">
  76. <NormalButton
  77. onPress={() => router.push('bookingMenuPage')}
  78. title={
  79. <View className="flex flex-row space-x-2 items-center ">
  80. <MyBookingIconSvg />
  81. <Text className="text-white font-bold text-lg">我的預約</Text>
  82. </View>
  83. }
  84. extendedStyle={{
  85. alignItems: 'flex-start',
  86. padding: 24
  87. }}
  88. />
  89. </View>
  90. <View className="flex-1">
  91. <NormalButton
  92. onPress={() => router.push('myVehiclePage')}
  93. title={
  94. <View className="flex flex-row space-x-2 items-center">
  95. <MyVehicleIconSvg />
  96. <Text className="text-white font-bold text-lg">我的車輛</Text>
  97. </View>
  98. }
  99. extendedStyle={{
  100. alignItems: 'flex-start',
  101. padding: 24
  102. }}
  103. />
  104. </View>
  105. </View>
  106. <View className="mt-4">
  107. <NormalButton
  108. // onPress={() => console.log('掃瞄及充電')}
  109. onPress={() => router.push('vipQrPage')}
  110. title={
  111. <View className="flex flex-row items-center space-x-2">
  112. <VipCodeIconSvg />
  113. <Text className="text-white font-bold text-lg">專屬會員二維碼</Text>
  114. </View>
  115. }
  116. extendedStyle={{
  117. alignItems: 'flex-start',
  118. padding: 24
  119. }}
  120. />
  121. </View>
  122. </View>
  123. </ScrollView>
  124. </SafeAreaView>
  125. );
  126. };
  127. export default HomePage;