React-Native Tutorial To do list [ #10 ]

์กฐํŒ”๋กœยท2020๋…„ 9์›” 21์ผ
0

React-Native-Todolist

๋ชฉ๋ก ๋ณด๊ธฐ
10/15
post-thumbnail

React Native Tutorial ๋”ฐ๋ผํ•˜๊ธฐ ๐Ÿ“ฑ

๐Ÿ“Œ ํŠœํ† ๋ฆฌ์–ผ์„ ๋”ฐ๋ผํ•œ ํ”„๋กœ์ ํŠธ์ž…๋‹ˆ๋‹ค!

์•„์ด์ฝ˜ ์ถ”๊ฐ€ํ•˜๊ธฐ

icons ๋‹ค์šด๋กœ๋“œํ•˜๊ธฐ

TodoListItem ์ปดํฌ๋„ŒํŠธ ์•ˆ์—๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ํ•  ์ผ ๋ชฉ๋ก ๋‚ด์šฉ์ด ๋‹ด๊ธฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ ํ•ด๋‹น ๋ชฉ๋ก์„ ์™„๋ฃŒํ–ˆ๋Š”์ง€ ์ฒดํฌํ•  ์ˆ˜ ์žˆ๋Š” ์ฒดํฌ ๋ฐ•์Šค์™€ ์‚ญ์ œ ๋ฒ„ํŠผ์„ ์ถ”๊ฐ€ํ•ด๋ด…์‹œ๋‹ค. ์•„์ด์ฝ˜์€ react-native-vector-icons ์„ ์„ค์น˜ํ•ด์„œ ์‚ฌ์šฉํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

ํ„ฐ๋ฏธ๋„์— ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ฉ์‹œ๋‹ค!

react-native link react-native-vector-icons

์ฃผ์˜์‚ฌํ•ญ
๋‚˜๋Š” ์ € ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋‹ˆ๊นŒ error๊ฐ€ ๋‚˜์„œ ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ์ž…๋ ฅํ–ˆ๋‹ค.

๋ช…๋ น์–ด

npm install --save react-native-vector-icons
react-native link react-native-vector-icons

error

warn Calling react-native link [packageName] is deprecated in favor of autolinking. It will be removed in the next major release.
Autolinking documentation: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
(node:15376) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
error Unknown dependency. Make sure that the package you are trying to link is already installed in your "node_modules" and present in your "package.json" dependencies. Run CLI with --verbose flag for more details.

๋งŒ์•ฝ ์œ„ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด๋„ ์ž˜ ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด react-native-vector-icons README ๋ฅผ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค. ์„ค์น˜ ๋ฐฉ๋ฒ•๊ณผ ์˜ค๋ฅ˜ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์ด ์ž์„ธํžˆ ๋‚˜์™€์žˆ์Šต๋‹ˆ๋‹ค.

react-native-vector-icons๋Š” ๋‹ค์–‘ํ•œ ์•„์ด์ฝ˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ฒจ๋ถ€ํ•œ ๋งํฌ์— ๋“ค์–ด๊ฐ€์„œ ๋ณธ์ธ ์ทจํ–ฅ์— ๋”ฐ๋ผ ๋‹ค์–‘ํ•œ ์•„์ด์ฝ˜์„ ์„ ํƒํ•ด ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. https://oblador.github.io/react-native-vector-icons/

TodoListItem.js์—์„œ react-native-vector-icons importํ•˜๊ธฐ

import Icon from 'react-native-vector-icons/AntDesign';

StyleSheet ์†์„ฑ ์•ˆ์— ์™„๋ฃŒํ•œ ๋ชฉ๋ก์„ ํ‘œ์‹œํ•ด์ฃผ๋Š” ์Šคํƒ€์ผ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ

const styles = StyleSheet.create({
  ...
  completeCircle: {
    marginRight: 20,
    marginLeft: 20,
  },
  strikeText: {
    color: '#bbb',
    textDecorationLine: 'line-through',
  },
  unstrikeText: {
    color: '#29323c',
  },
  buttonContainer: {
    marginVertical: 10,
    marginHorizontal: 10,
  },
});

์„ค์ •ํ•œ ์Šคํƒ€์ผ์„ ์•„์ด์ฝ˜๊ณผ ํ…์ŠคํŠธ์— ์ ์šฉํ•˜๊ธฐ 1

const TodoListItem = () => {
  return (
    <View style={styles.container}>
      <TouchableOpacity>
        <View style={styles.completeCircle}>
          <Icon name="circledowno" size={30} color="#3143e8" />
        </View>
      </TouchableOpacity>
      <Text style={[styles.text, styles.strikeText]}>
        Items will be shown here
      </Text>
    </View>
  );
};

๊ฒฐ๊ณผ๋ณด๊ธฐ 1

์ด๊ฒŒ ์ •์ƒ

๋‚˜๋Š” ๋น„์ •์ƒ

์„ค์ •ํ•œ ์Šคํƒ€์ผ์„ ์•„์ด์ฝ˜๊ณผ ํ…์ŠคํŠธ์— ์ ์šฉํ•˜๊ธฐ2 [์‚ญ์ œ๋ฒ„ํŠผ]

<TouchableOpacity style={styles.buttonContainer}>
    <Text style={styles.buttonText}>
      <Icon name="delete" size={30} color="#e33057" />
    </Text>
</TouchableOpacity>

๊ฒฐ๊ณผ๋ณด๊ธฐ 2

์ด๊ฒŒ ์ •์ƒ

๋‚˜๋Š” ๋น„์ •์ƒ

๋น„์ •์ƒ์ธ ์ด์œ 

๋ชจ๋ฅด๊ฒ ๊ณ  ์ง€๊ธˆ ํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ๋“ค

  1. ์„ค์น˜
npm install --save-dev @types/react-native-vector-icons
  1. ์„ค์ •

android/app/build.gradle์—

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
  1. ์„ค์ •

์ด๊ฑฐ ๋ณด๊ณ  ๋”ฐ๋ผํ•˜๊ธฐ

react-native link react-native-vector-icons

๊ฒฐ๊ตญ

4์‹œ๊ฐ„ ๋™์•ˆ ์”จ๋ฆ„ํ–ˆ๋Š”๋ฐ ๊ฑ ํฌ๊ธฐํ•˜๋ ต๋‹ˆ๋‹ค. ์ด๊ฑฐ ๋ฌธ์ œ ๊ณ ์น˜๋Š” ๋ฐฉ๋ฒ• ์•„์‹œ๋ฉด ์ œ๋ฐœ ์•Œ๋ ค์ฃผ์„ธ์š” real plz

profile
ํ˜„์‹ค์— ์•ˆ์ฃผํ•˜์ง€ ์•Š๊ณ  - ๊ฐœ๋ฐœ์ž

2๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2021๋…„ 4์›” 22์ผ

ํ•ด๊ฒฐ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜ ์ž…๋‹ˆ๋‹ค.
// android
// '๋ฃจํŠธ ํด๋”'/android/app/build.grandle์— ์•„๋ž˜ ์ฝ”๋“œ ์‚ฝ์ž…

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

๋‹ต๊ธ€ ๋‹ฌ๊ธฐ
comment-user-thumbnail
2021๋…„ 7์›” 13์ผ

https://phant0m.tistory.com/20 ์—ฌ๊ธฐ ์‚ฌ์ดํŠธ ๋“ค์–ด๊ฐ€์„œ ํ•ด๋ณด๋ฉด ์ž˜ ๋ฉ๋‹ˆ๋‹ค

๋‹ต๊ธ€ ๋‹ฌ๊ธฐ