Skip to content

Commit 0eb78dd

Browse files
authored
Merge pull request #139 from Nico1eKim/refactor/#138-completed_rooms
[REFACTOR] 완료된 모임방 구현, 모임방 사용성 개선작업
2 parents f280150 + d366113 commit 0eb78dd

File tree

22 files changed

+428
-179
lines changed

22 files changed

+428
-179
lines changed

app/src/main/java/com/texthip/thip/data/model/rooms/response/JoinedRoomListResponse.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ data class JoinedRoomResponse(
1818
@SerialName("bookImageUrl") val bookImageUrl: String?,
1919
@SerialName("roomTitle") val roomTitle: String,
2020
@SerialName("memberCount") val memberCount: Int,
21-
@SerialName("userPercentage") val userPercentage: Int
21+
@SerialName("userPercentage") val userPercentage: Int,
22+
@SerialName("deadlineDate") val deadlineDate: String? = null,
2223
)
2324

app/src/main/java/com/texthip/thip/data/model/rooms/response/RoomMainResponse.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ data class RoomMainResponse(
1717
@Serializable
1818
data class RoomMainList(
1919
@SerialName("deadlineRoomList") val deadlineRoomList: List<RoomMainResponse> = emptyList(),
20-
@SerialName("popularRoomList") val popularRoomList: List<RoomMainResponse> = emptyList()
20+
@SerialName("popularRoomList") val popularRoomList: List<RoomMainResponse> = emptyList(),
21+
@SerialName("recentRoomList") val recentRoomList: List<RoomMainResponse> = emptyList()
2122
)

app/src/main/java/com/texthip/thip/data/repository/RoomsRepository.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class RoomsRepository @Inject constructor(
5757
response
5858
}
5959

60-
/** 카테고리별 모임방 섹션 조회 (마감임박/인기) */
60+
/** 카테고리별 모임방 섹션 조회 (마감임박/인기/최근 생성) */
6161
suspend fun getRoomSections(
6262
genre: Genre? = null
6363
): Result<RoomMainList?> = runCatching {
@@ -141,11 +141,12 @@ class RoomsRepository @Inject constructor(
141141
suspend fun searchRooms(
142142
keyword: String,
143143
category: String,
144+
isAllCategory: Boolean = false,
144145
sort: String = "deadline",
145146
isFinalized: Boolean = false,
146147
cursor: String? = null
147148
): Result<RoomsSearchResponse?> = runCatching {
148-
roomsService.searchRooms(keyword, category, sort, isFinalized, cursor)
149+
roomsService.searchRooms(keyword, category, isAllCategory, sort, isFinalized, cursor)
149150
.handleBaseResponse()
150151
.getOrThrow()
151152
}

app/src/main/java/com/texthip/thip/data/service/RoomsService.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ interface RoomsService {
5252
@Query("cursor") cursor: String? = null
5353
): BaseResponse<JoinedRoomListResponse>
5454

55-
/** 카테고리별 모임방 목록 조회 (마감임박/인기) */
55+
/** 카테고리별 모임방 목록 조회 (마감임박/인기/최근 생성) */
5656
@GET("rooms")
5757
suspend fun getRooms(
5858
@Query("category") category: String = "문학"
@@ -100,6 +100,7 @@ interface RoomsService {
100100
suspend fun searchRooms(
101101
@Query("keyword") keyword: String,
102102
@Query("category") category: String,
103+
@Query("isAllCategory") isAllCategory: Boolean = false,
103104
@Query("sort") sort: String = "deadline",
104105
@Query("isFinalized") isFinalized: Boolean = false,
105106
@Query("cursor") cursor: String? = null
@@ -108,7 +109,7 @@ interface RoomsService {
108109

109110

110111
/** 기록장 API들 */
111-
@GET("rooms/{roomId}/playing")
112+
@GET("rooms/{roomId}")
112113
suspend fun getRoomsPlaying(
113114
@Path("roomId") roomId: Int
114115
): BaseResponse<RoomsPlayingResponse>

app/src/main/java/com/texthip/thip/ui/feed/component/MySubscribelistBar.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,25 @@ fun MySubscribeBarlist(
131131
}
132132

133133
@Composable
134-
private fun EmptyMySubscriptionBar() {
134+
fun EmptyMySubscriptionBar(
135+
modifier: Modifier = Modifier,
136+
text: String = stringResource(R.string.find_thip_mate),
137+
onClick: () -> Unit = {}
138+
) {
135139
Box(
136-
modifier = Modifier
140+
modifier = modifier
137141
.padding(top = 8.dp)
138142
.fillMaxWidth()
139143
.height(42.dp)
140144
.clip(RoundedCornerShape(12.dp))
141145
.background(colors.DarkGrey02)
142-
.clickable { }
146+
.clickable { onClick() }
143147
) {
144148
Text(
145149
modifier = Modifier
146150
.align(Alignment.CenterStart)
147151
.padding(start = 12.dp),
148-
text = stringResource(R.string.find_thip_mate),
152+
text = text,
149153
color = colors.White,
150154
style = typography.view_m500_s12_h20
151155
)

app/src/main/java/com/texthip/thip/ui/group/done/screen/GroupDoneScreen.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ import com.texthip.thip.utils.rooms.RoomUtils
3737
@OptIn(ExperimentalMaterial3Api::class)
3838
@Composable
3939
fun GroupDoneScreen(
40+
onRoomClick: (Int) -> Unit = {},
4041
onNavigateBack: () -> Unit = {},
4142
viewModel: GroupDoneViewModel = hiltViewModel()
4243
) {
4344
val uiState by viewModel.uiState.collectAsState()
4445

4546
GroupDoneContent(
4647
uiState = uiState,
48+
onRoomClick = onRoomClick,
4749
onNavigateBack = onNavigateBack,
4850
onRefresh = { viewModel.refreshData() },
4951
onLoadMore = { viewModel.loadMoreExpiredRooms() }
@@ -54,6 +56,7 @@ fun GroupDoneScreen(
5456
@Composable
5557
fun GroupDoneContent(
5658
uiState: GroupDoneUiState,
59+
onRoomClick: (Int) -> Unit = {},
5760
onNavigateBack: () -> Unit = {},
5861
onRefresh: () -> Unit = {},
5962
onLoadMore: () -> Unit = {}
@@ -118,7 +121,7 @@ fun GroupDoneContent(
118121
maxParticipants = room.recruitCount, // 모집 인원 수 사용
119122
isRecruiting = RoomUtils.isRecruitingByType(room.type),
120123
isSecret = !room.isPublic,
121-
onClick = { /* 완료된 모임방은 클릭 불가 */ }
124+
onClick = { onRoomClick(room.roomId) }
122125
)
123126
}
124127
}

app/src/main/java/com/texthip/thip/ui/group/myroom/component/GroupDeadlineRoomSection.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fun GroupRoomDeadlineSection(
6868
// Genre enum을 현지화된 문자열로 변환
6969
val genreStrings = Genre.entries.toDisplayStrings()
7070

71-
// 마감 임박 방 목록과 인기 방 목록을 섹션으로 구성
71+
// 마감 임박 방 목록, 인기 방 목록, 최신 생성 모임방을 섹션으로 구성
7272
val roomSections = listOf(
7373
Pair(
7474
stringResource(R.string.room_section_deadline),
@@ -77,12 +77,18 @@ fun GroupRoomDeadlineSection(
7777
Pair(
7878
stringResource(R.string.room_section_popular),
7979
roomMainList?.popularRoomList ?: emptyList()
80-
)
80+
),
81+
Pair(
82+
stringResource(R.string.room_section_recent),
83+
roomMainList?.recentRoomList ?: emptyList()
84+
),
8185
)
8286

87+
val actualPageCount = roomSections.size
88+
8389
val effectivePagerState = rememberPagerState(
84-
initialPage = 0,
85-
pageCount = { roomSections.size }
90+
initialPage = 2,
91+
pageCount = { Int.MAX_VALUE }
8692
)
8793

8894
HorizontalPager(
@@ -91,7 +97,8 @@ fun GroupRoomDeadlineSection(
9197
pageSpacing = pageSpacing,
9298
modifier = Modifier.fillMaxWidth()
9399
) { page ->
94-
val (sectionTitle, rooms) = roomSections[page]
100+
val actualPage = page % actualPageCount
101+
val (sectionTitle, rooms) = roomSections[actualPage]
95102

96103
val isCurrent = effectivePagerState.currentPage == page
97104
val scale = if (isCurrent) 1f else 0.94f

app/src/main/java/com/texthip/thip/ui/group/myroom/component/GroupMainCard.kt

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fun GroupMainCard(
105105
)
106106
Spacer(Modifier.width(2.dp))
107107

108-
Row (
108+
Row(
109109
verticalAlignment = Alignment.CenterVertically
110110
) {
111111
Text(
@@ -122,23 +122,39 @@ fun GroupMainCard(
122122
}
123123
Spacer(Modifier.height(16.dp))
124124
// 닉네임 + 진행도
125-
Row(verticalAlignment = Alignment.Bottom) {
126-
Text(
127-
text = stringResource(R.string.group_progress, userName),
128-
color = colors.Grey02,
129-
style = typography.view_m500_s14
130-
)
131-
Spacer(Modifier.width(4.dp))
132-
Text(
133-
text = "${data.userPercentage}",
134-
color = colors.Purple,
135-
style = typography.smalltitle_sb600_s16_h20
136-
)
137-
Text(
138-
text = "%",
139-
color = colors.Purple,
140-
style = typography.menu_sb600_s12,
141-
)
125+
if (data.deadlineDate == null) {
126+
Row(verticalAlignment = Alignment.Bottom) {
127+
Text(
128+
text = stringResource(R.string.group_progress, userName),
129+
color = colors.Grey02,
130+
style = typography.view_m500_s14
131+
)
132+
Spacer(Modifier.width(4.dp))
133+
Text(
134+
text = "${data.userPercentage}",
135+
color = colors.Purple,
136+
style = typography.smalltitle_sb600_s16_h20
137+
)
138+
Text(
139+
text = "%",
140+
color = colors.Purple,
141+
style = typography.menu_sb600_s12,
142+
)
143+
}
144+
} else {
145+
Row(verticalAlignment = Alignment.Bottom) {
146+
Text(
147+
text = stringResource(R.string.until_start),
148+
color = colors.Grey02,
149+
style = typography.view_m500_s14
150+
)
151+
Spacer(Modifier.width(4.dp))
152+
Text(
153+
text = data.deadlineDate,
154+
color = colors.Purple,
155+
style = typography.smalltitle_sb600_s16_h20
156+
)
157+
}
142158
}
143159
Spacer(Modifier.height(10.dp))
144160

@@ -153,7 +169,10 @@ fun GroupMainCard(
153169
modifier = Modifier
154170
.fillMaxWidth(fraction = percentage / 100f)
155171
.fillMaxHeight()
156-
.background(color = colors.Purple, shape = RoundedCornerShape(12.dp))
172+
.background(
173+
color = colors.Purple,
174+
shape = RoundedCornerShape(12.dp)
175+
)
157176
)
158177
}
159178
Spacer(Modifier.height(2.dp))

app/src/main/java/com/texthip/thip/ui/group/note/component/CommentBottomSheet.kt

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import com.texthip.thip.utils.rooms.advancedImePadding
5151
@Composable
5252
fun CommentBottomSheet(
5353
uiState: CommentsUiState,
54+
isExpired: Boolean = false,
5455
onDismiss: () -> Unit,
5556
onProfileClick: (userId: Long) -> Unit = {},
5657
onShowToast: (String) -> Unit = {},
@@ -122,6 +123,7 @@ fun CommentBottomSheet(
122123
} else {
123124
CommentLazyList(
124125
listState = listState,
126+
isExpired = isExpired,
125127
commentList = uiState.comments,
126128
isLoadingMore = uiState.isLoadingMore,
127129
isLastPage = uiState.isLast,
@@ -137,37 +139,40 @@ fun CommentBottomSheet(
137139
selectedCommentForMenu = comment
138140
},
139141
onReplyLongPress = { reply -> selectedReplyForMenu = reply },
140-
onProfileClick = onProfileClick
142+
onProfileClick = onProfileClick,
143+
onShowToast = onShowToast
141144
)
142145
}
143146
}
144147
}
145148

146-
CommentTextField(
147-
modifier = Modifier
148-
.fillMaxWidth()
149-
.focusRequester(focusRequester),
150-
hint = stringResource(R.string.reply_to),
151-
input = inputText,
152-
onInputChange = { inputText = it },
153-
onSendClick = {
154-
viewModel.onEvent(
155-
CommentsEvent.CreateComment(
156-
content = inputText,
157-
parentId = replyingToCommentId
149+
if (!isExpired) {
150+
CommentTextField(
151+
modifier = Modifier
152+
.fillMaxWidth()
153+
.focusRequester(focusRequester),
154+
hint = stringResource(R.string.reply_to),
155+
input = inputText,
156+
onInputChange = { inputText = it },
157+
onSendClick = {
158+
viewModel.onEvent(
159+
CommentsEvent.CreateComment(
160+
content = inputText,
161+
parentId = replyingToCommentId
162+
)
158163
)
159-
)
160-
inputText = ""
161-
replyingToCommentId = null
162-
replyingToNickname = null
163-
focusManager.clearFocus()
164-
},
165-
replyTo = replyingToNickname,
166-
onCancelReply = {
167-
replyingToCommentId = null
168-
replyingToNickname = null
169-
}
170-
)
164+
inputText = ""
165+
replyingToCommentId = null
166+
replyingToNickname = null
167+
focusManager.clearFocus()
168+
},
169+
replyTo = replyingToNickname,
170+
onCancelReply = {
171+
replyingToCommentId = null
172+
replyingToNickname = null
173+
}
174+
)
175+
}
171176
}
172177
}
173178
}
@@ -224,6 +229,7 @@ fun CommentBottomSheet(
224229
@Composable
225230
private fun CommentLazyList(
226231
listState: LazyListState,
232+
isExpired: Boolean = false,
227233
commentList: List<CommentList>,
228234
isLoadingMore: Boolean,
229235
isLastPage: Boolean,
@@ -232,7 +238,8 @@ private fun CommentLazyList(
232238
onEvent: (CommentsEvent) -> Unit,
233239
onCommentLongPress: (CommentList) -> Unit,
234240
onReplyLongPress: (ReplyList) -> Unit,
235-
onProfileClick: (userId: Long) -> Unit
241+
onProfileClick: (userId: Long) -> Unit,
242+
onShowToast: (String) -> Unit
236243
) {
237244
val isScrolledToEnd by remember {
238245
derivedStateOf {
@@ -263,11 +270,13 @@ private fun CommentLazyList(
263270
) { comment ->
264271
CommentSection(
265272
commentItem = comment,
273+
isExpired = isExpired,
266274
onReplyClick = onReplyClick,
267275
onEvent = onEvent,
268276
onCommentLongPress = onCommentLongPress,
269277
onReplyLongPress = onReplyLongPress,
270-
onProfileClick = onProfileClick
278+
onProfileClick = onProfileClick,
279+
onShowToast = onShowToast
271280
)
272281
}
273282

0 commit comments

Comments
 (0)