Skip to content

Commit e3ae4fe

Browse files
committed
[refactor/#51] 요정리스트가 비었을 경우
- coerceIn이 (0,-1) 이 되버려서 오류 발생 - null 보내주고, FairySelectionBottomSection 에서 selectedFairy가 null 인 경우 다시 대화하기 만 노출시키도록 개선
1 parent 4929fee commit e3ae4fe

File tree

1 file changed

+21
-16
lines changed
  • feature/chatting/src/commonMain/kotlin/com/nexters/emotia/feature/chatting

1 file changed

+21
-16
lines changed

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,13 @@ private fun FairySelectionScreen(
429429
}
430430

431431
FairySelectionBottomSection(
432-
selectedFairy = uiState.fairies.getOrNull(
433-
uiState.selectedFairyIndex.coerceIn(0, uiState.fairies.size - 1)
434-
),
432+
selectedFairy = if (uiState.fairies.isNotEmpty()) {
433+
uiState.fairies.getOrNull(
434+
uiState.selectedFairyIndex.coerceIn(0, uiState.fairies.size - 1)
435+
)
436+
} else {
437+
null
438+
},
435439
onConfirmClick = onSpotlightAnimationStart,
436440
onRetryClick = {
437441
viewModel.handleIntent(ChattingIntent.RestartChat)
@@ -538,21 +542,22 @@ private fun FairySelectionBottomSection(
538542
modifier = Modifier.padding(16.dp),
539543
onClick = onConfirmClick
540544
)
545+
}
541546

542-
Text(
543-
text = "다시 대화하기",
544-
modifier = Modifier
545-
.fillMaxWidth()
546-
.rippleClickable(onClick = onRetryClick),
547-
style = typography.emotia14M.copy(
548-
color = colors.lightGray,
549-
textDecoration = TextDecoration.Underline
550-
),
551-
textAlign = TextAlign.Center
552-
)
547+
Text(
548+
text = "다시 대화하기",
549+
modifier = Modifier
550+
.fillMaxWidth()
551+
.rippleClickable(onClick = onRetryClick),
552+
style = typography.emotia14M.copy(
553+
color = colors.lightGray,
554+
textDecoration = TextDecoration.Underline
555+
),
556+
textAlign = TextAlign.Center
557+
)
558+
559+
Spacer(Modifier.height(24.dp))
553560

554-
Spacer(Modifier.height(24.dp))
555-
}
556561
}
557562

558563
@Composable

0 commit comments

Comments
 (0)