carModel.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. renderItem={({ item }) => (
  44. <Pressable onPress={() => handleSelectModel(item.name)}>
  45. <View style={styles.listContainer}>
  46. <View style={styles.logoContainer}>
  47. <Text
  48. style={{
  49. fontSize: 24,
  50. fontWeight: '200'
  51. }}
  52. >
  53. {'logo'}
  54. </Text>
  55. </View>
  56. <View style={styles.itemContainer}>
  57. <Text style={styles.item}>{item.name}</Text>
  58. </View>
  59. </View>
  60. </Pressable>
  61. )}
  62. />
  63. </View>
  64. </View>
  65. );
  66. };
  67. const styles = StyleSheet.create({
  68. mainContainer: {
  69. flex: 1,
  70. flexDirection: 'column',
  71. backgroundColor: '#FFFFFF'
  72. },
  73. titleContainer: {
  74. flex: 1,
  75. alignItems: 'center',
  76. justifyContent: 'center'
  77. },
  78. paginationContainer: {
  79. flex: 0.3,
  80. paddingLeft: '6%',
  81. paddingBottom: '5%'
  82. },
  83. bottomContainer: {
  84. flex: 7
  85. },
  86. listContainer: {
  87. flex: 0.5,
  88. flexDirection: 'row',
  89. alignItems: 'center',
  90. paddingVertical: 15
  91. },
  92. logoContainer: {
  93. flex: 2,
  94. alignItems: 'center'
  95. },
  96. itemContainer: {
  97. flex: 8
  98. },
  99. item: {
  100. paddingLeft: '6%',
  101. fontSize: 24,
  102. fontWeight: '200'
  103. }
  104. });
  105. export default ChooseCarModel;