From 2ad13cf40cecf42c24b373dddb4485f1c821f027 Mon Sep 17 00:00:00 2001 From: SmashinFries Date: Fri, 29 Oct 2021 19:25:34 -0500 Subject: [PATCH 01/18] removed --- api/getdata.js | 299 ---------------------------------------------- api/getstorage.js | 25 ---- api/updatedata.js | 66 ---------- 3 files changed, 390 deletions(-) delete mode 100644 api/getdata.js delete mode 100644 api/getstorage.js delete mode 100644 api/updatedata.js diff --git a/api/getdata.js b/api/getdata.js deleted file mode 100644 index 8bfa537..0000000 --- a/api/getdata.js +++ /dev/null @@ -1,299 +0,0 @@ -import axios from 'axios'; -import { ACTIVITY, AUTH_USER_QUERY, CHARACTERS, FILTER_QUERY, FOLLOWING_QUERY, HPQUERY, ITEMQUERY, LISTS, REVIEWS, USER_QUERY, USER_SEARCH, VA_QUERY } from '../Queries/query'; -import { cacheA, cacheM, cacheN, cacheS, cacheFilter } from '../Queries/query'; -import { getNSFW } from '../Components/storagehooks'; - -const url = 'https://graphql.anilist.co'; -const perPage = 8; - -const date = new Date(); -export const time = date.getTime(); -let year = date.getFullYear(); -let month = date.getMonth() + 1; -let nextYear = year; -let season = ''; -let nextSeason = ''; - -// Lots of if statements... :| - -if (month <= 3 ) { - season = 'WINTER'; - nextSeason = 'SPRING'; -} else if (month > 3 && month <= 6 ) { - season = 'SPRING'; - nextSeason = 'SUMMER'; -} else if (month > 6 && month <= 9) { - season = 'SUMMER'; - nextSeason = 'FALL'; -} else if (month > 9 && month <= 12) { - season = 'FALL'; - nextSeason = 'WINTER'; - nextYear +=1; -} - -export const getDateDiff = (createdAt) => { - const dateNew = new Date(); - let timeDifference = dateNew.getTime() - createdAt; - const daysDif = Math.floor(timeDifference/1000/60/60/24); - - const hoursDif = Math.floor(timeDifference/1000/60/60); - - const minutesDif = Math.floor(timeDifference/1000/60); - - const secondsDif = Math.floor(timeDifference/1000); - return{daysDif, hoursDif, minutesDif, secondsDif}; -} - -export const getSeason = async (page=1, isAdult=undefined, token=undefined, onList=undefined) => { - try { - if (cacheA.Season.Page.currentPage < page || Object.keys(cacheA.Season.Page).length === 0 ) { - const data = await axios.post(url, {query: HPQUERY, variables:{page:page, perPage:perPage, onList:onList, isAdult: isAdult, sort:'POPULARITY_DESC', type:"ANIME", season:season, seasonYear:year}}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}} ); - const media = await data.data.data.Page.media; - const pages = await data.data.data.Page.pageInfo; - cacheA.Season.content = await [...cacheA.Season.content, ...media]; - cacheA.Season.Page = await pages; - return cacheA.Season.content; - } - } catch (error) { - console.error(error); - } -} - -export const getNextSeason = async (page=1, isAdult=undefined, token=undefined, onList=undefined) => { - try { - if (cacheA.NextSeason.Page.currentPage < page || Object.keys(cacheA.NextSeason.Page).length === 0) { - const data = await axios.post(url, {query: HPQUERY, variables:{page:page, perPage:perPage, onList:onList, isAdult: isAdult, sort:'POPULARITY_DESC', type:"ANIME", season:nextSeason, seasonYear:nextYear}}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Page.media; - const pages = await data.data.data.Page.pageInfo; - cacheA.NextSeason.content = await [...cacheA.NextSeason.content, ...media]; - cacheA.NextSeason.Page = await pages; - return cacheA.NextSeason.content; - } - } catch (error) { - console.error(error); - } -} - -export const getTrend = async (type, page=1, format=undefined, isAdult=undefined, token=undefined, onList=undefined) => { - try { - if (((type === "ANIME" && cacheA.Trending.Page.currentPage < page) || Object.keys(cacheA.Trending.Page).length === 0 ) || - ((type === "MANGA" && cacheM.Trending.Page.currentPage < page) || Object.keys(cacheM.Trending.Page).length === 0) || - ((format === "NOVEL" && cacheN.Trending.Page.currentPage < page) || Object.keys(cacheN.Trending.Page).length === 0)) { - const data = await axios.post(url, {query: HPQUERY, variables:{page:page, perPage:perPage, onList:onList, sort:'TRENDING_DESC', isAdult: isAdult, format:format, type:type}}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Page.media; - const pages = await data.data.data.Page.pageInfo; - if (type === "ANIME") {cacheA.Trending.content = [...cacheA.Trending.content, ...media]; cacheA.Trending.Page = pages; return cacheA.Trending.content;} - if (type === "MANGA" && format !== "NOVEL") {cacheM.Trending.content = [...cacheM.Trending.content, ...media]; cacheM.Trending.Page = pages; return cacheM.Trending.content;} - if (format === "NOVEL") {cacheN.Trending.content = [...cacheN.Trending.content, ...media]; cacheN.Trending.Page = pages; return cacheN.Trending.content;} - } - } catch (error) { - console.error(error); - } -} - -export const getPopular = async (type, page=1, format=undefined, isAdult=undefined, token=undefined, onList=undefined) => { - try { - if ((type === "ANIME" && cacheA.Popular.Page.currentPage < page || Object.keys(cacheA.Popular.Page).length === 0) || - (type === "MANGA" && cacheM.Popular.Page.currentPage < page || Object.keys(cacheM.Popular.Page).length === 0) || - (format === "NOVEL" && cacheN.Popular.Page.currentPage < page || Object.keys(cacheN.Popular.Page).length === 0)) { - const data = await axios.post(url, {query: HPQUERY, variables:{page:page, perPage:perPage, onList:onList, isAdult: isAdult, sort:'POPULARITY_DESC', format:format, type:type}}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Page.media; - const pages = await data.data.data.Page.pageInfo; - if (type === "ANIME") {cacheA.Popular.content = [...cacheA.Popular.content, ...media]; cacheA.Popular.Page = pages; return cacheA.Popular.content;} - if (type === "MANGA" && format !== "NOVEL") {cacheM.Popular.content = [...cacheM.Popular.content, ...media]; cacheM.Popular.Page = pages; return cacheM.Popular.content;} - if (format === "NOVEL") {cacheN.Popular.content = [...cacheN.Popular.content, ...media]; cacheN.Popular.Page = pages; return cacheN.Popular.content;} - } - } catch (error) { - console.error(error); - } -} - -export const getTop = async(type, page=1, format=undefined, isAdult=undefined, token=undefined, onList=undefined) => { - try { - if ((type === "ANIME" && cacheA.Top.Page.currentPage < page || Object.keys(cacheA.Top.Page).length === 0) || - (type === "MANGA" && cacheM.Top.Page.currentPage < page || Object.keys(cacheM.Top.Page).length === 0) || - (format === "NOVEL" && cacheN.Top.Page.currentPage < page || Object.keys(cacheN.Top.Page).length === 0)) { - const data = await axios.post(url, {query: HPQUERY, variables:{page:page, perPage:perPage, onList:onList, isAdult: isAdult, sort:'SCORE_DESC', format:format, type:type}}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Page.media; - const pages = await data.data.data.Page.pageInfo; - if (type === "ANIME") {cacheA.Top.content = [...cacheA.Top.content, ...media]; cacheA.Top.Page = pages; return cacheA.Top.content;} - if (type === "MANGA" && format !== "NOVEL") {cacheM.Top.content = [...cacheM.Top.content, ...media]; cacheM.Top.Page = pages; return cacheM.Top.content;} - if (format === "NOVEL") {cacheN.Top.content = [...cacheN.Top.content, ...media]; cacheN.Top.Page = pages; return cacheN.Top.content;} - } - } catch (error) { - console.error(error); - } -} - -export const getOverview = async(id, token, page=1) => { - try { - const data = await axios.post(url, {query: ITEMQUERY, variables:{id:id, page:page, perPage:perPage}}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Media; - //console.log(data.headers["x-ratelimit-remaining"]); - return media; - } catch (error) { - console.error(error); - } -} - -export const getReviews = async(id) => { - try { - const data = await axios.post(url, {query: REVIEWS, variables:{id:id}}, - {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Media; - return media; - } catch (error) { - console.error(error); - } -} - -export const getCharacter = async(id) => { - try { - const data = await axios.post(url, {query: CHARACTERS, variables:{id:id}}, - {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Character; - return media; - } catch (error) { - console.error(error); - } -} - -export const getVA = async(id, page=1) => { - try { - const data = await axios.post(url, {query: VA_QUERY, variables:{id:id, page:page, perPage:perPage, sort:"ROLE"}}, - {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Staff; - return media; - } catch (error) { - console.error(error); - } -} - -export const getSearch = async(token=undefined, onList=undefined, search=undefined, origin=undefined, isAdult=undefined, page=1, type=undefined, sort='POPULARITY_DESC', format_in=undefined, format_not_in=undefined, genre_in=undefined, genre_not_in=undefined, tag_in=undefined, tag_not_in=undefined) => { - try { - const data = await axios.post(url, {query: HPQUERY, variables:{ - page: page, perPage:10, onList: onList, search: search, origin:origin, type:type, isAdult:isAdult, sort:sort, format_in:format_in, format_not_in:format_not_in, genre_in:genre_in, genre_not_in:genre_not_in, tag_in:tag_in, tag_not_in:tag_not_in - }}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Page; - //console.log(data.headers["x-ratelimit-remaining"]); - cacheS.Page = await media.pageInfo; - cacheS.Content = await media.media; - return media; - } catch (error) { - console.error(error); - } -} - -export const getUser = async( name, token=undefined, page=1, perPage=10) => { - try { - const data = await axios.post(url, {query: USER_QUERY, variables:{name:name, page:page, perPage:perPage}}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.User; - //console.log(data.headers["x-ratelimit-remaining"]); - return media; - } catch (error) { - console.error(error); - } -} - -export const getUserSearch = async(search, token=undefined, page=1, perPage=12) => { - try { - const data = await axios.post(url, {query: USER_SEARCH, variables:{search:search, page:page, perPage:perPage}}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Page; - //console.log(data.headers["x-ratelimit-remaining"]); - return media; - } catch (error) { - console.error(error); - } -} - -export const getActivity = async(userId, page=1, perPage=10 ) => { - try { - const data = await axios.post(url, {query: ACTIVITY, variables:{userId:userId, page:page, perPage:perPage }}, - {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Page; - //console.log(data.headers["x-ratelimit-remaining"]); - return media; - } catch (error) { - console.error(error); - } -} - -export const getLists = async(userId, page=1, status, type, sort='UPDATED_TIME_DESC', perPage=12) => { - try { - const data = await axios.post(url, {query: LISTS, variables:{userId:userId, page:page, perPage:perPage, status:status, type:type, sort:sort }}, - {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Page; - //console.log(data.headers["x-ratelimit-remaining"]); - return media; - } catch (error) { - console.error(error); - } -} - -export const getFilters = async() => { - const nsfw = await getNSFW(); - try { - let cat = []; - cacheFilter.splice(1); - cacheFilter[0].data.splice(0); - const data = await axios.post(url, {query: FILTER_QUERY}, - {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data; - media.MediaTagCollection.forEach((item, index) => { - if (nsfw === false) { - (item.isAdult === false) ? cat.push(item.category) : null; - } else { - cat.push(item.category); - } - }); - cat = [...new Set(cat)] - cat.sort(); - - media.GenreCollection.forEach((genre, index) => { - (nsfw === false && genre === 'Hentai') ? null : cacheFilter[0].data = [...cacheFilter[0].data, { id: index+'g', tag: genre, description:'No description' }] - }) - - cat.forEach((categ, index) => { - let tempobj = {title: categ, data: []}; - cacheFilter.push(tempobj); - media.MediaTagCollection.forEach((item) => { - let pos = cacheFilter.findIndex(elem => elem['title'] == categ); - if (categ === item.category) cacheFilter[pos].data = [...cacheFilter[pos].data, {id: item.id, tag: item.name, description:item.description}]; - }) - }); - return cacheFilter; - } catch (error) { - console.error(error); - } -} - -export const getAuthUserData = async(token, page=1, perPage=10) => { - try { - const data = await axios.post(url, {query: AUTH_USER_QUERY, variables:{page:page, perPage:perPage}}, - {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Viewer; - return media; - } catch (error) { - console.error(error); - } -} - -export const getFollowing = async(userId, token=undefined, page=1, perPage=10) => { - try { - const data = await axios.post(url, {query: FOLLOWING_QUERY, variables:{userId: userId, page:page, perPage:perPage}}, - (typeof token !== 'string') ? {headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}} : {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const media = await data.data.data.Page; - return media; - } catch (error) { - console.error(error); - } -} \ No newline at end of file diff --git a/api/getstorage.js b/api/getstorage.js deleted file mode 100644 index f94ba74..0000000 --- a/api/getstorage.js +++ /dev/null @@ -1,25 +0,0 @@ -import * as Keychain from 'react-native-keychain'; - -export const getToken = async() => { - try { - const token = await Keychain.getGenericPassword(); - if (token !== false) { - return token.password; - } else { - return false; - } - } catch (error) { - console.log(error); - } -} - -export const storeToken = async(token) => { - if (typeof token === 'string') { - let auth = token.slice(14).split('&'); - try { - await Keychain.setGenericPassword('Bearer ', auth[0]); - } catch (error) { - console.log(error); - } - } -} \ No newline at end of file diff --git a/api/updatedata.js b/api/updatedata.js deleted file mode 100644 index 1315622..0000000 --- a/api/updatedata.js +++ /dev/null @@ -1,66 +0,0 @@ -import axios from 'axios'; -import { DELETE_MEDIA_ENTRY, FAVORITE_MODIFY, PROGRESS_UPDATE, SCORE_UPDATE, STATUS_UPDATE, TOGGLE_FOLLOW } from '../Queries/mutations'; - -const url = 'https://graphql.anilist.co'; - -export const updateStatus = async(token, mediaId, status) => { - try { - const data = await axios.post(url, {query: STATUS_UPDATE, variables:{mediaId:mediaId, status:status}}, - {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const updatedInfo = await data.data.data.SaveMediaListEntry; - return updatedInfo; - } catch (error) { - console.error(error); - } -} - -export const updateProgress = async(token, mediaId, progress) => { - try { - const data = await axios.post(url, {query: PROGRESS_UPDATE, variables:{mediaId:mediaId, progress:progress}}, - {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const updatedInfo = await data.data.data.SaveMediaListEntry; - return updatedInfo; - } catch (error) { - console.error(error); - } -} - -export const updateScore = async(token, mediaId, score) => { - try { - const data = await axios.post(url, {query: SCORE_UPDATE, variables:{mediaId:mediaId, score:score}}, - {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const updatedInfo = await data.data.data.SaveMediaListEntry; - return updatedInfo; - } catch (error) { - console.error(error); - } -} - -export const updateFavorite = async(token, characterId) => { - try { - const data = await axios.post(url, {query: FAVORITE_MODIFY, variables:{characterId: characterId}}, - {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const updatedInfo = await data.data.data.ToggleFavourite; - return updatedInfo; - } catch (error) { - console.error(error); - } -} - -export const updateFollow = async(token, userId) => { - try { - const data = await axios.post(url, {query: TOGGLE_FOLLOW, variables:{userId: userId}}, - {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const updatedInfo = await data.data.data.ToggleFollow.isFollowing; - return updatedInfo; - } catch (error) { - console.error(error); - } -} - -export const deleteEntry = async(token, id) => { - const data = await axios.post(url, {query: DELETE_MEDIA_ENTRY, variables:{id:id}}, - {headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Accept': 'application/json'}}); - const updatedInfo = await data.data.data.DeleteMediaListEntry; - return updatedInfo; -} \ No newline at end of file From 5fa5083034e9df6978930c5c801953f8eb55da98 Mon Sep 17 00:00:00 2001 From: SmashinFries Date: Fri, 29 Oct 2021 19:25:55 -0500 Subject: [PATCH 02/18] removed --- Components/storagehooks.js | 49 -------------------------------------- Themes/themes.js | 19 --------------- 2 files changed, 68 deletions(-) delete mode 100644 Components/storagehooks.js delete mode 100644 Themes/themes.js diff --git a/Components/storagehooks.js b/Components/storagehooks.js deleted file mode 100644 index 426c7e7..0000000 --- a/Components/storagehooks.js +++ /dev/null @@ -1,49 +0,0 @@ -import React from 'react'; -import AsyncStorage from '@react-native-async-storage/async-storage'; - -export const getTheme = async() => { - try { - const themeSet = await AsyncStorage.getItem('@Theme'); - return(themeSet); - } catch (error) { - console.log(error); - } -} - -export const getLanguage = async() => { - try { - const lang = await AsyncStorage.getItem('@TitleLang'); - return(lang); - } catch (error) { - console.log(error); - } -} - -export const getNSFW = async() => { - try { - const nsfw = await AsyncStorage.getItem('@NSFW'); - return((nsfw === 'enabled' ? true : false)); - } catch (error) { - console.log(error); - } -} - -export const checkUserID = async(userID) => { - try { - const id = await AsyncStorage.getItem('@UserID'); - if (typeof id !== 'string') { - await AsyncStorage.setItem('@UserID', userID); - } - } catch (e) { - console.log('Asyncstorage ERROR:', e); - }; -} - -export const getUserID = async() => { - try { - const id = await AsyncStorage.getItem('@UserID'); - return id; - } catch (error) { - console.log('Asyncstorage ERROR:', e); - } -} \ No newline at end of file diff --git a/Themes/themes.js b/Themes/themes.js deleted file mode 100644 index 6a3c88f..0000000 --- a/Themes/themes.js +++ /dev/null @@ -1,19 +0,0 @@ -import { DefaultTheme, DarkTheme } from '@react-navigation/native'; - -export const DimTheme = { - ...DarkTheme, - colors: { - ...DarkTheme.colors, - primary: '#28c922', - inactive: '#d1d1d1', - } - }; - -export const LightTheme = { - ...DefaultTheme, - colors: { - ...DefaultTheme.colors, - primary: '#28c922', - inactive: '#000', - } - }; \ No newline at end of file From 561004a8f4df28892860313b634fec6a8dc345fb Mon Sep 17 00:00:00 2001 From: SmashinFries Date: Fri, 29 Oct 2021 19:26:31 -0500 Subject: [PATCH 03/18] added utils folder --- Utils/dataprocess.js | 62 +++++++++++++++++++++ Utils/markdown.js | 44 +++++++++++++++ Utils/themes.js | 127 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 233 insertions(+) create mode 100644 Utils/dataprocess.js create mode 100644 Utils/markdown.js create mode 100644 Utils/themes.js diff --git a/Utils/dataprocess.js b/Utils/dataprocess.js new file mode 100644 index 0000000..1e8b373 --- /dev/null +++ b/Utils/dataprocess.js @@ -0,0 +1,62 @@ +import React from "react"; +import { getDateDiff } from "../Data Handler/getdata"; +import { useIsFocused } from "@react-navigation/core"; +import { StatusBar } from "react-native"; + +export const textDecider = (data) => { + const typename = data['__typename']; + const {daysDif, hoursDif, minutesDif, secondsDif} = getDateDiff(data.createdAt * 1000); + const time = (hoursDif > 23) ? `${daysDif} ${(daysDif > 1) ? 'days' : 'day'} ago` : + (hoursDif < 24 && hoursDif > 0) ? `${hoursDif} ${(hoursDif > 1) ? 'hours' : 'hour'} ago` : + (minutesDif > 1) ? `${minutesDif} minutes ago` : `Under a minute ago`; + + let bottomText = ''; + let topText = ''; + let image = ''; + let notifData = {title:'', body:''}; + let rawTime = data.createdAt * 1000; + + // Notifications + if (typename === 'AiringNotification') { + topText = `${data.contexts[0]}${data.episode}${data.contexts[1]}${data.media.title.userPreferred}`; + bottomText = `${data.contexts[2].replace(' ', '')}`; + image = data.media.coverImage.extraLarge; + notifData = {title:data.media.title.userPreferred, body:`${data.contexts[0]}${data.episode}${data.contexts[2]}`}; + } else if (typename === 'FollowingNotification') { + topText = `${data.user.name}${data.context}`; + image = data.user.avatar.large; + notifData = {title:data.user.name, body:`${data.user.name}${data.context}`}; + } else if (typename === 'ActivityLikeNotification') { + topText = `${data.user.name}${data.context}`; + image = data.user.avatar.large; + notifData = {title:data.user.name, body:`${data.user.name}${data.context}`}; + } else if (typename === 'RelatedMediaAdditionNotification') { + topText = data.media.title.userPreferred; + bottomText = `${data.context.slice(1)}`; + image = data.media.coverImage.extraLarge; + notifData = {title:data.media.title.userPreferred, body:`${data.context.slice(1)}`}; + } + + // Activity + if (typename === 'ListActivity') { + topText = `${data.status} ${(data.progress !== null) ? data.progress : ''}`; + bottomText = `${data.media.title.userPreferred}`; + image = data.media.coverImage.extraLarge; + } else if (typename === 'TextActivity') { + topText = ``; + bottomText = `${data.text}`; + image = data.user.avatar.large; + } else if (typename === 'MessageActivity') { + topText = `${data.messenger.name} wrote:`; + bottomText = `${data.message}`; + image = data.messenger.avatar.large; + } + + return({bottomText, topText, time, image, rawTime, notifData}); +} + +export const FocusAwareStatusBar = (props) => { + const isFocused = useIsFocused(); + + return isFocused ? : null; + } \ No newline at end of file diff --git a/Utils/markdown.js b/Utils/markdown.js new file mode 100644 index 0000000..f356452 --- /dev/null +++ b/Utils/markdown.js @@ -0,0 +1,44 @@ +import React from 'react'; +import { Dimensions, View } from 'react-native'; +import FastImage from 'react-native-fast-image'; +import Markdown, { MarkdownIt } from 'react-native-markdown-display'; +blockEmbedPlugin = require("markdown-it-block-embed"); + +// export const markdownItInstance = +// MarkdownIt({typographer: true}) +// .use(blockEmbedPlugin, { +// containerClassName: "video-embed" +// }); + +const {width, height} = Dimensions.get('window'); + +export const rules = { + image: (node, children, parent, styles) => + +}; + +export const md = (data) => { + const regexImg = /(img\d+\W+|[(]*\bimg\b)/gmi; + const regHeader = /(#{1,})/gmi; + const markdown = data.replaceAll('
', '') + .replaceAll('', '*') + .replaceAll('', '*') + .replaceAll('', '*') + .replaceAll('~~~', '') + .replaceAll('~!', '') + .replaceAll('!~', '') + .replaceAll(regexImg, `![](`) + .replaceAll('
' , '') + .replaceAll('', '**') + .replaceAll('', '**') + .replaceAll('', '**') // if underlined, make bold. MD has no underline. TEMP FIX + .replaceAll('', '**') // ^ + .replaceAll('
', ` ${'\n'}`) + .replaceAll('
', ` ${'\n'}`) + .replaceAll('
', ` `) + .replaceAll('', '') + .replaceAll('', '') + .replaceAll('', '') + .replaceAll(regHeader, `$1 `); + return markdown; +} \ No newline at end of file diff --git a/Utils/themes.js b/Utils/themes.js new file mode 100644 index 0000000..667287b --- /dev/null +++ b/Utils/themes.js @@ -0,0 +1,127 @@ +import { DefaultTheme, DarkTheme } from '@react-navigation/native'; +import AsyncStorage from '@react-native-async-storage/async-storage'; + +const themeColors = { + prime: 'rgba(40, 201, 34, 1)', + ocean: 'rgba(11, 168, 189, 1)', + crimson: 'rgba(153, 0, 0, 1)', + spooky: 'rgba(255, 132, 0, 1)', +}; + +// Light Theme +export const LightTheme = { + ...DefaultTheme, + dark: false, + colors: { + ...DefaultTheme.colors, + primary: themeColors.prime, + inactive: '#000', + } +}; + +export const SpookyLightTheme = { + ...DefaultTheme, + dark: false, + colors: { + ...DefaultTheme.colors, + primary: themeColors.spooky, + inactive: '#000', + } +}; + +export const OceanLightTheme = { + ...DefaultTheme, + dark: false, + colors: { + ...DefaultTheme.colors, + primary: themeColors.ocean, + inactive: '#000', + } +}; + +export const CrimsonLightTheme = { + ...DefaultTheme, + dark: false, + colors: { + ...DefaultTheme.colors, + primary: themeColors.crimson, + inactive: '#000', + } +}; + +// Dark Theme +export const DimTheme = { + ...DarkTheme, + dark: true, + colors: { + ...DarkTheme.colors, + primary: themeColors.prime, + inactive: '#d1d1d1', + } +}; + +export const SpookyDarkTheme = { + ...DarkTheme, + dark: true, + colors: { + ...DarkTheme.colors, + primary: themeColors.spooky, + inactive: '#d1d1d1', + } +}; + +export const OceanDarkTheme = { + ...DarkTheme, + dark: true, + colors: { + ...DarkTheme.colors, + primary: themeColors.ocean, + inactive: '#d1d1d1', + } +}; + +export const CrimsonDarkTheme = { + ...DarkTheme, + dark: true, + colors: { + ...DarkTheme.colors, + primary: themeColors.crimson, + inactive: '#d1d1d1', + } +}; + +// Theme Array +export const themes = [ + { theme: 'Light', object:LightTheme, title:'Default'}, + { theme: 'Light Crimson', object:CrimsonLightTheme, title:'Crimson'}, + { theme: 'Light Ocean', object:OceanLightTheme, title:'Ocean'}, + { theme: 'Light Spooky', object:SpookyLightTheme, title:'Spooky'}, + { theme: 'Dark', object:DimTheme, title:'Default'}, + { theme: 'Dark Crimson', object:CrimsonDarkTheme, title:'Crimson'}, + { theme: 'Dark Ocean', object:OceanDarkTheme, title:'Ocean'}, + { theme: 'Dark Spooky', object:SpookyDarkTheme, title:'Spooky'}, + +]; + +// Get Theme +export const getTheme = async () => { + try { + const themeSet = await AsyncStorage.getItem('@Theme'); + let currentTheme = {theme: '', object:{}}; + if (typeof themeSet === 'string') { + for (let thm in themes) { + if (themeSet === themes[thm].theme) { + currentTheme = themes[thm]; + break; + } + } + } + if (typeof themeSet !== 'string') { + currentTheme = themes[0]; + await AsyncStorage.setItem('@Theme', themes[0].theme); + } + return currentTheme; + } catch (e) { + console.error(e); + } +} \ No newline at end of file From 69b3d827d599ee93034467638ecc3b1abf122cdb Mon Sep 17 00:00:00 2001 From: SmashinFries Date: Fri, 29 Oct 2021 19:26:58 -0500 Subject: [PATCH 04/18] containing info page components --- Components/contentcomp.js | 412 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 412 insertions(+) create mode 100644 Components/contentcomp.js diff --git a/Components/contentcomp.js b/Components/contentcomp.js new file mode 100644 index 0000000..f6e36f9 --- /dev/null +++ b/Components/contentcomp.js @@ -0,0 +1,412 @@ +// React +import React, { useEffect, useState } from 'react'; +import { View, ScrollView, useWindowDimensions, Pressable, FlatList, Linking, ToastAndroid, Alert, ImageBackground } from 'react-native'; +// UI +import { Chip, Text, Avatar, Image, Icon, Button, Overlay } from 'react-native-elements'; +// Navigation +import { useTheme, useNavigation } from '@react-navigation/native'; +// Components +import DoubleClick from 'react-native-double-tap'; +import { _ContentTile } from '../Components/customtile'; +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 { copyText } from '../Screens/character'; +import { updateFavorite, updateProgress, updateScore, updateStatus } from '../Data Handler/updatedata'; +import Markdown from 'react-native-markdown-display'; +import { md, rules } from '../Utils/markdown'; + +const types = ['Current', 'Planning', 'Completed', 'Repeating', 'Dropped', 'Paused']; +const scoring = Array.from({ length: (10 - 0) / .1 + 1}, (_, i) => (i * .1).toFixed(1).replace(/\.0/g, '')).reverse(); + +export const SectionInfo = ({header, info, style=null}) => { + const { colors } = useTheme(); + const displayText = (info !== null) ? info : 'Unknown'; + return( + {copyText(displayText)}} style={{ justifyContent: 'center', margin: 5 }}> + {header} + {displayText} + + ); +} + +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'); + const [progress, setProgress] = useState((data.mediaListEntry !== null) ? data.mediaListEntry.progress : '0'); + const [score, setScore] = useState((data.mediaListEntry !== null) ? data.mediaListEntry.score : '0'); + const [statusVis, setStatusVis] = useState(false); + const [progressVis, setProgressVis] = useState(false); + const [scoreVis, setScoreVis] = useState(false); + + const { colors } = useTheme(); + const { width, height } = useWindowDimensions(); + const navigation = useNavigation(); + + const syn = data.synonyms; + syn.toString(); + + const updateContent = async(item) => { + const newItem = await updateStatus(auth, id, item.toUpperCase()); + setStatus(item); + ToastAndroid.show(`Updated to ${item}!`, ToastAndroid.SHORT); + setStatusVis(false); + } + const StatusOverlay = () => { + return( + setStatusVis(false)} overlayStyle={{backgroundColor:colors.card, width:width/2}}> + + {types.map((item, index) => + (item !== status) ?