1. Native App2. React Native3. Electron4. Reactive Native ์ค์ต4.1. ์ค์ต ์ ์ค๋น ์ฌํญsnack ์ฌ์ฉ๋ฒ4.2. App.js4.3. App.js ์ฝ๋ ์์ (Text ๋ถ๋ถ๋ง ์์ )4.4. WebView 4.5. ํ๋ฉด ๋ถํ 14.6. ํ๋ฉด ๋ถํ 24.7. ์นด๋ฉ๋ผ ๋กค5. ๊ณต์๋ฌธ์
1. Native App
Android, ios์ฒ๋ผ ๊ฐ๊ฐ์ ์ด์์ฒด์ ํ๊ฒฝ์ ๋ง์ถฐ์ ๊ฐ๋ฐํ ์ฑ์ ๋งํฉ๋๋ค. ์ฆ, ๊ฐ๋ฐ์ ํ ๋ Android๋ Android Studio, ios๋ Swift๋ฅผ ์ด์ฉํด์ ๊ฐ๋ฐํฉ๋๋ค. Native App์ ์ฑ๋ฅ์ด ์น์ฑ , ํ์ด๋ธ๋ฆฌ๋ ์ฑ์ ๋นํ์ฌ ๊ฐ์ฅ ๋์ง๋ง, ํ๋ซํผ์ ์์กด์ ์ด๊ธฐ ๋๋ฌธ์ ํด๋น ์ธ์ด๋ฅผ ๋ค๋ฃฐ ์ ์์ด์ผ ๊ฐ๋ฐ ๊ฐ๋ฅํ๋ค๋ ๋จ์ ์ด ์์ต๋๋ค.
ย
2. React Native
Native App๊ณผ ๋ฌ๋ฆฌ, ์ด์์ฒด์ ์ ๊ตฌ์ ๋ฐ์ง ์๊ณ ํ๋์ ์ธ์ด๋ก ์ฑ์ ๊ฐ๋ฐํ๋ ๋ฐฉ๋ฒ๋ ์์ต๋๋ค. ์ด๋ฅผ Hybrid App์ด๋ผ๊ณ ํ๊ณ , React Native๋ฅผ ์ด์ฉํด์ ๊ฐ๋ฐ ๊ฐ๋ฅํฉ๋๋ค.
ย
3. Electron
Node.js ๊ธฐ๋ฐ์ ํ๋ซํผ์ผ๋ก, ๋ฐ์คํฌํ App ๊ฐ๋ฐ์ด ๊ฐ๋ฅํฉ๋๋ค. ๋ํ์ ์ธ ์ฑ์ผ๋ก๋ VScode, Atom ๋ฑ์ด ์์ต๋๋ค.
ย
4. Reactive Native ์ค์ต
React Native๋ก 5๋ถ๋ง์ ์์ฑํ๋ ์น์ฑ(๊ตฌ๋ฆIDE + Expo) ์ค์ต์ ์ ํ๋ธ์์๋ ํ์ธํ ์ ์์ต๋๋ค.๐ (https://bit.ly/3iN5Bb9)
ย
4.1. ์ค์ต ์ ์ค๋น ์ฌํญ
- ๊ตฌ๋ฆ IDE ๋ก๊ทธ์ธ & React Native ์ปจํ ์ด๋ ์์ฑ (ํ์์ด ์๋๋ฉด ํ์๊ฐ์ ๋ถํฐ ์งํํด ์ฃผ์ธ์!)
- ์ฑ์คํ ์ด / ํ๋ ์ด์คํ ์ด์์ Expo ์ค์น ๋๋ snack(https://snack.expo.io/) ์ค๋น ๋ค๋ง, Snack์ ๊ฒฝ์ฐ ๋๊ธฐ ์๊ฐ์ด ๊ฑธ๋ฆฌ๊ธฐ ๋๋ฌธ์ Expo ์ค์น๋ฅผ ๊ถ์ฅํฉ๋๋ค.
ย
snack ์ฌ์ฉ๋ฒ
ย
์ค์ต ์ค ์๋์ ๊ฐ์ ํ๋ฉด์ด ๋จ๋ฉด 'Add dependency'๋ฅผ ํด๋ฆญํด ์์กด์ฑ์ ์ถ๊ฐํ๋ฉด ๋ฉ๋๋ค.
4.2. App.js
import * as React from 'react'; import { Text, View, StyleSheet } from 'react-native'; import Constants from 'expo-constants'; // You can import from local files import AssetExample from './components/AssetExample'; // or any pure javascript modules available in npm import { Card } from 'react-native-paper'; export default function App() { return ( <View style={styles.container}> <Text style={styles.paragraph}> Change code in the editor and watch it change on your phone! Save to get a shareable url. </Text> <Card> <AssetExample /> </Card> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', paddingTop: Constants.statusBarHeight, backgroundColor: '#ecf0f1', padding: 8, }, paragraph: { margin: 24, fontSize: 18, fontWeight: 'bold', textAlign: 'center', }, });
ย
ย
4.3. App.js ์ฝ๋ ์์ (Text ๋ถ๋ถ๋ง ์์ )
import * as React from 'react'; import { Text, View, StyleSheet } from 'react-native'; import Constants from 'expo-constants'; // You can import from local files import AssetExample from './components/AssetExample'; // or any pure javascript modules available in npm import { Card } from 'react-native-paper'; export default function App() { return ( <View style={styles.container}> <Text style={styles.paragraph}> Hello World! </Text> <Card> <AssetExample /> </Card> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', paddingTop: Constants.statusBarHeight, backgroundColor: '#ecf0f1', padding: 8, }, paragraph: { margin: 24, fontSize: 18, fontWeight: 'bold', textAlign: 'center', }, });
ย
4.4. WebView
import * as React from 'react'; import { WebView } from 'react-native-webview'; export default class App extends React.Component { render() { return <WebView source={{ uri: 'https://paullab.co.kr/about.html' }} style={{ marginTop: 20 }} />; } }
ย
ย
4.5. ํ๋ฉด ๋ถํ 1
import React, {Component} from 'react'; import {StyleSheet, Text, View} from 'react-native'; export default class App extends Component<Props> { render() { return ( <View style={styles.container}> <View style={styles.case1} /> <View style={styles.case2} /> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'white', }, case1: { flex: 1, backgroundColor: 'red', }, case2: { flex: 1, backgroundColor: 'blue', }, });
ย
ย
4.6. ํ๋ฉด ๋ถํ 2
import React, {Component} from 'react'; import {StyleSheet, Text, View} from 'react-native'; export default class App extends Component<Props> { render() { return ( <View style={styles.container}> <View style={styles.case1} /> <View style={styles.case2} /> <View style={styles.case3} /> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'white', }, case1: { flex: 1, backgroundColor: 'red', }, case2: { flex: 2, backgroundColor: 'green', }, case3: { flex: 1, backgroundColor: 'blue', }, });
ย
4.7. ์นด๋ฉ๋ผ ๋กค
import React, { useState, useEffect } from 'react'; import { Button, Image, View, Platform } from 'react-native'; import * as ImagePicker from 'expo-image-picker'; import Constants from 'expo-constants'; export default function ImagePickerExample() { const [image, setImage] = useState(null); useEffect(() => { (async () => { if (Platform.OS !== 'web') { const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync(); if (status !== 'granted') { alert('Sorry, we need camera roll permissions to make this work!'); } } })(); }, []); const pickImage = async () => { let result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.All, allowsEditing: true, aspect: [4, 3], quality: 1, }); console.log(result); if (!result.cancelled) { setImage(result.uri); } }; return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Button title="Pick an image from camera roll" onPress={pickImage} /> {image && <Image source={{ uri: image }} style={{ width: 200, height: 200 }} />} </View> ); }
ย
ย