myVehiclePageComponent.tsx 6.1 KB

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