homePage.tsx 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { View, Text, ScrollView, FlatList } from 'react-native';
  2. import NormalButton from '../global/normal_button';
  3. import NormalInput from '../global/normal_input';
  4. import { SafeAreaView } from 'react-native-safe-area-context';
  5. import { router } from 'expo-router';
  6. import RecentlyBookedScrollView from '../global/recentlyBookedScrollView';
  7. import { BellIconSvg, HomeIconSvg } from '../global/SVG';
  8. import { AuthContext } from '../../context/AuthProvider';
  9. import { useContext, useEffect } from 'react';
  10. interface HomePageProps {}
  11. const HomePage: React.FC<HomePageProps> = () => {
  12. const { user } = useContext(AuthContext);
  13. return (
  14. <SafeAreaView edges={['left', 'right']} className="flex-1 bg-white">
  15. <ScrollView
  16. showsVerticalScrollIndicator={false}
  17. className="flex-1 mx-[5%] mt-8 "
  18. >
  19. <View className="">
  20. <View className="flex-row items-center pb-4">
  21. <HomeIconSvg />
  22. <View className="pl-2 flex-1 flex-column ">
  23. <View className="flex-row justify-between">
  24. <Text className="text-lg pb-1">你好!</Text>
  25. <BellIconSvg />
  26. </View>
  27. <Text className="text-4xl font-light ">
  28. {user?.nickname}
  29. </Text>
  30. </View>
  31. </View>
  32. <NormalInput
  33. placeholder="搜尋充電站或地區"
  34. onChangeText={() => console.log('abc')}
  35. />
  36. </View>
  37. {/* ************************近期預約過************************ */}
  38. <RecentlyBookedScrollView />
  39. {/* ************************Bottom Button Groups************************ */}
  40. <View className="">
  41. <View className=" mb-4">
  42. <NormalButton
  43. // onPress={() => console.log('掃瞄及充電')}
  44. onPress={() => router.push('scanQrPage')}
  45. title={
  46. <Text className="text-white font-bold text-lg">
  47. 掃瞄及充電
  48. </Text>
  49. }
  50. extendedStyle={{
  51. alignItems: 'flex-start',
  52. padding: 24
  53. }}
  54. />
  55. </View>
  56. <View className="flex-1 flex-row justify-between gap-6">
  57. <View className="flex-1">
  58. <NormalButton
  59. onPress={() => router.push('bookingMenuPage')}
  60. title={
  61. <Text className="text-white font-bold text-lg">
  62. 我的預約
  63. </Text>
  64. }
  65. extendedStyle={{
  66. alignItems: 'flex-start',
  67. padding: 24
  68. }}
  69. />
  70. </View>
  71. <View className="flex-1">
  72. <NormalButton
  73. onPress={() => router.push('myVehiclePage')}
  74. title={
  75. <Text className="text-white font-bold text-lg">
  76. 我的車輛
  77. </Text>
  78. }
  79. extendedStyle={{
  80. alignItems: 'flex-start',
  81. padding: 24
  82. }}
  83. />
  84. </View>
  85. </View>
  86. </View>
  87. </ScrollView>
  88. </SafeAreaView>
  89. );
  90. };
  91. export default HomePage;