bookingMenuPage.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import { View, Text, StyleSheet, ScrollView, Dimensions } from 'react-native';
  2. import TabViewComponent, { TabItem } from '../global/tabView';
  3. import NormalButton from '../global/normal_button';
  4. import { SafeAreaView } from 'react-native-safe-area-context';
  5. import RecentlyBookedScrollView from '../global/recentlyBookedScrollView';
  6. import { router } from 'expo-router';
  7. interface BookingMenuPageProps {}
  8. const dummyTabItems: TabItem[] = [
  9. {
  10. imgURL: require('../../assets/dummyStationPicture.png'),
  11. date: '今天',
  12. time: '16:30',
  13. chargeStationName: '上環街市充電站',
  14. chargeStationAddress: '香港上環皇后大道中345號',
  15. distance: '400米'
  16. },
  17. {
  18. imgURL: require('../../assets/dummyStationPicture2.png'),
  19. date: '3月15',
  20. time: '17:45',
  21. chargeStationName: '中環IFC充電站',
  22. chargeStationAddress: '香港中環皇后大道中999號',
  23. distance: '680米'
  24. },
  25. {
  26. imgURL: require('../../assets/dummyStationPicture2.png'),
  27. date: '4月20',
  28. time: '12:30',
  29. chargeStationName: '中環IFC充電站',
  30. chargeStationAddress: '香港中環皇后大道中999號',
  31. distance: '680米'
  32. }
  33. ];
  34. const BookingMenuPageComponent: React.FC<BookingMenuPageProps> = () => {
  35. const calculateResponsivePadding = () => {
  36. const screenHeight = Dimensions.get('window').height;
  37. return screenHeight * 0.03;
  38. };
  39. const calculateTabViewHeight = () => {
  40. const screenHeight = Dimensions.get('window').height;
  41. if (screenHeight > 800) {
  42. return 500;
  43. } else if (screenHeight > 550) {
  44. return 300;
  45. } else {
  46. return 150;
  47. }
  48. };
  49. return (
  50. <SafeAreaView
  51. edges={['top', 'left', 'right']}
  52. className="flex-1 bg-white"
  53. >
  54. <ScrollView
  55. className="flex-1 mt-8 "
  56. nestedScrollEnabled={true}
  57. showsVerticalScrollIndicator={false}
  58. >
  59. <View className="mx-[5%]">
  60. <View className="">
  61. <Text className="text-5xl pt-1 pb-6">預約</Text>
  62. <NormalButton
  63. title={
  64. <Text
  65. style={{
  66. color: 'white',
  67. fontSize: 16,
  68. fontWeight: '800'
  69. }}
  70. >
  71. + 新增預約
  72. </Text>
  73. }
  74. onPress={() =>
  75. router.push('reservationLocationPage')
  76. }
  77. extendedStyle={{
  78. padding: calculateResponsivePadding()
  79. }}
  80. />
  81. </View>
  82. <View className="">
  83. <RecentlyBookedScrollView />
  84. </View>
  85. </View>
  86. <View
  87. className="flex-1"
  88. style={{ height: calculateTabViewHeight() }}
  89. >
  90. <TabViewComponent
  91. titles={['已預約', '已完成']}
  92. tabItems={dummyTabItems}
  93. />
  94. </View>
  95. </ScrollView>
  96. </SafeAreaView>
  97. );
  98. };
  99. const styles = StyleSheet.create({
  100. recentBookingRowContainer: {
  101. flexDirection: 'row',
  102. alignItems: 'center'
  103. }
  104. });
  105. export default BookingMenuPageComponent;