일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 데이터 종류에 따른 분석 방법
- 주성분 줄이기
- 날짜 시간 데이터 전처리
- 명목형 데이터
- 다중상관분석
- 최소-최대 정규화
- Z-점수 기반 이상치 탐지
- ARIMA 모델링
- 시계열 특성을 고려한 이상치 탐지
- ARMA 모델링
- 다변량 분석
- 상관 분석
- 군집화 시각화 방법
- 데이터 수집 및 전처리
- 데이터의 차원 축소
- 순서형 데이터
- 시계열 모델링
- Q-Q 플롯
- 주성분 분석
- 데이터 분석 프로세스
- 지수평활법
- 계절성 모델
- 상자 그림
- R과 Python
- 선형 판별 분석 LDA
- Python
- 범주형 데이터
- custom vision
- 상위포지션
- 시계열 상관 분석
Archives
- Today
- Total
me made it !
[React] 날씨 앱 만들기 본문
반응형
import * as Location from "expo-location"
import React, { useEffect, useState } from "react";
import {View, Text, Dimensions, StyleSheet, ScrollView, ActivityIndicator} from 'react-native';
const { width : SCREEN_WIDTH } = Dimensions.get('window');
const API_KEY = "f80a82d6f4ca6e9ecaeb1386c05dfb87"
export default function App() {
const [city, setCity] = useState("Loading...")
const [days, setDays] = useState([]);
const [ok, setOk] = useState(true);
const ask = async() => {
const {granted} = await Location.requestForegroundPermissionsAsync();
if (!granted) {
setOk(false);
}
const {coords: {latitude, longitude}} = await Location.getCurrentPositionAsync({accuracy: 5});
const location = await Location.reverseGeocodeAsync(
{latitude, longitude},
{useGoogleMaps:false}
);
setCity(location[0].city);
const response = await fetch(`https://api.openweathermap.org/data/2.5/forecast?lat=${latitude}&lon=${longitude}&appid=${API_KEY}&units=metric`)
const json = await response.json();
setDays(
json.list.filter((weather) => {
if (weather.dt_txt.includes("00:00:00")) {
return weather;
}
})
);
};
useEffect(() => {
ask();
}, [])
return (
<View style={styles.container}>
<View style={styles.city}>
<Text style={styles.cityName}>{city}</Text>
</View>
<ScrollView
showsHorizontalScrollIndicator
pagingEnabled
indicatorStyle="white"
horizontal contentContainerStyle={styles.weather}
>
{days.length === 0 ? (
<View style={styles.day}>
<ActivityIndicator color ="white" size = "large" style = {{marginTop:10}} ></ActivityIndicator>
</View>
) : (
days.map((day, index) =>
<View key={index} style={styles.day}>
<Text style={styles.temp}>{parseFloat(day.main.temp).toFixed(1)}</Text>
<Text style={styles.description}>{day.weather[0].main}</Text>
<Text style={styles.tinyText}>{day.weather[0].description}</Text>
</View>
)
)}
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
container:{
flex:1,
backgroundColor : "tomato",
},
city : {
flex : 1.2,
// backgroundColor: "blue",
justifyContent: "center",
alignItems: "center",
},
cityName: {
color : "black",
fontSize : 80,
fontWeight: "500",
},
weather : {
// backgroundColor : "blue",
},
day: {
width: SCREEN_WIDTH,
alignItems : "center",
// backgroundColor: "teal",
},
temp : {
marginTop : 50,
fontSize : 156,
},
description : {
marginTop : -10,
fontSize : 50
},
tinyText : {
fontSize : 20,
}
});
위치정보 로드
로딩중 화면 생성
레이아웃에 맞는 페이지 설정
스크롤 설정
반응형
'TIL > React' 카테고리의 다른 글
[React] to-do list 만들기 (0) | 2023.09.05 |
---|---|
[React] to-do list 만들기 (0) | 2023.09.05 |
[React] (0) | 2023.09.05 |
[React] flex에 대하여 (반응형 레이아웃 만들기) (0) | 2023.09.04 |
[React] (0) | 2023.09.04 |