From ea6ce2d6879c0fd6fb2893b03fad138ab52bdaff Mon Sep 17 00:00:00 2001 From: SmashinFries Date: Sun, 31 Oct 2021 03:13:46 -0500 Subject: [PATCH 01/18] added studios --- Components/contentcomp.js | 75 +++++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 7 deletions(-) diff --git a/Components/contentcomp.js b/Components/contentcomp.js index f6e36f9..1748e52 100644 --- a/Components/contentcomp.js +++ b/Components/contentcomp.js @@ -1,6 +1,6 @@ // React import React, { useEffect, useState } from 'react'; -import { View, ScrollView, useWindowDimensions, Pressable, FlatList, Linking, ToastAndroid, Alert, ImageBackground } from 'react-native'; +import { View, ScrollView, useWindowDimensions, Pressable, FlatList, Linking, ToastAndroid, Alert, ActivityIndicator } from 'react-native'; // UI import { Chip, Text, Avatar, Image, Icon, Button, Overlay } from 'react-native-elements'; // Navigation @@ -12,7 +12,7 @@ import Video from 'react-native-video'; import YoutubeIframe from 'react-native-youtube-iframe'; import FastImage from 'react-native-fast-image'; // Data -import { getOverview } from '../Data Handler/getdata'; +import { getOverview, getStudio } from '../Data Handler/getdata'; import { copyText } from '../Screens/character'; import { updateFavorite, updateProgress, updateScore, updateStatus } from '../Data Handler/updatedata'; import Markdown from 'react-native-markdown-display'; @@ -32,6 +32,62 @@ export const SectionInfo = ({header, info, style=null}) => { ); } +export const Studio = ({route}) => { + const { id, token, routeName, name } = route.params; + const [data, setData] = useState([]); + const [page, setPage] = useState({}); + const [refresh, setRefresh] = useState(false); + const [loading, setLoading] = useState(true); + const { colors } = useTheme(); + + useEffect(() => { + let mounted = true; + getStudio(id, token, 1).then(studio => { + if(mounted) { + setData(studio.media.nodes); + setPage(studio.media.pageInfo); + setLoading(false); + } + }); + return () => {mounted = false}; + },[]); + + const onRefresh = async() => { + setRefresh(true); + const studio = await getStudio(id, token, 1); + setData(studio.media.nodes); + setPage(studio.media.pageInfo); + setRefresh(false); + } + + const fetchMore = async() => { + if (page.hasNextPage === true) { + const newData = await getStudio(id, token, page.currentPage + 1); + setData([...data, ...newData.media.nodes]); + setPage(newData.media.pageInfo); + } + } + + if (loading) return + + return( + + <_ContentTile item={item} routeName={routeName} token={token} isSearch={true} />} + keyExtractor={(item, index) => index.toString()} + onEndReached={fetchMore} + onEndReachedThreshold={0.4} + refreshing={refresh} + onRefresh={onRefresh} + numColumns={2} + columnWrapperStyle={{marginVertical:5}} + contentContainerStyle={{paddingVertical:10}} + /> + + ); +} + export const OverView = ({route}) => { const {data, auth, id, tags, lang, routeName} = route.params; const [status, setStatus] = useState((data.mediaListEntry !== null) ? data.mediaListEntry.status : 'Not Added'); @@ -138,6 +194,10 @@ export const OverView = ({route}) => { ); } + const navStudio = () => { + navigation.push('Studio', {id:data.studios.nodes[0].id, token:auth, routeName:routeName, name:data.studios.nodes[0].name}); + } + return( @@ -172,7 +232,6 @@ export const OverView = ({route}) => { {(data.duration !== null) ? : null} {(data.source !== null) ? : null} - {(data.studios.edges.length > 0) ? : null} {(data.title.english !== null) ? : (data.title.english === null && syn.length > 0) ? : null} @@ -193,6 +252,8 @@ export const OverView = ({route}) => { Staff + {(data.studios.nodes.length > 0) ? Studio : null} + {(data.studios.nodes.length > 0) ?