Skip to content

Commit

Permalink
fix: checkListTypeC
Browse files Browse the repository at this point in the history
사진을 터치했을 때 해당 사진으로 바로 이동
#70
  • Loading branch information
11t518s committed Mar 31, 2022
1 parent ff85ca9 commit 0e3d630
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
11 changes: 9 additions & 2 deletions components/CheckListComponent/ButtonsOfTypeC.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Dispatch, SetStateAction } from 'react';
import React, { Dispatch, SetStateAction, useState } from 'react';
import { DefaultText } from '../../CustomText';
import { checkListTypes } from '../../types/checkListTypes';
import { Image, Pressable, View } from 'react-native';
Expand All @@ -12,6 +12,7 @@ interface IProps {
}

function ButtonsOfTypeC({ setModal, modal, checkList }: IProps) {
const [order, setOrder] = useState<number | undefined>(0);
return (
<>
<View style={styles.imageWrapper}>
Expand All @@ -21,6 +22,7 @@ function ButtonsOfTypeC({ setModal, modal, checkList }: IProps) {
key={item.id}
onPress={() => {
setModal ? setModal(true) : null;
setOrder(item.order);
}}
>
<Image
Expand All @@ -38,7 +40,12 @@ function ButtonsOfTypeC({ setModal, modal, checkList }: IProps) {
))}
</View>
{checkList?.answer?.some((item) => item.id) ? (
<CheckListImage checkList={checkList.answer} setModal={setModal} modal={modal} />
<CheckListImage
order={order}
checkList={checkList.answer}
setModal={setModal}
modal={modal}
/>
) : null}
</>
);
Expand Down
10 changes: 8 additions & 2 deletions components/CheckListComponent/CheckListImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Dispatch, SetStateAction, useContext, useRef, useState } from 'r
import { DefaultText } from '../../CustomText';
import Modal from 'react-native-modal';
import { Dimensions, Image, Pressable, View } from 'react-native';
import Carousel, { Pagination } from 'react-native-snap-carousel';
import Carousel from 'react-native-snap-carousel';
import { answerButtonType } from '../../types/checkListTypes';
import styles from './styles';
import axios from 'axios';
Expand All @@ -12,10 +12,11 @@ interface IProps {
checkList: answerButtonType[];
setModal?: Dispatch<SetStateAction<boolean>>;
modal?: boolean;
order: number;
}
const windowWidth = Dimensions.get('window').width;

function CheckListImage({ checkList, setModal, modal }: IProps) {
function CheckListImage({ checkList, setModal, modal, order }: IProps) {
const checkListContext = useContext(checkListCtx);
const [index, setIndex] = useState(0);
const isCarousel = useRef(null);
Expand All @@ -33,11 +34,15 @@ function CheckListImage({ checkList, setModal, modal }: IProps) {
setModal ? setModal(false) : null;
}
};
console.log(checkList);

const renderItem = ({ item }: any) => {
return (
<View style={styles.selectedImageWrapper}>
<Image style={styles.selectedImage} resizeMode="cover" source={{ uri: item.url }} />
<DefaultText style={{ color: 'white', marginTop: 20 }}>
{item.order + 1} / {checkList.length}
</DefaultText>
<Pressable style={styles.imageSelectButtonWrapper} onPress={() => mainImageHandler(item)}>
<DefaultText style={styles.selectMainImageText}>대표 사진으로 설정</DefaultText>
</Pressable>
Expand All @@ -57,6 +62,7 @@ function CheckListImage({ checkList, setModal, modal }: IProps) {
<Image source={require('../../assets/images/common/X.png')} />
</Pressable>
<Carousel
firstItem={order}
ref={isCarousel}
data={checkList}
sliderWidth={windowWidth}
Expand Down
2 changes: 1 addition & 1 deletion components/CheckListComponent/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const styles = StyleSheet.create({
imageSelectButtonWrapper: {
marginHorizontal: 17,
backgroundColor: 'white',
marginTop: 100,
marginTop: 80,
paddingVertical: 20,
width: windowWidth - 34,
alignItems: 'center',
Expand Down
1 change: 1 addition & 0 deletions types/checkListTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface answerButtonType {
id?: number;
main?: boolean;
url?: string;
order?: number;
}

export interface answerListType {
Expand Down

0 comments on commit 0e3d630

Please sign in to comment.