From 9b27fee57ad63c3d41fd7876855bb9f66cb0fbe3 Mon Sep 17 00:00:00 2001 From: Inwoo Date: Wed, 27 Nov 2024 16:40:36 +0900 Subject: [PATCH] =?UTF-8?q?Feat=20:=20MyGallery=20Firestore=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20-=20#53?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/kolown/data/mock/MockDataProvider.kt | 14 ++++++++++++++ .../my/src/main/java/com/kolown/my/MyViewModel.kt | 6 +++--- .../java/com/kolown/my/component/GalleryItem.kt | 15 ++++----------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/core/data/src/main/java/com/kolown/data/mock/MockDataProvider.kt b/core/data/src/main/java/com/kolown/data/mock/MockDataProvider.kt index d809b10e..5b75b205 100644 --- a/core/data/src/main/java/com/kolown/data/mock/MockDataProvider.kt +++ b/core/data/src/main/java/com/kolown/data/mock/MockDataProvider.kt @@ -5,6 +5,8 @@ import com.kolown.model.FollowerThumbnail import com.kolown.model.Gallery import com.kolown.model.GalleryThumbnail import com.kolown.model.Post +import com.kolown.model.PostContentModel +import com.kolown.model.Reactions import com.kolown.model.Tag object MockDataProvider { @@ -154,6 +156,18 @@ object MockDataProvider { description = getRandomDescription() ) + fun getRandomGalleryPostContentModel() = PostContentModel( + postId = getRandomName(), + authorId = getRandomName(), + imageUrl = getRandomImageUrl(), + description = getRandomDescription(), + registerAt = "2023-01-01", + tags = listOf(getRandomTagName()), + isFollower = true, + reactions = listOf(Reactions.STAR), + myReaction = Reactions.STAR + ) + fun getRandomPostList() = getRandomList { getRandomPost() } diff --git a/feature/my/src/main/java/com/kolown/my/MyViewModel.kt b/feature/my/src/main/java/com/kolown/my/MyViewModel.kt index 3ac01572..062ca97f 100644 --- a/feature/my/src/main/java/com/kolown/my/MyViewModel.kt +++ b/feature/my/src/main/java/com/kolown/my/MyViewModel.kt @@ -6,15 +6,15 @@ import androidx.paging.cachedIn import androidx.paging.map import com.kolown.data.di.Fake import com.kolown.data.repository.GalleryRepository +import com.kolown.data.repository.PostRepository import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.map import javax.inject.Inject @HiltViewModel class MyViewModel @Inject constructor( - @Fake - private val galleryRepository: GalleryRepository + private val postRepository: PostRepository, ) : ViewModel() { - val galleryFlow = galleryRepository.getGalleryThumbnailPagingFlow(1).cachedIn(viewModelScope) + val galleryFlow = postRepository.getUserPosts().cachedIn(viewModelScope) } diff --git a/feature/my/src/main/java/com/kolown/my/component/GalleryItem.kt b/feature/my/src/main/java/com/kolown/my/component/GalleryItem.kt index 8d5448c6..39b90ad0 100644 --- a/feature/my/src/main/java/com/kolown/my/component/GalleryItem.kt +++ b/feature/my/src/main/java/com/kolown/my/component/GalleryItem.kt @@ -1,29 +1,22 @@ package com.kolown.my.component -import android.util.Log -import androidx.compose.foundation.border import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import coil3.compose.AsyncImage -import coil3.compose.AsyncImagePreviewHandler import com.kolown.data.mock.MockDataProvider -import com.kolown.model.Gallery -import com.kolown.model.GalleryThumbnail +import com.kolown.model.PostContentModel import kotlin.random.Random @Composable -fun GalleryItem(galleryThumbnail: GalleryThumbnail, width: Dp) { +fun GalleryItem(postContentModel: PostContentModel, width: Dp) { //비율은 그냥 테스트 val height = if (Random.nextBoolean()) (width.value * 1.4).dp else width + 20.dp @@ -32,7 +25,7 @@ fun GalleryItem(galleryThumbnail: GalleryThumbnail, width: Dp) { .fillMaxWidth() .height(height) .clip(RoundedCornerShape(10.dp)), - model = galleryThumbnail.imageUrl, + model = postContentModel.imageUrl, contentDescription = null, contentScale = ContentScale.Crop ) @@ -42,5 +35,5 @@ fun GalleryItem(galleryThumbnail: GalleryThumbnail, width: Dp) { @Preview @Composable private fun GalleryItemPreview() { - GalleryItem(MockDataProvider.getRandomGalleryThumbnail(), 200.dp) + GalleryItem(MockDataProvider.getRandomGalleryPostContentModel(), 200.dp) }