|
|
|
@ -5,6 +5,7 @@ definePageMeta({
|
|
|
|
|
|
|
|
|
|
|
|
const posts = usePosts()
|
|
|
|
const posts = usePosts()
|
|
|
|
const openCreatePostModal = ref<Boolean>(false)
|
|
|
|
const openCreatePostModal = ref<Boolean>(false)
|
|
|
|
|
|
|
|
const pageType = ref<'following' | 'for you'>('for you')
|
|
|
|
|
|
|
|
|
|
|
|
const getPosts = async () => {
|
|
|
|
const getPosts = async () => {
|
|
|
|
await fetchPosts()
|
|
|
|
await fetchPosts()
|
|
|
|
@ -14,8 +15,13 @@ const toggleCreatePostModal = () => {
|
|
|
|
openCreatePostModal.value = !openCreatePostModal.value
|
|
|
|
openCreatePostModal.value = !openCreatePostModal.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const changePageType = (type: 'following' | 'for you') => {
|
|
|
|
|
|
|
|
pageType.value = type
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const createPost = () => {
|
|
|
|
const createPost = () => {
|
|
|
|
toggleCreatePostModal()
|
|
|
|
navigateTo('/compose/tweet')
|
|
|
|
|
|
|
|
// toggleCreatePostModal()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
onMounted(() => {
|
|
|
|
@ -26,20 +32,64 @@ onMounted(() => {
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<Header />
|
|
|
|
<Header />
|
|
|
|
<div class="mt-16 flex w-full items-center justify-center">
|
|
|
|
<div class="sticky top-0 flex bg-primary text-center">
|
|
|
|
<div class="flex w-full max-w-2xl flex-col gap-4 px-4 pb-16 pt-4">
|
|
|
|
<div
|
|
|
|
<div v-if="posts" v-for="post in posts">
|
|
|
|
@click="changePageType('for you')"
|
|
|
|
<PostCard :title="post.title" :description="post.description" :created_at="post.created_at"
|
|
|
|
class="flex w-full flex-col items-center hover:bg-white/10">
|
|
|
|
:user="post.user" />
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
class="py-4"
|
|
|
|
|
|
|
|
:class="{
|
|
|
|
|
|
|
|
'font-bold': pageType === 'for you',
|
|
|
|
|
|
|
|
}">
|
|
|
|
|
|
|
|
For you
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
class="w-full border-2 border-sky-500"
|
|
|
|
|
|
|
|
:class="{
|
|
|
|
|
|
|
|
invisible: pageType !== 'for you',
|
|
|
|
|
|
|
|
}">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
@click="changePageType('following')"
|
|
|
|
|
|
|
|
class="flex w-full flex-col items-center hover:bg-white/10">
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
class="py-4"
|
|
|
|
|
|
|
|
:class="{
|
|
|
|
|
|
|
|
'font-bold': pageType === 'following',
|
|
|
|
|
|
|
|
}">
|
|
|
|
|
|
|
|
Following
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
class="w-full border-2 border-sky-500"
|
|
|
|
|
|
|
|
:class="{
|
|
|
|
|
|
|
|
invisible: pageType !== 'following',
|
|
|
|
|
|
|
|
}">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mb-16 flex w-full items-center justify-center">
|
|
|
|
|
|
|
|
<div class="flex w-full max-w-2xl flex-col">
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
v-if="posts"
|
|
|
|
|
|
|
|
v-for="post in posts">
|
|
|
|
|
|
|
|
<PostCard :post="post" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button @click="getPosts()">More</button>
|
|
|
|
<button @click="getPosts()">More</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button @click="createPost()"
|
|
|
|
<button
|
|
|
|
class="fixed bottom-6 right-6 flex items-center justify-center gap-2 rounded-full bg-blue-500 p-4">
|
|
|
|
@click="createPost()"
|
|
|
|
<Icon name="plus" />
|
|
|
|
class="fixed bottom-16 right-6 flex items-center justify-center gap-2 rounded-full bg-sky-500 p-4">
|
|
|
|
Create Post
|
|
|
|
<Icon name="mdi:feather" />
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
<ModalCreatePost v-if="openCreatePostModal" @close="toggleCreatePostModal()" />
|
|
|
|
<ModalCreatePost
|
|
|
|
|
|
|
|
v-if="openCreatePostModal"
|
|
|
|
|
|
|
|
@close="toggleCreatePostModal()" />
|
|
|
|
|
|
|
|
<BottomNavigationBar />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|