Skip to content

Commit

Permalink
We back)
Browse files Browse the repository at this point in the history
  • Loading branch information
saharulik committed Mar 31, 2024
1 parent 8046569 commit caa764d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
17 changes: 16 additions & 1 deletion app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ->
Expand Down Expand Up @@ -208,7 +223,7 @@ fun MessageInput(
.fillMaxWidth()
.weight(0.15f)
) {
Icon(
Icon(
Icons.Default.Send,
contentDescription = stringResource(R.string.action_send),
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ChatViewModel(
)
)



viewModelScope.launch {
try {
val response = chat.sendMessage(userMessage)
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/kotlin/ai/elimu/soga/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)

val Gold80 = Color(0xFFFFC94A)

0 comments on commit caa764d

Please sign in to comment.