diff --git a/app/blog/[identifier]/index.tsx b/app/blog/[identifier]/index.tsx index 2524a00..fb25c88 100644 --- a/app/blog/[identifier]/index.tsx +++ b/app/blog/[identifier]/index.tsx @@ -1,4 +1,6 @@ import FeedPost from "@/src/components/FeedPost"; +import LoadingIndicator from "@/src/components/primitive/LoadingIndicator"; +import { Text } from "@/src/components/primitive/Text"; import { AuthContext } from "@/src/context/AuthContext"; import { Post } from "@/src/lib/post"; import { Profile, resolveProfile } from "@/src/lib/profile"; @@ -8,8 +10,9 @@ import { useContext, useEffect, useState } from "react"; import { ScrollView, View } from "react-native"; export default function BlogPage() { - const [posts, setPosts] = useState(); - const [profile, setProfile] = useState(); + const [loading, setLoading] = useState(true) + const [posts, setPosts] = useState() + const [profile, setProfile] = useState() const { identifier: blogId } = useLocalSearchParams<{ identifier?: string }>(); const authCtx = useContext(AuthContext) @@ -19,7 +22,8 @@ export default function BlogPage() { const profile = await resolveProfile(blogId!) setProfile(profile) const fetchedPosts = await fetchBlogPosts(profile, authCtx) - setPosts(fetchedPosts); + setPosts(fetchedPosts) + setLoading(false) })(); }, [authCtx, blogId]); @@ -33,8 +37,13 @@ export default function BlogPage() { borderLeftWidth: 1, borderRightWidth: 1, padding: 5, + paddingTop: 30, }} > + {loading && } + {!loading && posts && posts.length === 0 && ( + This account has no posts + )} {posts?.map((post) => ( ))} diff --git a/src/components/primitive/LoadingIndicator.tsx b/src/components/primitive/LoadingIndicator.tsx new file mode 100644 index 0000000..626bdf6 --- /dev/null +++ b/src/components/primitive/LoadingIndicator.tsx @@ -0,0 +1,21 @@ +import { View, ActivityIndicator } from "react-native"; +import { Text } from "./Text"; + +export default function LoadingIndicator() { + return + + + Loading + + +} \ No newline at end of file diff --git a/src/components/primitive/Text.tsx b/src/components/primitive/Text.tsx index a710b6a..cfefcdf 100644 --- a/src/components/primitive/Text.tsx +++ b/src/components/primitive/Text.tsx @@ -1,10 +1,10 @@ import { Text as RNText, TextProps } from "react-native" export function Text(props: TextProps) { - return + ]} /> } \ No newline at end of file