carModel.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import React from 'react';
  2. import { View, Text, StyleSheet, Pressable, FlatList } from 'react-native';
  3. import { FlashList } from '@shopify/flash-list';
  4. import useSignUpStore from '../../../../../providers/signup_form_store';
  5. type ChooseCarModelProps = {
  6. goToChooseCarSeriesPage: () => void;
  7. goToCarInformation: () => void;
  8. };
  9. //hard-coded mock data
  10. const fakeData = [
  11. { name: 'vehicle 1' },
  12. { name: 'vehicle 2' },
  13. { name: 'vehicle 3' },
  14. { name: 'vehicle 4' }
  15. ];
  16. const ChooseCarModel: React.FC<ChooseCarModelProps> = ({
  17. goToChooseCarSeriesPage,
  18. goToCarInformation
  19. }) => {
  20. const { signUpFormData, setSignUpFormData } = useSignUpStore();
  21. const handleSelectModel = (model: string) => {
  22. setSignUpFormData({
  23. ...signUpFormData,
  24. selectedCarModel: model
  25. });
  26. goToCarInformation();
  27. };
  28. return (
  29. <View style={styles.mainContainer}>
  30. <View style={styles.titleContainer}>
  31. <Text style={{ fontSize: 24, fontWeight: '300' }}>
  32. 選擇車系
  33. </Text>
  34. </View>
  35. <View style={styles.paginationContainer}>
  36. <Pressable onPress={goToChooseCarSeriesPage}>
  37. <Text style={{ color: '#888888' }}>{`< 上一步`}</Text>
  38. </Pressable>
  39. </View>
  40. <View style={styles.bottomContainer}>
  41. <FlashList
  42. data={fakeData}
  43. estimatedItemSize={20}
  44. renderItem={({ item }) => (
  45. <Pressable onPress={() => handleSelectModel(item.name)}>
  46. <View style={styles.listContainer}>
  47. <View style={styles.logoContainer}>
  48. <Text
  49. style={{
  50. fontSize: 24,
  51. fontWeight: '200'
  52. }}
  53. >
  54. {'logo'}
  55. </Text>
  56. </View>
  57. <View style={styles.itemContainer}>
  58. <Text style={styles.item}>{item.name}</Text>
  59. </View>
  60. </View>
  61. </Pressable>
  62. )}
  63. />
  64. </View>
  65. </View>
  66. );
  67. };
  68. const styles = StyleSheet.create({
  69. mainContainer: {
  70. flex: 1,
  71. flexDirection: 'column',
  72. backgroundColor: '#FFFFFF'
  73. },
  74. titleContainer: {
  75. flex: 1,
  76. alignItems: 'center',
  77. justifyContent: 'center'
  78. },
  79. paginationContainer: {
  80. flex: 0.3,
  81. paddingLeft: '6%',
  82. paddingBottom: '5%'
  83. },
  84. bottomContainer: {
  85. flex: 7
  86. },
  87. listContainer: {
  88. flex: 0.5,
  89. flexDirection: 'row',
  90. alignItems: 'center',
  91. paddingVertical: 15
  92. },
  93. logoContainer: {
  94. flex: 2,
  95. alignItems: 'center'
  96. },
  97. itemContainer: {
  98. flex: 8
  99. },
  100. item: {
  101. paddingLeft: '6%',
  102. fontSize: 24,
  103. fontWeight: '200'
  104. }
  105. });
  106. export default ChooseCarModel;