Skip to content

Commit 0eaf5a6

Browse files
committed
[feature/#38] 채팅화면에서 다시 대화하기 기능 구현
1 parent 518e28a commit 0eaf5a6

File tree

4 files changed

+90
-83
lines changed

4 files changed

+90
-83
lines changed

feature/chatting/src/commonMain/kotlin/com/nexters/emotia/feature/chatting/ChattingScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ private fun FairySelectionScreen(
434434
),
435435
onConfirmClick = onSpotlightAnimationStart,
436436
onRetryClick = {
437-
// TODO: 다시 대화하기 구현
437+
viewModel.handleIntent(ChattingIntent.RestartChat)
438438
}
439439
)
440440
}

feature/chatting/src/commonMain/kotlin/com/nexters/emotia/feature/chatting/ChattingViewModel.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ChattingViewModel(
4343
is ChattingIntent.ClearError -> clearError()
4444
is ChattingIntent.LoadFairies -> loadFairies()
4545
is ChattingIntent.SelectFairy -> selectFairy(intent.index)
46+
is ChattingIntent.RestartChat -> restartChat()
4647
}
4748
}
4849

@@ -183,6 +184,11 @@ class ChattingViewModel(
183184
reduce { state.copy(selectedFairyIndex = index) }
184185
}
185186

187+
private fun restartChat() = intent {
188+
reduce { ChattingState() }
189+
createChatRoom()
190+
}
191+
186192
private fun getUserMessageCount(messages: PersistentList<ChatMessage>): Int {
187193
return messages.count { it.type == BubbleType.MINE }
188194
}

feature/chatting/src/commonMain/kotlin/com/nexters/emotia/feature/chatting/contract/ChattingIntent.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ sealed interface ChattingIntent {
1111
data object ClearError : ChattingIntent
1212
data object LoadFairies : ChattingIntent
1313
data class SelectFairy(val index: Int) : ChattingIntent
14+
data object RestartChat : ChattingIntent
1415
}

feature/result/src/commonMain/kotlin/com/nexters/emotia/feature/result/letter/LetterScreen.kt

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -135,102 +135,102 @@ fun LetterScreen(
135135
.verticalScroll(scrollState),
136136
horizontalAlignment = Alignment.CenterHorizontally
137137
) {
138-
Box {
139-
Image(
140-
painter = painterResource(Res.drawable.img_letter_background),
141-
contentDescription = "Background Image",
142-
modifier = Modifier.fillMaxWidth(),
143-
contentScale = ContentScale.FillWidth
144-
)
145-
146-
SubcomposeAsyncImage(
147-
model = ImageRequest.Builder(LocalPlatformContext.current)
148-
.data(fairyImage)
149-
.crossfade(true)
150-
.build(),
151-
contentDescription = "$fairyImage image",
152-
contentScale = ContentScale.Inside,
153-
modifier = Modifier
154-
.size(108.dp)
155-
.align(Alignment.BottomCenter)
156-
.offset(y = (-49).dp)
157-
.clip(RoundedCornerShape(16.dp)),
158-
error = {
159-
// TODO : 에러 이미지 처리
160-
},
161-
)
162-
}
138+
Box {
139+
Image(
140+
painter = painterResource(Res.drawable.img_letter_background),
141+
contentDescription = "Background Image",
142+
modifier = Modifier.fillMaxWidth(),
143+
contentScale = ContentScale.FillWidth
144+
)
163145

164-
Column(
165-
modifier = Modifier
166-
.let { modifier ->
167-
if (isKeyboardVisible) {
168-
modifier.fillMaxWidth()
169-
} else {
170-
modifier.weight(1f).fillMaxWidth()
171-
}
172-
}
173-
.background(
174-
brush = Brush.verticalGradient(
175-
colors = listOf(
176-
Color(0xFF171E2D),
177-
Color(0xFF1A1A1B)
178-
)
179-
)
180-
),
181-
horizontalAlignment = Alignment.CenterHorizontally
182-
) {
183-
Spacer(modifier = Modifier.height(28.dp))
146+
SubcomposeAsyncImage(
147+
model = ImageRequest.Builder(LocalPlatformContext.current)
148+
.data(fairyImage)
149+
.crossfade(true)
150+
.build(),
151+
contentDescription = "$fairyImage image",
152+
contentScale = ContentScale.Inside,
153+
modifier = Modifier
154+
.size(108.dp)
155+
.align(Alignment.BottomCenter)
156+
.offset(y = (-49).dp)
157+
.clip(RoundedCornerShape(16.dp)),
158+
error = {
159+
// TODO : 에러 이미지 처리
160+
},
161+
)
162+
}
184163

185-
EmotiaMultiLineTextField(
186-
value = uiState.contents,
187-
onValueChange = { viewModel.handleIntent(LetterIntent.UpdateContents(it)) },
188-
placeholder = "${fairyName}에게 위로의 말을 건네보자.",
164+
Column(
189165
modifier = Modifier
190166
.let { modifier ->
191167
if (isKeyboardVisible) {
192-
modifier.heightIn(min = 160.dp)
168+
modifier.fillMaxWidth()
193169
} else {
194-
modifier.weight(1f)
170+
modifier.weight(1f).fillMaxWidth()
195171
}
196172
}
197-
.fillMaxWidth()
198-
.padding(horizontal = 24.dp)
199-
)
200-
201-
Spacer(modifier = Modifier.height(32.dp))
202-
203-
EmotiaButton(
204-
text = "위로 건네기",
205-
onClick = {
206-
viewModel.handleIntent(LetterIntent.SendLetter)
207-
},
208-
enabled = uiState.contents.isNotBlank() && !uiState.isLoading,
209-
modifier = Modifier.padding(horizontal = 24.dp)
210-
)
173+
.background(
174+
brush = Brush.verticalGradient(
175+
colors = listOf(
176+
Color(0xFF171E2D),
177+
Color(0xFF1A1A1B)
178+
)
179+
)
180+
),
181+
horizontalAlignment = Alignment.CenterHorizontally
182+
) {
183+
Spacer(modifier = Modifier.height(28.dp))
184+
185+
EmotiaMultiLineTextField(
186+
value = uiState.contents,
187+
onValueChange = { viewModel.handleIntent(LetterIntent.UpdateContents(it)) },
188+
placeholder = "${fairyName}에게 위로의 말을 건네보자.",
189+
modifier = Modifier
190+
.let { modifier ->
191+
if (isKeyboardVisible) {
192+
modifier.heightIn(min = 160.dp)
193+
} else {
194+
modifier.weight(1f)
195+
}
196+
}
197+
.fillMaxWidth()
198+
.padding(horizontal = 24.dp)
199+
)
211200

212-
Spacer(modifier = Modifier.height(16.dp))
201+
Spacer(modifier = Modifier.height(32.dp))
213202

214-
Text(
215-
text = "다시 대화하기",
216-
modifier = Modifier
217-
.fillMaxWidth()
218-
.clickable {
219-
onNavigateToChatting()
203+
EmotiaButton(
204+
text = "위로 건네기",
205+
onClick = {
206+
viewModel.handleIntent(LetterIntent.SendLetter)
220207
},
221-
style = typography.emotia14M.copy(
222-
color = colors.lightGray,
223-
textDecoration = TextDecoration.Underline
224-
),
225-
textAlign = TextAlign.Center
226-
)
208+
enabled = uiState.contents.isNotBlank() && !uiState.isLoading,
209+
modifier = Modifier.padding(horizontal = 24.dp)
210+
)
227211

228-
Spacer(modifier = Modifier.height(24.dp))
212+
Spacer(modifier = Modifier.height(16.dp))
213+
214+
Text(
215+
text = "다시 대화하기",
216+
modifier = Modifier
217+
.fillMaxWidth()
218+
.clickable {
219+
onNavigateToChatting()
220+
},
221+
style = typography.emotia14M.copy(
222+
color = colors.lightGray,
223+
textDecoration = TextDecoration.Underline
224+
),
225+
textAlign = TextAlign.Center
226+
)
229227

230-
if (isKeyboardVisible) {
231-
Spacer(modifier = Modifier.height(210.dp))
228+
Spacer(modifier = Modifier.height(24.dp))
229+
230+
if (isKeyboardVisible) {
231+
Spacer(modifier = Modifier.height(210.dp))
232+
}
232233
}
233-
}
234234

235235
// TODO : 로딩이 빨라서 보류. 다른 정책 필요
236236
// // 로딩 오버레이

0 commit comments

Comments
 (0)