-
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.
Merge pull request #1 from Delemangi/feat/notification-ui
Feat/notification UI
- Loading branch information
Showing
25 changed files
with
1,221 additions
and
1,106 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,4 @@ yarn-error.* | |
# The following patterns were generated by expo-cli | ||
|
||
expo-env.d.ts | ||
# @end expo-cli | ||
# @end expo-cli |
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 |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
"hints": { | ||
"typescript-config/consistent-casing": "off" | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,27 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
import { getUrl, listUrl } from "./urls"; | ||
import { Post } from "../types/Post"; | ||
|
||
export const useGetPosts = (type: string | null) => { | ||
return useQuery<Post[], Error>({ | ||
queryKey: ["posts", type], | ||
enabled: Boolean(type), | ||
queryFn: () => | ||
fetch(getUrl(type!)) | ||
.then((res) => res.json()) | ||
.then((data) => data.posts), | ||
staleTime: 1000 * 60 * 5, | ||
}); | ||
}; | ||
|
||
export const useGetPostTypes = () => { | ||
return useQuery<string[], Error>({ | ||
queryKey: ["types"], | ||
queryFn: () => | ||
fetch(listUrl()) | ||
.then((res) => res.json()) | ||
.then((data) => data.scrapers), | ||
staleTime: Infinity, | ||
}); | ||
}; |
File renamed without changes.
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,6 @@ | ||
import { config } from "@config/config"; | ||
|
||
export const getUrl = (scraperType: string) => | ||
`${config.BASE_URL}/get/${scraperType}`; | ||
|
||
export const listUrl = () => `${config.BASE_URL}/list`; |
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 |
---|---|---|
@@ -1,7 +1,44 @@ | ||
import AppHeader from "@components/AppHeader"; | ||
import { makeStyles } from "@rneui/themed"; | ||
import { usePostStore } from "@stores/postStore"; | ||
import { Slot } from "expo-router"; | ||
import { useEffect } from "react"; | ||
import { View } from "react-native"; | ||
|
||
import { useGetPostTypes } from "../../api/hooks"; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
container: { | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
flex: 1, | ||
backgroundColor: theme.colors.background, | ||
}, | ||
title: { | ||
margin: "auto", | ||
}, | ||
})); | ||
|
||
const HomeLayout = () => { | ||
return <Slot />; | ||
const styles = useStyles(); | ||
const { data: typesData } = useGetPostTypes(); | ||
const setTypes = usePostStore((state) => state.setTypes); | ||
|
||
useEffect(() => { | ||
if (typesData) { | ||
setTypes(typesData); | ||
} | ||
}, [typesData]); | ||
|
||
return ( | ||
<> | ||
<AppHeader /> | ||
<View style={styles.container}> | ||
<Slot /> | ||
</View> | ||
</> | ||
); | ||
}; | ||
|
||
export default HomeLayout; |
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
File renamed without changes.
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,5 @@ | ||
const UNAUTHENTICATED_ROUTES = ["login", "register"]; | ||
|
||
export const isRouteAuthenticated = (route: string) => { | ||
return !UNAUTHENTICATED_ROUTES.includes(route); | ||
}; |
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,55 @@ | ||
import { Header, Text, makeStyles } from "@rneui/themed"; | ||
import { usePostStore } from "@stores/postStore"; | ||
import React from "react"; | ||
import { ScrollView, TouchableOpacity } from "react-native"; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
headerContainer: { | ||
backgroundColor: theme.colors.primary, | ||
justifyContent: "space-around", | ||
height: 100, | ||
}, | ||
scrollView: { | ||
flexGrow: 0, | ||
}, | ||
option: { | ||
paddingHorizontal: 10, | ||
}, | ||
optionText: { | ||
color: theme.colors.white, | ||
}, | ||
})); | ||
|
||
const AppHeader = () => { | ||
const styles = useStyles(); | ||
const { setType, types } = usePostStore((state) => state); | ||
|
||
const handlePostTypeSelect = (type: string) => { | ||
setType(type); | ||
}; | ||
|
||
return ( | ||
<Header | ||
centerComponent={ | ||
<ScrollView | ||
horizontal | ||
showsHorizontalScrollIndicator={false} | ||
style={styles.scrollView} | ||
> | ||
{types.map((type, index) => ( | ||
<TouchableOpacity | ||
key={index} | ||
onPress={() => handlePostTypeSelect(type)} | ||
style={styles.option} | ||
> | ||
<Text style={styles.optionText}>{type.toUpperCase()}</Text> | ||
</TouchableOpacity> | ||
))} | ||
</ScrollView> | ||
} | ||
containerStyle={styles.headerContainer} | ||
/> | ||
); | ||
}; | ||
|
||
export default AppHeader; |
This file was deleted.
Oops, something went wrong.
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.