-
Notifications
You must be signed in to change notification settings - Fork 3
[API] 내 팔로잉 목록 조회 API 연동 #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1a1e6a1
41b3d52
f2d6e22
5e4a428
7ce2517
4876dc9
dcb3844
e0d94cc
bf05950
38c0349
225ea7a
9c62a3d
27be2a5
97ce79e
9dd50b1
1816db9
e931517
9b42b3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.texthip.thip.data.model.users | ||
|
|
||
| import com.google.gson.annotations.SerializedName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class MyFollowingsResponse( | ||
| @SerializedName("followings") val followings: List<FollowingList>, | ||
| @SerializedName("totalFollowingCount") val totalFollowingCount: Int, | ||
| @SerializedName("nextCursor") val nextCursor: String?, | ||
| @SerializedName("isLast") val isLast: Boolean | ||
| ) | ||
|
|
||
| @Serializable | ||
| data class FollowingList( | ||
| @SerializedName("userId") val userId: Int, | ||
| @SerializedName("nickname") val nickname: String, | ||
| @SerializedName("profileImageUrl") val profileImageUrl: String?, | ||
| @SerializedName("aliasName") val aliasName: String, | ||
| @SerializedName("aliasColor") val aliasColor: String, | ||
| @SerializedName("isFollowing") val isFollowing: Boolean | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.texthip.thip.data.repository | ||
|
|
||
| import com.texthip.thip.data.model.base.handleBaseResponse | ||
| import com.texthip.thip.data.model.users.MyFollowingsResponse | ||
| import com.texthip.thip.data.service.UserService | ||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
|
|
||
| @Singleton | ||
| class UserRepository@Inject constructor( | ||
| private val userService: UserService | ||
| ) { | ||
| suspend fun getMyFollowings( | ||
| cursor: String?, | ||
| size: Int = 10 | ||
| ): Result<MyFollowingsResponse?> = runCatching { | ||
| userService.getMyFollowings(cursor = cursor, size = size) | ||
| .handleBaseResponse() | ||
| .getOrThrow() | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.texthip.thip.data.service | ||
|
|
||
| import com.texthip.thip.data.model.base.BaseResponse | ||
| import com.texthip.thip.data.model.rooms.response.RoomsUsersResponse | ||
| import com.texthip.thip.data.model.users.MyFollowingsResponse | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.Path | ||
| import retrofit2.http.Query | ||
|
|
||
| interface UserService { | ||
| @GET("users/my-followings") | ||
| suspend fun getMyFollowings( | ||
| @Query("size") size: Int = 10, | ||
| @Query("cursor") cursor: String? = null | ||
| ): BaseResponse<MyFollowingsResponse> | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,16 +13,19 @@ import androidx.compose.foundation.lazy.itemsIndexed | |
| import androidx.compose.material3.HorizontalDivider | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.collectAsState | ||
| import androidx.compose.runtime.mutableIntStateOf | ||
| import androidx.compose.runtime.mutableStateListOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.saveable.rememberSaveable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.hilt.navigation.compose.hiltViewModel | ||
| import androidx.navigation.NavController | ||
| import com.texthip.thip.R | ||
| import com.texthip.thip.ui.common.buttons.FloatingButton | ||
|
|
@@ -33,21 +36,26 @@ import com.texthip.thip.ui.feed.component.FeedSubscribeBarlist | |
| import com.texthip.thip.ui.feed.component.MyFeedCard | ||
| import com.texthip.thip.ui.feed.component.MySubscribeBarlist | ||
| import com.texthip.thip.ui.feed.mock.MySubscriptionData | ||
| import com.texthip.thip.ui.feed.viewmodel.MySubscriptionViewModel | ||
| import com.texthip.thip.ui.mypage.component.SavedFeedCard | ||
| import com.texthip.thip.ui.mypage.mock.FeedItem | ||
| import com.texthip.thip.ui.navigator.routes.FeedRoutes | ||
| import com.texthip.thip.ui.theme.ThipTheme | ||
| import com.texthip.thip.ui.theme.ThipTheme.colors | ||
| import com.texthip.thip.ui.theme.ThipTheme.typography | ||
|
|
||
|
|
||
| @Composable | ||
| fun FeedScreen( | ||
| navController: NavController? = null, | ||
| onNavigateToMySubscription: () -> Unit = {}, | ||
| nickname: String = "", | ||
| userRole: String = "", | ||
| feeds: List<FeedItem> = emptyList(), | ||
| totalFeedCount: Int = 0, | ||
| selectedTabIndex: Int = 0, | ||
| followerProfileImageUrls: List<String> = emptyList() | ||
| followerProfileImageUrls: List<String> = emptyList(), | ||
| viewModel: MySubscriptionViewModel = hiltViewModel() | ||
| ) { | ||
| val selectedIndex = rememberSaveable { mutableIntStateOf(selectedTabIndex) } | ||
| val feedStateList = remember { | ||
|
|
@@ -105,6 +113,7 @@ fun FeedScreen( | |
| roleColor = colors.SocialScience | ||
| ) | ||
| ) | ||
| val subscriptionUiState by viewModel.uiState.collectAsState() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent ❓ Verification inconclusive수명 주기 인식 상태 수집으로 전환 권장: collectAsStateWithLifecycle 수명 주기와 동기화된 상태 수집으로 전환하면 백그라운드에서 불필요한 수집을 방지할 수 있습니다. 아래 변경을 제안합니다: -import androidx.compose.runtime.collectAsState
+import androidx.lifecycle.compose.collectAsStateWithLifecycle-val subscriptionUiState by viewModel.uiState.collectAsState()
+val subscriptionUiState by viewModel.uiState.collectAsStateWithLifecycle()Gradle 의존성에 lifecycle-runtime-compose가 포함되어 있는지 확인해 주세요. 아래 스크립트로 점검할 수 있습니다. 🏁 Script executed: #!/bin/bash
# lifecycle-runtime-compose 의존성 존재 여부 확인
rg -n "lifecycle-runtime-compose" -A 2Length of output: 38 다음 스크립트로 Gradle 파일 내에 🏁 Script executed: #!/bin/bash
# Gradle 파일 (*.gradle, *.gradle.kts) 내 lifecycle-runtime-compose 의존성 검색
rg -n "lifecycle-runtime-compose" --glob "*.gradle*" -A2Length of output: 56 수명 주기 인식 상태 수집으로 전환 및 의존성 추가 필요 아래와 같이 위치: 제안 변경사항: -import androidx.compose.runtime.collectAsState
+import androidx.lifecycle.compose.collectAsStateWithLifecycle-val subscriptionUiState by viewModel.uiState.collectAsState()
+val subscriptionUiState by viewModel.uiState.collectAsStateWithLifecycle()추가로, 프로젝트의 implementation "androidx.lifecycle:lifecycle-runtime-compose:<최신_버전>"
🤖 Prompt for AI Agents |
||
| Box(modifier = Modifier.fillMaxSize()) { | ||
| Column( | ||
| modifier = Modifier.fillMaxSize() | ||
|
|
@@ -121,7 +130,8 @@ fun FeedScreen( | |
| selectedTabIndex = selectedIndex.value, | ||
| onTabSelected = { selectedIndex.value = it } | ||
| ) | ||
| // 스크롤 영역 | ||
|
|
||
| // 스크롤 영역 전체 | ||
| LazyColumn( | ||
| modifier = Modifier.weight(1f), | ||
| verticalArrangement = Arrangement.spacedBy(12.dp) | ||
|
|
@@ -203,11 +213,20 @@ fun FeedScreen( | |
| //피드 | ||
| item { | ||
| Spacer(modifier = Modifier.height(20.dp)) | ||
| val subscriptionsForBar = subscriptionUiState.followings.map { user -> | ||
| MySubscriptionData( | ||
| profileImageUrl = user.profileImageUrl, | ||
| nickname = user.nickname, | ||
| role = user.aliasName, | ||
| roleColor = colors.White, | ||
| subscriberCount = 0, | ||
| isSubscribed = user.isFollowing | ||
| ) | ||
| } | ||
| MySubscribeBarlist( | ||
| modifier = Modifier.padding(horizontal = 20.dp), | ||
| subscriptions = mySubscriptions, | ||
| onClick = { | ||
| } | ||
| subscriptions = subscriptionsForBar, | ||
| onClick = onNavigateToMySubscription | ||
| ) | ||
| } | ||
| itemsIndexed(feedStateList, key = { _, item -> item.id }) { index, feed -> | ||
|
|
@@ -300,7 +319,7 @@ private fun FeedScreenWithoutDataPreview() { | |
| FeedScreen( | ||
| nickname = "ThipUser01", | ||
| userRole = "문학 칭호", | ||
| selectedTabIndex = 1, | ||
| selectedTabIndex = 0, | ||
| feeds = mockFeeds, | ||
| totalFeedCount = mockFeeds.size, | ||
| followerProfileImageUrls = mockFollowerImages | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 screen이랑 content랑 분리해서 screen에서 viewmodel을 주입받고 content에서는 ui만 다루도록 수정해주세여 !