Skip to content

Commit

Permalink
Feat : MyGallery Firestore 연동
Browse files Browse the repository at this point in the history
- #53
  • Loading branch information
inwoo13 committed Nov 28, 2024
1 parent c9d1f48 commit 9b27fee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
14 changes: 14 additions & 0 deletions core/data/src/main/java/com/kolown/data/mock/MockDataProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
Expand Down
6 changes: 3 additions & 3 deletions feature/my/src/main/java/com/kolown/my/MyViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
15 changes: 4 additions & 11 deletions feature/my/src/main/java/com/kolown/my/component/GalleryItem.kt
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
)
Expand All @@ -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)
}

0 comments on commit 9b27fee

Please sign in to comment.