Skip to content

Commit

Permalink
✨ 커뮤니티 상단 본인 섬네일 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
yonghanJu committed Dec 5, 2024
1 parent c6a7518 commit efa64cb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/whyranoid/walkie/KoinModules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ val viewModelModule =
viewModel { AddPostViewModel(get()) }
viewModel { SearchFriendViewModel(get(), get(), get()) }
viewModel { DialogViewModel(get(), get(), get(), get(), get(), get()) }
viewModel { CommunityScreenViewModel(get(), get(), get(), get(), get()) }
viewModel { CommunityScreenViewModel(get(), get(), get(), get(), get(), get(), get()) }
viewModel { FollowingViewModel(get(), get(), get(), get(), get(), get()) }
viewModel { SettingViewModel(get(), get()) }
viewModel { TotalBadgeViewModel(get(), get()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class PostDataSourceImpl(private val postService: PostService) : PostDataSource

override suspend fun getEveryPost(uid: Long): Result<List<Post>> {
return kotlin.runCatching {
val posts = requireNotNull(postService.getPosts(uid).body())
val posts = requireNotNull(postService.getEveryPosts(uid).body())
posts.map { it.toPost(uid) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PostRepositoryImpl(
}

override suspend fun getEveryPost(uid: Long): Result<List<Post>> {
return postDataSource.getMyFollowingsPost(uid)
return postDataSource.getEveryPost(uid)
}

override suspend fun getComments(postId: Long): Result<List<Comment>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.whyranoid.presentation.component.bar.WalkieTopBar
import com.whyranoid.presentation.component.community.PostItem
import com.whyranoid.presentation.component.community.RunningFollowerItem
import com.whyranoid.presentation.component.running.RunningFollowerItemWithLikable
import com.whyranoid.presentation.theme.WalkieColor
import com.whyranoid.presentation.theme.WalkieTypography
Expand Down Expand Up @@ -119,6 +120,16 @@ fun CommunityScreen(navController: NavController) {
modifier = Modifier.padding(it)
) {
LazyRow {
state.myThumbnailState.getDataOrNull()?.let { myInfo ->
item {
RunningFollowerItem(
user = myInfo,
onClickProfile = {
navController.navigate(Screen.MyPage.route)
},
)
}
}
state.runningFollowerState.getDataOrNull()?.let { (running, notRunning) ->
items(running.size) {
RunningFollowerItemWithLikable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.whyranoid.domain.model.post.Post
import com.whyranoid.domain.model.user.User
import com.whyranoid.domain.usecase.GetFollowingsPostsUseCase
import com.whyranoid.domain.usecase.GetMyFollowingUseCase
import com.whyranoid.domain.usecase.GetMyUidUseCase
import com.whyranoid.domain.usecase.GetUserUseCase
import com.whyranoid.domain.usecase.LikePostUseCase
import com.whyranoid.domain.usecase.running.GetRunningFollowerUseCase
import com.whyranoid.domain.usecase.running.SendLikeUseCase
Expand All @@ -25,6 +27,7 @@ data class CommunityScreenState(
val following: UiState<List<User>> = UiState.Idle,
val isEveryPost: UiState<Boolean> = UiState.Success(true),
val runningFollowerState: UiState<Pair<List<RunningFollower>, List<User>>> = UiState.Idle,
val myThumbnailState: UiState<User> = UiState.Idle,
)

class CommunityScreenViewModel(
Expand All @@ -33,6 +36,8 @@ class CommunityScreenViewModel(
private val likePostUseCase: LikePostUseCase,
private val sendLikeUseCase: SendLikeUseCase,
private val getRunningFollowerUseCase: GetRunningFollowerUseCase,
private val getMyUidUseCase: GetMyUidUseCase,
private val getUserUseCase: GetUserUseCase,
) : ViewModel(), ContainerHost<CommunityScreenState, CommunityScreenSideEffect> {

override val container =
Expand All @@ -49,6 +54,15 @@ class CommunityScreenViewModel(
}
}
}
intent {
val myUid = getMyUidUseCase().getOrThrow()
val user = getUserUseCase(myUid).getOrThrow()
reduce {
state.copy(
myThumbnailState = UiState.Success(user)
)
}
}
getPosts()
}

Expand Down

0 comments on commit efa64cb

Please sign in to comment.