myVehiclePageComponent.tsx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import { router } from 'expo-router';
  2. import {
  3. View,
  4. Text,
  5. ScrollView,
  6. Pressable,
  7. Image,
  8. Dimensions,
  9. ImageBackground
  10. } from 'react-native';
  11. import { SafeAreaView } from 'react-native-safe-area-context';
  12. import { CrossLogoSvg, GreenStarSvg, RightArrowIconSvg } from '../global/SVG';
  13. import NormalButton from '../global/normal_button';
  14. const VehicleRowComponent = ({
  15. deviceWidth,
  16. deviceHeight
  17. }: {
  18. deviceWidth: number;
  19. deviceHeight: number;
  20. }) => (
  21. <Pressable onPress={() => router.push('manageVehiclePage')}>
  22. <View
  23. className="rounded-xl overflow-hidden mb-3"
  24. style={{
  25. width: deviceWidth * 0.9,
  26. height: deviceHeight * 0.12
  27. }}
  28. >
  29. <ImageBackground
  30. source={require('../../assets/myVehicleBackground.png')}
  31. resizeMode="cover"
  32. className="flex-1 flex-row items-center justify-between "
  33. >
  34. <Image
  35. style={{
  36. marginTop: 15,
  37. marginLeft: 5,
  38. width: deviceWidth * 0.35,
  39. height: '100%'
  40. }}
  41. resizeMode="contain"
  42. source={require('../../assets/car1.png')}
  43. className=""
  44. />
  45. {/* <View className="pr-28 "> */}
  46. <View
  47. className="flex-col "
  48. style={{
  49. paddingRight: deviceHeight < 600 ? 80 : 100
  50. }}
  51. >
  52. <Text
  53. style={{
  54. fontSize: deviceHeight < 600 ? 18 : 22,
  55. fontWeight: '600'
  56. }}
  57. >
  58. TESLA
  59. </Text>
  60. <Text style={{ fontSize: deviceHeight < 600 ? 14 : 18 }}>
  61. Model S
  62. </Text>
  63. <Text
  64. style={{
  65. fontSize: deviceHeight < 600 ? 12 : 16,
  66. color: '#02677D'
  67. }}
  68. className=" text-[#02677D]"
  69. >
  70. BF0992
  71. </Text>
  72. </View>
  73. <View className="pr-3">
  74. <RightArrowIconSvg />
  75. </View>
  76. </ImageBackground>
  77. </View>
  78. </Pressable>
  79. );
  80. const MyVehiclePageComponent = () => {
  81. const { height: deviceHeight, width: deviceWidth } =
  82. Dimensions.get('window');
  83. console.log(deviceHeight, deviceWidth);
  84. return (
  85. <SafeAreaView
  86. className="flex-1 bg-white"
  87. edges={['top', 'right', 'left']}
  88. >
  89. <ScrollView
  90. showsVerticalScrollIndicator={false}
  91. className="flex-1 mx-[5%]"
  92. >
  93. <View style={{ marginTop: 25 }}>
  94. <Pressable
  95. className="self-start"
  96. onPress={() => {
  97. if (router.canGoBack()) {
  98. router.back();
  99. } else {
  100. router.replace('/accountMainPage');
  101. }
  102. }}
  103. >
  104. <CrossLogoSvg />
  105. </Pressable>
  106. <Text
  107. style={{
  108. fontSize: 45,
  109. marginTop: 25,
  110. marginBottom: 10
  111. }}
  112. >
  113. 我的車輛
  114. </Text>
  115. </View>
  116. <View className="items-center ">
  117. <Image
  118. source={require('../../assets/car.png')}
  119. resizeMode="contain"
  120. style={{
  121. width: deviceWidth * 0.8,
  122. height: deviceHeight * 0.25
  123. }}
  124. />
  125. </View>
  126. <View className="flex-row space-x-2 ">
  127. <View
  128. style={{
  129. width: 4,
  130. height: '100%',
  131. backgroundColor: '#02677D'
  132. }}
  133. />
  134. <View>
  135. <View className="flex-row items-center">
  136. <Text className="text-lg text-[#02677D]">
  137. 預設車輛
  138. </Text>
  139. <GreenStarSvg />
  140. </View>
  141. <Text className="text-2xl">TESLA Model 3</Text>
  142. <Text className="text-lg text-[#888888]">CE1107</Text>
  143. </View>
  144. </View>
  145. <View className="w-full h-1 my-4 bg-[#DBE4E8]" />
  146. <Text className="text-xl mb-4">其他車輛</Text>
  147. <VehicleRowComponent
  148. deviceHeight={deviceHeight}
  149. deviceWidth={deviceWidth}
  150. />
  151. <VehicleRowComponent
  152. deviceHeight={deviceHeight}
  153. deviceWidth={deviceWidth}
  154. />
  155. <VehicleRowComponent
  156. deviceHeight={deviceHeight}
  157. deviceWidth={deviceWidth}
  158. />
  159. <NormalButton
  160. title={
  161. <Text
  162. style={{
  163. fontWeight: '700',
  164. fontSize: 20,
  165. color: '#fff'
  166. }}
  167. >
  168. 新增車輛
  169. </Text>
  170. }
  171. onPress={() => router.push('addVehiclePage')}
  172. />
  173. </ScrollView>
  174. </SafeAreaView>
  175. );
  176. };
  177. export default MyVehiclePageComponent;