Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: [게시글 생성] 상,하단 컴포넌트 #56

Merged
merged 13 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions front/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
},
"web": {
"favicon": "./assets/favicon.png"
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모듈추가하면서 생긴건가요? 어떤 설정인가요?😀

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안드로이드에서 입력 창을 누르면 키보드가 올라오면서 해결하기 위한 설정입니다 :)

"android": {
"softwareKeyboardLayoutMode": "pan"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

softwareKeyboardLayoutMode 값을 resize로 두었을 때와 어떤 차이가 있을까요? 추가로 태그가 엔터키로도 추가가 되는데, 그럴 경우 키보드가 올려진 화면에서 추가된 태그가 보이지 않아요! 이 문제를 어떻게 해결할 것인지도 생각해봐야 할 것 같아요! (세부적인 사항이라 급하진 않은 내용이네요)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분은 정말 오랜 시간동안 찾아봤는데 마땅한 해결책이 없는 것 같아요..
많은 사람들이 제안하는 방법들을 모두 써봤는데 안드로이드라 그런지 ios와 다른 기능을 수행하더라구요...
추후 해결방법을 알게되면 그때 수정해야할 것 같습니다 ㅜㅡㅜ

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

역시나 이미 했던 고민이군요! 저도 관련된 사항 알게 되면 공유하도록 할게요! ㅎ_ㅎ

}
}
}
5 changes: 3 additions & 2 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@
"@react-navigation/stack": "^5.6.2",
"expo": "~38.0.8",
"expo-image-picker": "^8.3.0",
"expo-permissions": "~9.0.1",
"expo-status-bar": "^1.0.2",
"moment": "^2.27.0",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.1.tar.gz",
"react-native-gesture-handler": "~1.6.1",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-modal": "^11.5.6",
"react-native-reanimated": "~1.9.0",
"react-native-safe-area-context": "~3.0.7",
"react-native-screens": "~2.9.0",
"react-native-web": "~0.11.7",
"recoil": "^0.0.10",
"expo-permissions": "~9.0.1"
"recoil": "^0.0.10"
},
"devDependencies": {
"@babel/core": "^7.8.6",
Expand Down
10 changes: 5 additions & 5 deletions front/src/components/ArticleCreateNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ export default function ArticleCreateNavigation() {
return (
<Stack.Navigator>
<Stack.Screen
name="ArticleCreateHome"
name="ArticleCreateScreen"
component={ArticleCreateScreen}
options={{
title: "글 쓰기",
title: "글쓰기",
}}
/>
<Stack.Screen
name="ArticleCreateForm"
name="ArticleContentsFormScreen"
component={ArticleContentsFormScreen}
options={{
title: "내용 입력",
title: "내용",
}}
/>
<Stack.Screen
name="CategoryChoiceScreen"
component={CategoryChoiceScreen}
options={{
title: "카테고리 선택",
title: "카테고리",
}}
/>
</Stack.Navigator>
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/ArticleCreateOptionsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function ArticleCreateOptionsModal() {
>
<View style={styles.content}>
<Button
title={"글 쓰기"}
title={"글쓰기"}
onPress={() => {
navigation.navigate("글쓰기");
setModalVisible(false);
Expand Down
106 changes: 106 additions & 0 deletions front/src/components/ArticleCreateScreenModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* @author lxxjn0
*/
import React from "react";
import { useNavigation } from "@react-navigation/native";
import { useRecoilState } from "recoil/dist";
import {
Modal,
View,
Text,
TouchableHighlight,
StyleSheet,
} from "react-native";
import { articleModalActivationState } from "../states/articleState";
import { ArticleCreateModalNavigationProp } from "../types/types";

interface ArticleCreateScreenModalProps {
resetCreateScreen: Function;
}

export default function ArticleCreateScreenModal({
resetCreateScreen,
}: ArticleCreateScreenModalProps) {
const navigation = useNavigation<ArticleCreateModalNavigationProp>();
const [articleModalState, setArticleModalState] = useRecoilState(
articleModalActivationState,
);

return (
<Modal
animationType={"fade"}
transparent={true}
visible={articleModalState}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

articleModalState가 boolean 같은데 is 처럼 boolean 값을 나타낼수 있는 네이밍을 변경해주면 어떤가 해서 의견 남겨요 :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 처음엔 is를 접두어로 붙였는데 is 접두어의 경우 boolean을 반환하는 메서드 타입에서 주로 사용하는 것 같더라구요.
사실 State의 경우 메서드라기 보다는 상태를 가지는 변수?와 같은 역할을 한다고 느껴서 위와 같이 네이밍을 했습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그러네요 :) 메서드명으로 is를 붙여주네요 하나 알아갑니다

onRequestClose={() => setArticleModalState(false)}
>
<View style={styles.container}>
<View style={styles.modalContainer}>
<Text style={styles.modalText}>
페이지를 나가면 작성 중인 내용이 삭제됩니다.{"\n"}
페이지를 나가시겠습니까?
</Text>
<View style={styles.buttonContainer}>
<TouchableHighlight
style={styles.button}
onPress={() => setArticleModalState(false)}
>
<Text style={styles.buttonText}>돌아가기</Text>
</TouchableHighlight>
<TouchableHighlight
style={styles.button}
onPress={() => {
resetCreateScreen();
setArticleModalState(false);
navigation.goBack();
}}
>
<Text style={styles.buttonText}>나가기</Text>
</TouchableHighlight>
</View>
</View>
</View>
</Modal>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
},
modalContainer: {
backgroundColor: "white",
borderRadius: 20,
padding: 25,
alignItems: "center",
shadowColor: "black",
shadowOffset: {
width: 3,
height: 5,
},
shadowOpacity: 0.25,
shadowRadius: 5,
elevation: 3,
},
modalText: {
marginBottom: 20,
textAlign: "center",
},
buttonContainer: {
flexDirection: "row",
},
button: {
backgroundColor: "#dfd3c3",
borderRadius: 20,
marginHorizontal: 5,
padding: 10,
elevation: 2,
},
buttonText: {
color: "white",
fontWeight: "bold",
textAlign: "center",
marginHorizontal: 10,
},
});
10 changes: 5 additions & 5 deletions front/src/components/ArticlePriceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import React from "react";
import { StyleSheet, TextInput } from "react-native";
import { useRecoilState } from "recoil/dist";
import { articlePriceState } from "../states/articleState";
import { insertComma, removeComma } from "../replacePriceWithComma";

export default function ArticlePriceForm() {
const [price, setPrice] = useRecoilState(articlePriceState);

return (
<TextInput
style={styles.form}
placeholder={"가격 입력"}
placeholder={"가격"}
keyboardType={"number-pad"}
maxLength={10}
onChangeText={(text) => setPrice(Number(text))}
value={price === 0 ? "" : price.toString()}
onChangeText={(priceValue) => setPrice(Number(removeComma(priceValue)))}
value={price === 0 ? "" : insertComma(price.toString())}
/>
);
}

const styles = StyleSheet.create({
form: {
fontSize: 30,
paddingLeft: 15,
fontSize: 18,
},
});
5 changes: 2 additions & 3 deletions front/src/components/ArticleTitleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function ArticleTitleForm() {
return (
<TextInput
style={styles.form}
placeholder={"제목 입력"}
placeholder={"제목"}
keyboardType={"default"}
maxLength={30}
onChangeText={(text) => setTitle(text)}
Expand All @@ -24,7 +24,6 @@ export default function ArticleTitleForm() {

const styles = StyleSheet.create({
form: {
fontSize: 30,
paddingLeft: 15,
fontSize: 18,
},
});
2 changes: 1 addition & 1 deletion front/src/components/BottomTabNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function BottomTabNavigation() {
tabBarIcon: ({ color }) => (
<MaterialCommunityIcons
name="home-outline"
size={26}
size={24}
color={color}
/>
),
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/CategoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { CategoryItemProps } from "../types/types";
import { useRecoilState } from "recoil/dist";
import { useNavigation } from "@react-navigation/native";
import { articleSelectedCategoryState } from "../states/articleState";
import { CategoryItemProps } from "../types/types";

export default function CategoryItem({ title }: CategoryItemProps) {
const navigation = useNavigation();
Expand Down
Loading