일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 최소-최대 정규화
- Python
- 군집화 시각화 방법
- 시계열 모델링
- 시계열 특성을 고려한 이상치 탐지
- ARIMA 모델링
- 주성분 분석
- 순서형 데이터
- Q-Q 플롯
- 상위포지션
- 상자 그림
- custom vision
- R과 Python
- 데이터 수집 및 전처리
- 명목형 데이터
- 상관 분석
- 지수평활법
- 다변량 분석
- 선형 판별 분석 LDA
- 데이터 분석 프로세스
- 계절성 모델
- 다중상관분석
- ARMA 모델링
- 주성분 줄이기
- 날짜 시간 데이터 전처리
- 데이터의 차원 축소
- 시계열 상관 분석
- Z-점수 기반 이상치 탐지
- 범주형 데이터
- 데이터 종류에 따른 분석 방법
Archives
- Today
- Total
me made it !
[React] 배운데까지 일단 정리 본문
반응형
import { StatusBar } from 'expo-status-bar';
import React, { useEffect, useState } from 'react';
import {
StyleSheet,
Text,
View,
TouchableOpacity,
TouchableHighlight,
TouchableWithoutFeedback,
TextInput,
Pressable,
ScrollView
} from 'react-native';
import { theme } from "./colors";
import AsyncStorage from '@react-native-async-storage/async-storage';
const STORAGE_KEY = "@toDos";
export default function App() {
const [working, setWorking] = useState(true);
const [text, setText] = useState("");
const [toDos, setToDos] = useState({});
useEffect(() => {
loadToDos();
}, []);
const travel = () => setWorking(false);
const work = () => setWorking(true);
const onChangeText = (payload) => setText(payload);
const saveToDos = async (toSave) => {
await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(toSave))
};
const loadToDos = async () => {
const s = await AsyncStorage.getItem(STORAGE_KEY);
console.log(s);
s !== null ? setToDos(JSON.parse(s)) : null;
};
const addToDo = async () => {
if(text === ""){
return;
}
const newToDos = {
...toDos,
[Date.now()]: {text, working},
};
setToDos(newToDos);
await saveToDos(newToDos);
setText("");
};
return (
<View style={styles.container}>
<StatusBar style="auto" />
<View style={styles.header}>
<TouchableOpacity onPress={work}>
<Text style={{...styles.btnText, color: working ? "white" : theme.grey}}>
Work
</Text>
</TouchableOpacity>
<TouchableOpacity onPress={travel}>
<Text style={{...styles.btnText, color: !working ? "white" : theme.grey}}>
Travel
</Text>
</TouchableOpacity>
</View>
<TextInput
onSubmitEditing={addToDo}
onChangeText={onChangeText}
value={text}
returnKeyType='done'
autoCapitalize={"none"}
placeholder={
working ? "What do you have to do": "Where do you want to go"
}
style={styles.input}
/>
<ScrollView>
{Object.keys(toDos).map((key) =>
toDos[key].working === working ? (
<View style={styles.toDo} key={key}>
<Text style={styles.toDoText}>{toDos[key].text}</Text>
</View>
) : null
)}
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: theme.bg,
paddingHorizontal: 20
},
header : {
justifyContent: "space-between",
flexDirection: "row",
marginTop : 100,
},
btnText : {
fontSize : 38,
fontWeight: "700",
color : "white",
},
input: {
backgroundColor : "white",
paddingVertical: 20,
paddingLeft : 20,
borderRadius: 30,
marginVertical: 20,
fontSize : 18,
},
toDo : {
backgroundColor : theme.toDOBg,
marginBottom : 10,
paddingVertical : 20,
paddingHorizontal : 20,
borderRadius : 15,
},
toDoText : {
color : "white",
fontSize : 16,
fontWeight : "600",
},
});
반응형
'TIL > React' 카테고리의 다른 글
[React] 최종 recap (0) | 2023.09.06 |
---|---|
[React] 삭제 버튼 만들기 (0) | 2023.09.06 |
[React] Object.assign()에 대하여 (0) | 2023.09.06 |
[React] to-do list 만들기 (0) | 2023.09.05 |
[React] to-do list 만들기 (0) | 2023.09.05 |