From a36be6e4327acefe616ca8e4f7a78cad7a90f7ca Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Thu, 18 Jun 2026 17:51:52 +0300 Subject: [PATCH] fix(#4): replace private EmptyState with shared component in ChatScreen Remove ~30 lines of duplicated code by using the shared EmptyState from ui/common/StateViews.kt instead of the private version. Closes #4 Co-authored-by: M57 --- .../m57/hermescontrol/ui/chat/ChatScreen.kt | 39 +++---------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatScreen.kt b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatScreen.kt index b12ee875..3967fe0d 100644 --- a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatScreen.kt +++ b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatScreen.kt @@ -87,6 +87,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel import com.m57.hermescontrol.notification.NotificationHelper import com.m57.hermescontrol.theme.StatusGreen import com.m57.hermescontrol.theme.StatusRed +import com.m57.hermescontrol.ui.common.EmptyState @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -316,8 +317,10 @@ fun ChatScreen( .fillMaxWidth(), ) { if (state.messages.isEmpty() && !state.isLoading) { - // Empty state - EmptyState() + EmptyState( + title = "Ready to chat", + subtitle = "Send a message to start a conversation", + ) } LazyColumn( @@ -397,38 +400,6 @@ fun ChatScreen( } } -@Composable -private fun EmptyState() { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center, - ) { - Column( - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Text( - text = "⚡", - fontSize = 48.sp, - ) - Spacer(modifier = Modifier.height(8.dp)) - Text( - text = "Ready to chat", - style = - MaterialTheme.typography.titleMedium.copy( - color = MaterialTheme.colorScheme.onSurfaceVariant, - ), - ) - Text( - text = "Send a message to start a conversation", - style = - MaterialTheme.typography.bodySmall.copy( - color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f), - ), - ) - } - } -} - @Composable private fun ThinkingIndicator(thinkingText: String) { val infiniteTransition = rememberInfiniteTransition(label = "thinking")