homePage.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { View, Text, ScrollView, FlatList, Pressable } 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 { BellIconSvg, HomeIconSvg } from '../global/SVG';
  7. import { AuthContext } from '../../context/AuthProvider';
  8. import { useContext } from 'react';
  9. interface HomePageProps {}
  10. const HomePage: React.FC<HomePageProps> = () => {
  11. const { user } = useContext(AuthContext);
  12. return (
  13. <SafeAreaView edges={['top','left', 'right']} className="flex-1 bg-white">
  14. <ScrollView
  15. showsVerticalScrollIndicator={false}
  16. className="flex-1 mx-[5%] "
  17. >
  18. <View className="pt-8">
  19. <View className="flex-row items-center pb-4">
  20. <HomeIconSvg />
  21. <View className="pl-2 flex-1 flex-column ">
  22. <View className="flex-row justify-between">
  23. <Text className="text-lg pb-1">你好!</Text>
  24. <BellIconSvg />
  25. </View>
  26. <Text className="text-4xl font-light ">
  27. {user?.nickname}
  28. </Text>
  29. </View>
  30. </View>
  31. <View className=" flex-1 justify-center ">
  32. <Pressable onPress={() => router.push('searchPage')}>
  33. <View
  34. style={{
  35. borderWidth: 1,
  36. padding: 24,
  37. borderRadius: 12,
  38. borderColor: '#bbbbbb',
  39. maxWidth: '100%'
  40. }}
  41. >
  42. <Text
  43. style={{ color: '#888888', fontSize: 16 }}
  44. >
  45. 搜尋充電站或地區..
  46. </Text>
  47. </View>
  48. </Pressable>
  49. </View>
  50. </View>
  51. {/* ************************近期預約過************************ */}
  52. <RecentlyBookedScrollView />
  53. {/* ************************Bottom Button Groups************************ */}
  54. <View className="">
  55. <View className=" mb-4">
  56. <NormalButton
  57. // onPress={() => console.log('掃瞄及充電')}
  58. onPress={() => router.push('scanQrPage')}
  59. title={
  60. <Text className="text-white font-bold text-lg">
  61. 掃瞄及充電
  62. </Text>
  63. }
  64. extendedStyle={{
  65. alignItems: 'flex-start',
  66. padding: 24
  67. }}
  68. />
  69. </View>
  70. <View className="flex-1 flex-row justify-between gap-6">
  71. <View className="flex-1">
  72. <NormalButton
  73. onPress={() => router.push('bookingMenuPage')}
  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 className="flex-1">
  86. <NormalButton
  87. onPress={() => router.push('myVehiclePage')}
  88. title={
  89. <Text className="text-white font-bold text-lg">
  90. 我的車輛
  91. </Text>
  92. }
  93. extendedStyle={{
  94. alignItems: 'flex-start',
  95. padding: 24
  96. }}
  97. />
  98. </View>
  99. </View>
  100. </View>
  101. </ScrollView>
  102. </SafeAreaView>
  103. );
  104. };
  105. export default HomePage;