chooseCarForChargingRow.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {
  2. View,
  3. Text,
  4. Image,
  5. StyleSheet,
  6. Pressable,
  7. Dimensions
  8. } from 'react-native';
  9. import React from 'react';
  10. import { StarSvg } from './SVG';
  11. import { router } from 'expo-router';
  12. const { width, height } = Dimensions.get('window');
  13. const imageHeight = height < 700 ? 100 : 140;
  14. const imageWidth = width < 400 ? 120 : 146;
  15. const carHeight = height < 700 ? 48 : 72;
  16. const carWidth = width < 400 ? 100 : 140;
  17. const ChooseCarForChargingRow = ({
  18. imageUrl,
  19. VehicleName,
  20. isDefault
  21. }: {
  22. imageUrl?: any;
  23. VehicleName: string;
  24. isDefault: boolean;
  25. }) => (
  26. <Pressable onPress={() => router.push('/bookingConfirmationPage')}>
  27. <View
  28. style={[
  29. styles.container,
  30. { height: imageHeight, width: imageWidth }
  31. ]}
  32. >
  33. {isDefault && (
  34. <>
  35. <View style={styles.topLeftTriangle} />
  36. <View className="absolute top-1 left-1">
  37. <StarSvg />
  38. </View>
  39. </>
  40. )}
  41. <View className="items-center justify-center pt-4 space-y-2 ">
  42. <Image
  43. source={
  44. imageUrl ? imageUrl : require('../../assets/car2.png')
  45. }
  46. style={{ height: carHeight, width: carWidth }}
  47. />
  48. <Text
  49. style={{
  50. fontSize: height < 700 ? 14 : 16,
  51. color: '#222222'
  52. }}
  53. >
  54. {VehicleName}
  55. </Text>
  56. </View>
  57. </View>
  58. </Pressable>
  59. );
  60. export default ChooseCarForChargingRow;
  61. const styles = StyleSheet.create({
  62. container: {
  63. backgroundColor: 'white',
  64. overflow: 'hidden',
  65. borderRadius: 8,
  66. alignItems: 'center',
  67. justifyContent: 'center',
  68. marginRight: 12,
  69. position: 'relative'
  70. },
  71. grayColor: {
  72. color: '#888888'
  73. },
  74. topLeftTriangle: {
  75. width: 0,
  76. height: 0,
  77. borderLeftWidth: 50,
  78. borderBottomWidth: 50,
  79. borderLeftColor: '#02677D',
  80. borderBottomColor: 'transparent',
  81. position: 'absolute',
  82. top: 0,
  83. left: 0
  84. },
  85. text: {
  86. fontWeight: 300,
  87. color: '#000000'
  88. }
  89. });