recentlyBookedScrollView.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { View, Text, ScrollView, Dimensions } from 'react-native';
  2. import React from 'react';
  3. import NormalButton from './normal_button';
  4. import Svg, { Path } from 'react-native-svg';
  5. import { BookingIconSvg } from './SVG';
  6. const calculateResponsivePadding = () => {
  7. const screenHeight = Dimensions.get('window').height;
  8. return screenHeight * 0.01; // 3% of screen height, adjust as needed
  9. };
  10. const RecentBookedRowItemsData = [
  11. { chargingStationName: '充電站#1', chargingStationAddress: '充電站#1地址' },
  12. { chargingStationName: '充電站#2', chargingStationAddress: '充電站#2地址' },
  13. { chargingStationName: '充電站#3', chargingStationAddress: '充電站#3地址' },
  14. { chargingStationName: '充電站#4', chargingStationAddress: '充電站#4地址' },
  15. { chargingStationName: '充電站#5', chargingStationAddress: '充電站#5地址' },
  16. { chargingStationName: '充電站#6', chargingStationAddress: '充電站#6地址' },
  17. { chargingStationName: '充電站#7', chargingStationAddress: '充電站#7地址' },
  18. { chargingStationName: '充電站#8', chargingStationAddress: '充電站#8地址' }
  19. ];
  20. const RecentBookedRowItems = ({
  21. chargingStationName,
  22. chargingStationAddress
  23. }: {
  24. chargingStationName: string;
  25. chargingStationAddress: string;
  26. }) => (
  27. <View
  28. style={{
  29. flexDirection: 'row',
  30. alignItems: 'center'
  31. }}
  32. >
  33. <BookingIconSvg />
  34. <View
  35. style={{
  36. flexDirection: 'row',
  37. justifyContent: 'space-between',
  38. flex: 1,
  39. borderBottomWidth: 0.5,
  40. paddingVertical: calculateResponsivePadding(),
  41. borderColor: '#ccc',
  42. borderRadius: 8
  43. }}
  44. >
  45. <View
  46. style={{
  47. marginLeft: 15,
  48. gap: 3
  49. }}
  50. >
  51. <Text
  52. style={{
  53. fontSize: 16,
  54. color: '#222222'
  55. }}
  56. >
  57. {chargingStationName}
  58. </Text>
  59. <Text
  60. style={{
  61. fontSize: 16,
  62. color: '#888888'
  63. }}
  64. >
  65. {chargingStationAddress}
  66. </Text>
  67. </View>
  68. <NormalButton
  69. title={<Text style={{ color: '#061E25' }}>重新預約</Text>}
  70. onPress={() => console.log('abc')}
  71. buttonPressedStyle={{
  72. backgroundColor: '#CFDEE4'
  73. }}
  74. extendedStyle={{
  75. backgroundColor: '#E3F2F8',
  76. paddingHorizontal: 25,
  77. paddingVertical: 1,
  78. borderRadius: 8
  79. }}
  80. />
  81. </View>
  82. </View>
  83. );
  84. const RecentlyBookedScrollView = () => {
  85. return (
  86. <View className="py-6 flex-column">
  87. <Text
  88. style={{
  89. fontWeight: 400,
  90. fontSize: 16,
  91. color: '#222222',
  92. marginBottom: '5%'
  93. }}
  94. >
  95. 近期預約過
  96. </Text>
  97. <View className="">
  98. {RecentBookedRowItemsData.slice(0, 2).map((item) => (
  99. <RecentBookedRowItems
  100. key={`${item.chargingStationName}+${item.chargingStationAddress}`}
  101. chargingStationName={item.chargingStationName}
  102. chargingStationAddress={item.chargingStationAddress}
  103. />
  104. ))}
  105. </View>
  106. </View>
  107. );
  108. };
  109. export default RecentlyBookedScrollView;