-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add PostDetailLive screen to fetch article from server
- Loading branch information
Showing
9 changed files
with
77 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import gql from 'graphql-tag' | ||
|
||
const GET_ARTICLE_QUERY = gql` | ||
query articleQuery($_id: String!) { | ||
getArticle(_id: $_id) { | ||
_id | ||
title | ||
shortDescription | ||
content | ||
link | ||
imageLink | ||
createdDate | ||
modifiedDate | ||
category | ||
tags | ||
source { | ||
_id | ||
name | ||
logoLink | ||
} | ||
} | ||
} | ||
` | ||
|
||
export default GET_ARTICLE_QUERY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
import { View } from 'react-native' | ||
import { Placeholder, PlaceholderLine } from 'rn-placeholder' | ||
|
||
const Loading = () => { | ||
const holders = Array.from(Array(5)) | ||
|
||
return ( | ||
<View style={{ paddingTop: 60, padding: 20 }}> | ||
<Placeholder> | ||
<PlaceholderLine height={20} width={100} /> | ||
{holders.map((item, index) => ( | ||
<PlaceholderLine key={index} height={15} width={90} /> | ||
))} | ||
</Placeholder> | ||
</View> | ||
) | ||
} | ||
|
||
export default Loading |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
import { useQuery } from '@apollo/client' | ||
import PostDetail from './index' | ||
import GET_ARTICLE_QUERY from './GET_ARTICLE_QUERY' | ||
import Loading from './Loading' | ||
|
||
const PostDetailLive = ({ navigation, route }) => { | ||
const articleId = route?.params?.articleId | ||
|
||
const { loading, data } = useQuery(GET_ARTICLE_QUERY, { | ||
variables: { _id: articleId }, | ||
}) | ||
|
||
if (loading) return <Loading /> | ||
else return <PostDetail article={data.getArticle} navigation={navigation} /> | ||
} | ||
|
||
export default PostDetailLive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters