Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신승민
/
pocketMovie
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
korkeep
2019-12-09 01:26:36 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e7a8c9e41746b301a47c90454283f5ba02b87e0b
e7a8c9e4
1 parent
0827932f
12/9 합쳤다git add *!
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
12 deletions
Components/AppTabNavigator/MovieRankingTab.js
Components/AppTabNavigator/WantToWatchTab.js
Components/AppTabNavigator/MovieRankingTab.js
View file @
e7a8c9e
...
...
@@ -207,11 +207,16 @@ export default class MovieRankingTab extends Component {
var
date
=
year
+
""
+
month
+
day
;
this
.
getMovieList
(
date
);
}
//눌렀을 때 저장함수
_onPressButton
(
temp
)
{
Alert
.
alert
(
temp
);
//메시지 띄우고
console
.
log
(
temp
);
//콘솔에 log 띄운다
AsyncStorage
.
setItem
(
"MovieLists"
,
temp
);
//DB에 저장한다
//this.state.list = ""; //초기화(On Off 기능으로 짜놨습니당, 누적되는거 보고싶으면 이부분 주석달면 돼여)
Alert
.
alert
(
temp
);
//메시지 띄우고
this
.
state
.
list
=
this
.
state
.
list
+
'\n'
+
temp
;
//list 누적해준다(endl으로 구분)
console
.
log
(
this
.
state
.
list
);
//콘솔에 log 띄운다
AsyncStorage
.
setItem
(
'MovieLists'
,
this
.
state
.
list
);
//DB에 저장한다
}
render
()
{
return
(
<
SafeAreaView
style
=
{
style
.
container
}
>
...
...
Components/AppTabNavigator/WantToWatchTab.js
View file @
e7a8c9e
import
React
,
{
Component
}
from
"react"
;
import
{
View
,
Text
,
StyleSheet
}
from
"react-native"
;
import
React
,
{
Component
}
from
'react'
;
import
{
StyleSheet
,
Text
,
View
,
TouchableOpacity
,
AsyncStorage
,
ScrollView
,
Image
,
}
from
'react-native'
;
import
{
Icon
}
from
"native-base"
;
import
axios
from
"axios"
;
const
API_KEY
=
"2bf00f660b1a6a3ffeb6e06ac270cce3"
;
const
NAVER_CLIENT_ID
=
"KqPsntd1hcPJ8FUPBGqN"
;
const
NAVER_CLIENT_SECRET
=
"0GRb3uya1U"
;
export
default
class
WantToWatchTab
extends
Component
{
export
default
class
App
extends
Component
{
state
=
{
list
:
""
,
//영화 제목 list
date
:
""
,
//날짜
imgurl0
:
[],
//이미지
name0
:
[],
//제목
};
//날짜 정하기
componentDidMount
()
{
var
day
=
new
Date
().
getDate
()
-
1
;
// 어제 날짜
if
(
day
==
1
)
{
day
=
30
;
}
else
if
(
day
<
10
)
{
day
=
"0"
+
day
;
}
var
month
=
new
Date
().
getMonth
()
+
1
;
//Current Month
var
year
=
new
Date
().
getFullYear
();
//Current Year
var
date
=
year
+
""
+
month
+
day
;
this
.
getMovieList
(
date
);
this
.
setData
();
}
getMovieList
=
async
date
=>
{
axios
.
get
(
`http://www.kobis.or.kr/kobisopenapi/webservice/rest/boxoffice/searchDailyBoxOfficeList.json?key=
${
API_KEY
}
&targetDt=
${
date
}
`
)
.
then
(
response
=>
{
this
.
setState
({
//영화 제목
name0
:
response
.
data
.
boxOfficeResult
.
dailyBoxOfficeList
[
0
].
movieNm
,
});
temp
=
response
.
data
.
boxOfficeResult
.
dailyBoxOfficeList
[
0
].
movieNm
;
fetch
(
`https://openapi.naver.com/v1/search/movie.json?query='
${
temp
}
'`
,
{
headers
:
{
"X-Naver-Client-Id"
:
NAVER_CLIENT_ID
,
"X-Naver-Client-Secret"
:
NAVER_CLIENT_SECRET
}
}
)
.
then
(
response
=>
response
.
json
())
.
then
(
json
=>
{
this
.
setState
({
imgurl0
:
json
.
items
[
0
].
image
});
});
}
)
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
//네비게이션 바
static
navigationOptions
=
{
tabBarIcon
:
({
tintColor
})
=>
(
<
Icon
name
=
"ios-star"
style
=
{{
color
:
tintColor
}}
/
>
<
Icon
name
=
'ios-star'
style
=
{{
color
:
tintColor
}}
/
>
)
};
}
//Data 설정함수
setData
=
async
()
=>
{
try
{
this
.
state
.
list
=
await
AsyncStorage
.
getItem
(
'MovieLists'
);
//List에 받아온다
//console.log(this.state.list); //잘 뜨는데??
}
catch
(
error
)
{
alert
(
error
)
}
}
render
()
{
return
(
<
View
style
=
{
style
.
container
}
>
<
Text
>
WantToWatchTab
<
/Text
>
<
View
style
=
{
styles
.
container
}
>
<
TouchableOpacity
onPress
=
{
this
.
componentDidMount
.
bind
(
this
)}
>
{
/* 눌러용 누르면 리스트 갱신됩니다 */
}
<
Text
style
=
{
styles
.
textStyle
}
>
눌러용
<
/Text
>
<
/TouchableOpacity
>
<
Text
style
=
{
styles
.
textStyle
}
>
{
this
.
state
.
list
}
<
/Text
>
<
/View
>
);
}
}
const
style
=
StyleSheet
.
create
({
const
style
s
=
StyleSheet
.
create
({
container
:
{
backgroundColor
:
"black"
,
flex
:
1
,
alignItems
:
"center"
,
justifyContent
:
"center"
}
},
textStyle
:
{
fontSize
:
25
,
color
:
"white"
,
},
});
...
...
Please
register
or
login
to post a comment