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..7e6b418 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,17 @@ 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 android.util.Log
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
@@ -52,11 +59,23 @@ import androidx.compose.ui.res.painterResource
internal fun ChatRoute(
chatViewModel: ChatViewModel = viewModel(factory = GenerativeViewModelFactory)
) {
+ Log.i("Mytag","ChatRoute")
val chatUiState by chatViewModel.uiState.collectAsState()
val listState = rememberLazyListState()
val coroutineScope = rememberCoroutineScope()
+
Scaffold(
+ topBar = {
+ // backgroundColor="transparent"
+ 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 +227,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/ChatUiState.kt b/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatUiState.kt
index 854bf5e..36389c1 100644
--- a/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatUiState.kt
+++ b/app/src/main/kotlin/ai/elimu/soga/feature/chat/ChatUiState.kt
@@ -1,5 +1,6 @@
package ai.elimu.soga.feature.chat
+import android.util.Log
import androidx.compose.runtime.toMutableStateList
class ChatUiState(
@@ -18,6 +19,7 @@ class ChatUiState(
val newMessage = lastMessage.apply { isPending = false }
_messages.removeLast()
_messages.add(newMessage)
+ Log.i("Mytag","ChatUiState")
}
}
}
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 c86d533..cbeecb8 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
@@ -1,5 +1,6 @@
package ai.elimu.soga.feature.chat
+import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.ai.client.generativeai.GenerativeModel
@@ -13,6 +14,9 @@ import kotlinx.coroutines.launch
class ChatViewModel(
generativeModel: GenerativeModel
) : ViewModel() {
+
+ var pointCounter = 0.0f;
+
private val chat = generativeModel.startChat(
history = listOf(
content(role = "user") { text("You'll act as a friendly tutor who helps 6-year-old children learn basic math. Use emojis when you create word problems. Your name is Nya.") },
@@ -43,12 +47,16 @@ class ChatViewModel(
)
)
+
+
viewModelScope.launch {
try {
val response = chat.sendMessage(userMessage)
_uiState.value.replaceLastPendingMessage()
+ Log.i("NumberGenerated","Number 2")
+
response.text?.let { modelResponse ->
_uiState.value.addMessage(
ChatMessage(
@@ -57,6 +65,8 @@ class ChatViewModel(
isPending = false
)
)
+ if (modelResponse.contains("\uD83C\uDF1F") || modelResponse.contains("Nya") || modelResponse.contains("Correct") || modelResponse.contains("that's right") || modelResponse.contains("fantastic")) { pointCounter += 0.1f
+ Log.i("Mytag","viewModelScope") }
}
} 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
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index f8c6127..12b61b1 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -7,4 +7,7 @@
#FF018786
#FF000000
#FFFFFFFF
+ #FFFFC94A
+
+
\ No newline at end of file
diff --git a/settings.gradle.kts b/settings.gradle.kts
index d175187..19888c9 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -15,5 +15,4 @@ dependencyResolutionManagement {
}
}
-rootProject.name = "Soga"
include(":app")