From caa764df065f13761c5b572590041dc6bd0aa091 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 31 Mar 2024 13:09:31 +0300 Subject: [PATCH] We back) --- .../ai/elimu/soga/feature/chat/ChatScreen.kt | 17 ++++++++++++++++- .../ai/elimu/soga/feature/chat/ChatViewModel.kt | 4 +++- .../main/kotlin/ai/elimu/soga/ui/theme/Color.kt | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatScreen.kt b/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatScreen.kt index 586e69a..f5dee1a 100644 --- a/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatScreen.kt +++ b/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatScreen.kt @@ -40,10 +40,16 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import ai.elimu.soga.GenerativeViewModelFactory import ai.elimu.soga.R +import ai.elimu.soga.ui.theme.Gold80 import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.LinearProgressIndicator import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.graphics.StrokeCap import kotlinx.coroutines.launch import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource @@ -57,6 +63,15 @@ internal fun ChatRoute( val coroutineScope = rememberCoroutineScope() Scaffold( + topBar = { + LinearProgressIndicator( + progress = chatViewModel.pointCounter, + modifier = Modifier.height(30.dp).fillMaxWidth().padding(10.dp,0.dp), + color = Gold80, + trackColor = Color.Black, + strokeCap = StrokeCap.Round, + ) + }, bottomBar = { MessageInput( onSendMessage = { inputText -> @@ -208,7 +223,7 @@ fun MessageInput( .fillMaxWidth() .weight(0.15f) ) { - Icon( + Icon( Icons.Default.Send, contentDescription = stringResource(R.string.action_send), modifier = Modifier diff --git a/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatViewModel.kt b/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatViewModel.kt index afe5cab..1ab1eee 100644 --- a/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatViewModel.kt +++ b/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatViewModel.kt @@ -46,6 +46,8 @@ class ChatViewModel( ) ) + + viewModelScope.launch { try { val response = chat.sendMessage(userMessage) @@ -60,7 +62,7 @@ class ChatViewModel( isPending = false ) ) - if (modelResponse.contains("hhvhv") || modelResponse.contains("there") || modelResponse.contains("Correct")) { pointCounter += 0.1f } + if (modelResponse.contains("\uD83C\uDF1F") || modelResponse.contains("correct") || modelResponse.contains("Correct")) { pointCounter += 0.1f } } } catch (e: Exception) { _uiState.value.replaceLastPendingMessage() diff --git a/app/src/main/kotlin/ai/elimu/soga/ui/theme/Color.kt b/app/src/main/kotlin/ai/elimu/soga/ui/theme/Color.kt index 33a1a28..27bc624 100644 --- a/app/src/main/kotlin/ai/elimu/soga/ui/theme/Color.kt +++ b/app/src/main/kotlin/ai/elimu/soga/ui/theme/Color.kt @@ -9,3 +9,5 @@ val Pink80 = Color(0xFFEFB8C8) val Purple40 = Color(0xFF6650a4) val PurpleGrey40 = Color(0xFF625b71) val Pink40 = Color(0xFF7D5260) + +val Gold80 = Color(0xFFFFC94A) \ No newline at end of file