This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tdanks2000
committed
Dec 8, 2022
1 parent
3e670b7
commit f46227e
Showing
18 changed files
with
371 additions
and
13 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
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,71 @@ | ||
import { ScrollView } from "react-native"; | ||
import React, { useCallback, useMemo, useState } from "react"; | ||
import { Card } from "../../components"; | ||
import { Container, Title } from "../Container.styles"; | ||
import { useAccessToken } from "../../contexts"; | ||
import { | ||
useGetAnimeListQuery, | ||
useGetViewerQuery, | ||
} from "../../utils/graphql/generated"; | ||
import { MediaListStatusWithLabel } from "../../utils/constants"; | ||
import { sortBy } from "lodash"; | ||
import { utils } from "../../utils"; | ||
import { useFocusEffect } from "@react-navigation/native"; | ||
|
||
const Completed = () => { | ||
const [status, setStatus] = useState(MediaListStatusWithLabel[4].value); | ||
|
||
const { accessToken, setAccessToken } = useAccessToken(); | ||
|
||
const { loading: loadingViewer, data: viewerData } = useGetViewerQuery({ | ||
skip: !accessToken, | ||
}); | ||
|
||
const { | ||
loading: loadingAnimeList, | ||
data: animeListData, | ||
refetch, | ||
} = useGetAnimeListQuery({ | ||
skip: !viewerData?.Viewer?.id || !accessToken, | ||
variables: { | ||
userId: viewerData?.Viewer?.id, | ||
status, | ||
}, | ||
// TODO: figure out how to maintain the list position while also updating the cache | ||
fetchPolicy: "no-cache", | ||
notifyOnNetworkStatusChange: false, | ||
}); | ||
|
||
const list = useMemo( | ||
() => | ||
sortBy( | ||
( | ||
(animeListData?.MediaListCollection?.lists && | ||
animeListData?.MediaListCollection?.lists[0]?.entries) ?? | ||
[] | ||
).filter(utils.notEmpty), | ||
(m) => m.media?.title?.english | ||
), | ||
[animeListData] | ||
); | ||
|
||
useFocusEffect( | ||
useCallback(() => { | ||
if (!loadingAnimeList) refetch(); | ||
}, []) | ||
); | ||
|
||
if (!list.length) return null; | ||
return ( | ||
<Container> | ||
<Title>Completed</Title> | ||
<ScrollView horizontal={true} showsHorizontalScrollIndicator={false}> | ||
{list.map((item, i) => ( | ||
<Card key={`completed-${item.id}`} {...item} index={i} /> | ||
))} | ||
</ScrollView> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Completed; |
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,71 @@ | ||
import { ScrollView } from "react-native"; | ||
import React, { useCallback, useMemo, useState } from "react"; | ||
import { Card } from "../../components"; | ||
import { Container, Title } from "../Container.styles"; | ||
import { useAccessToken } from "../../contexts"; | ||
import { | ||
useGetAnimeListQuery, | ||
useGetViewerQuery, | ||
} from "../../utils/graphql/generated"; | ||
import { MediaListStatusWithLabel } from "../../utils/constants"; | ||
import { sortBy } from "lodash"; | ||
import { utils } from "../../utils"; | ||
import { useFocusEffect } from "@react-navigation/native"; | ||
|
||
const Dropped = () => { | ||
const [status, setStatus] = useState(MediaListStatusWithLabel[3].value); | ||
|
||
const { accessToken, setAccessToken } = useAccessToken(); | ||
|
||
const { loading: loadingViewer, data: viewerData } = useGetViewerQuery({ | ||
skip: !accessToken, | ||
}); | ||
|
||
const { | ||
loading: loadingAnimeList, | ||
data: animeListData, | ||
refetch, | ||
} = useGetAnimeListQuery({ | ||
skip: !viewerData?.Viewer?.id || !accessToken, | ||
variables: { | ||
userId: viewerData?.Viewer?.id, | ||
status, | ||
}, | ||
// TODO: figure out how to maintain the list position while also updating the cache | ||
fetchPolicy: "no-cache", | ||
notifyOnNetworkStatusChange: false, | ||
}); | ||
|
||
const list = useMemo( | ||
() => | ||
sortBy( | ||
( | ||
(animeListData?.MediaListCollection?.lists && | ||
animeListData?.MediaListCollection?.lists[0]?.entries) ?? | ||
[] | ||
).filter(utils.notEmpty), | ||
(m) => m.media?.title?.english | ||
), | ||
[animeListData] | ||
); | ||
|
||
useFocusEffect( | ||
useCallback(() => { | ||
if (!loadingAnimeList) refetch(); | ||
}, []) | ||
); | ||
|
||
if (!list.length) return null; | ||
return ( | ||
<Container> | ||
<Title>Dropped</Title> | ||
<ScrollView horizontal={true} showsHorizontalScrollIndicator={false}> | ||
{list.map((item, i) => ( | ||
<Card key={`Dropped-${item.id}`} {...item} index={i} /> | ||
))} | ||
</ScrollView> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Dropped; |
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,71 @@ | ||
import { ScrollView } from "react-native"; | ||
import React, { useCallback, useMemo, useState } from "react"; | ||
import { Card } from "../../components"; | ||
import { Container, Title } from "../Container.styles"; | ||
import { useAccessToken } from "../../contexts"; | ||
import { | ||
useGetAnimeListQuery, | ||
useGetViewerQuery, | ||
} from "../../utils/graphql/generated"; | ||
import { MediaListStatusWithLabel } from "../../utils/constants"; | ||
import { sortBy } from "lodash"; | ||
import { utils } from "../../utils"; | ||
import { useFocusEffect } from "@react-navigation/native"; | ||
|
||
const OnHold = () => { | ||
const [status, setStatus] = useState(MediaListStatusWithLabel[1].value); | ||
|
||
const { accessToken, setAccessToken } = useAccessToken(); | ||
|
||
const { loading: loadingViewer, data: viewerData } = useGetViewerQuery({ | ||
skip: !accessToken, | ||
}); | ||
|
||
const { | ||
loading: loadingAnimeList, | ||
data: animeListData, | ||
refetch, | ||
} = useGetAnimeListQuery({ | ||
skip: !viewerData?.Viewer?.id || !accessToken, | ||
variables: { | ||
userId: viewerData?.Viewer?.id, | ||
status, | ||
}, | ||
// TODO: figure out how to maintain the list position while also updating the cache | ||
fetchPolicy: "no-cache", | ||
notifyOnNetworkStatusChange: false, | ||
}); | ||
|
||
const list = useMemo( | ||
() => | ||
sortBy( | ||
( | ||
(animeListData?.MediaListCollection?.lists && | ||
animeListData?.MediaListCollection?.lists[0]?.entries) ?? | ||
[] | ||
).filter(utils.notEmpty), | ||
(m) => m.media?.title?.english | ||
), | ||
[animeListData] | ||
); | ||
|
||
useFocusEffect( | ||
useCallback(() => { | ||
if (!loadingAnimeList) refetch(); | ||
}, []) | ||
); | ||
|
||
if (!list.length) return null; | ||
return ( | ||
<Container> | ||
<Title>On Hold</Title> | ||
<ScrollView horizontal={true} showsHorizontalScrollIndicator={false}> | ||
{list.map((item, i) => ( | ||
<Card key={`onHold-${item.id}`} {...item} index={i} /> | ||
))} | ||
</ScrollView> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default OnHold; |
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,26 @@ | ||
import React from "react"; | ||
import Completed from "../Completed"; | ||
import ContinueWatching from "../ContinueWatching"; | ||
import Dropped from "../Dropped"; | ||
import OnHold from "../OnHold"; | ||
import PlanToWatch from "../PlanToWatch"; | ||
import { Title, Container, Wrapper, ScrollView } from "./styles"; | ||
|
||
const ListsContainer = () => { | ||
return ( | ||
<Container> | ||
<ScrollView vertical={true} showsVerticalScrollIndicator={false}> | ||
<Wrapper> | ||
<Title>library</Title> | ||
</Wrapper> | ||
<ContinueWatching /> | ||
<PlanToWatch /> | ||
<OnHold /> | ||
<Completed /> | ||
<Dropped /> | ||
</ScrollView> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default ListsContainer; |
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,24 @@ | ||
import styled from "styled-components/native"; | ||
|
||
export const ScrollView = styled.ScrollView` | ||
margin-bottom: 60px; | ||
`; | ||
|
||
export const Container = styled.View``; | ||
|
||
export const Wrapper = styled.View` | ||
padding: 10px 25px; | ||
`; | ||
|
||
export const Wrap = styled.TouchableOpacity``; | ||
|
||
export const Title = styled.Text` | ||
font-size: 25px; | ||
font-family: ${({ theme }) => theme.text.font.secondary}; | ||
color: ${({ theme }) => theme.text.primary}; | ||
padding: 15px 0; | ||
margin: 15px 0; | ||
border-bottom-width: 1px; | ||
border-bottom-color: ${({ theme }) => theme.text.primary}; | ||
text-transform: uppercase; | ||
`; |
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
Oops, something went wrong.