Skip to content

Commit

Permalink
채팅 화면 로딩 화면 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
easyhooon committed Nov 16, 2023
1 parent dab7fb3 commit 16183a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.last.psychat.android.core.ui.ObserveAsEvents
import com.last.psychat.android.core.ui.components.LoadingScreen
import com.last.psychat.android.core.ui.extension.noRippleClickable
import com.last.psychat.android.core.ui.keyboardAsState
import com.last.psychat.android.feature.chat.components.ChatBubble
Expand Down Expand Up @@ -129,6 +130,9 @@ internal fun ChatScreen(
)
HorizontalDivider(color = Gray500)
Spacer(modifier = Modifier.height(8.dp))
if (uiState.isLoading) {
LoadingScreen(modifier = Modifier.fillMaxSize())
}
// LazyColumn(
// modifier = Modifier.weight(1f),
// state = listState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class ChatViewModel @Inject constructor(

private fun getPreviousChatDetail(sessionId: Long) {
viewModelScope.launch {
_uiState.update {
it.copy(
isLoading = true,
)
}
val result = getPreviousChatDetailUseCase(sessionId)
when {
result.isSuccess && result.getOrNull() != null -> {
Expand All @@ -107,6 +112,11 @@ class ChatViewModel @Inject constructor(
_eventFlow.emit(ChatUiEvent.ShowToast(UiText.DirectString(exception.message.toString())))
}
}
_uiState.update {
it.copy(
isLoading = false
)
}
}
}

Expand Down

0 comments on commit 16183a3

Please sign in to comment.