chooseCarForChargingRow.tsx 2.4 KB

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