-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add avatar #14
Add avatar #14
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,13 @@ import androidx.compose.ui.unit.dp | |
import androidx.lifecycle.viewmodel.compose.viewModel | ||
import ai.elimu.soga.GenerativeViewModelFactory | ||
import ai.elimu.soga.R | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.ui.draw.clip | ||
import kotlinx.coroutines.launch | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.res.painterResource | ||
|
||
@Composable | ||
internal fun ChatRoute( | ||
|
@@ -118,14 +124,24 @@ fun ChatBubbleItem( | |
Column( | ||
horizontalAlignment = horizontalAlignment, | ||
modifier = Modifier | ||
.padding(horizontal = 8.dp, vertical = 4.dp) | ||
.padding(horizontal = 12.dp, vertical = 10.dp) | ||
.fillMaxWidth() | ||
) { | ||
Text( | ||
text = chatMessage.participant.name, | ||
style = MaterialTheme.typography.bodySmall, | ||
modifier = Modifier.padding(bottom = 4.dp) | ||
) | ||
// Text( | ||
// text = chatMessage.participant.name, | ||
// style = MaterialTheme.typography.bodySmall, | ||
// modifier = Modifier.padding(bottom = 4.dp) | ||
// ) | ||
if (isModelMessage) { | ||
Image( | ||
painter = painterResource(id = R.drawable.nya), | ||
contentDescription = stringResource(id = R.string.nya_avatar_descritpion), | ||
contentScale = ContentScale.Crop, | ||
modifier = Modifier | ||
.size(50.dp) | ||
.clip(CircleShape) | ||
) | ||
} | ||
Comment on lines
+135
to
+144
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The introduction of avatar display for model messages enhances the chat feature. Consider adding alternative avatars for different participants to enrich the user experience further. Would you like me to suggest code for handling multiple avatars based on participant type? |
||
Row { | ||
if (chatMessage.isPending) { | ||
CircularProgressIndicator( | ||
|
@@ -138,11 +154,11 @@ fun ChatBubbleItem( | |
Card( | ||
colors = CardDefaults.cardColors(containerColor = backgroundColor), | ||
shape = bubbleShape, | ||
modifier = Modifier.widthIn(0.dp, maxWidth * 0.9f) | ||
modifier = Modifier.widthIn(0.dp, maxWidth * 2.9f) | ||
) { | ||
Text( | ||
text = chatMessage.text, | ||
modifier = Modifier.padding(16.dp) | ||
modifier = Modifier.padding(20.dp) | ||
) | ||
} | ||
} | ||
|
@@ -192,7 +208,7 @@ fun MessageInput( | |
.fillMaxWidth() | ||
.weight(0.15f) | ||
) { | ||
Icon( | ||
Icon( | ||
Icons.Default.Send, | ||
contentDescription = stringResource(R.string.action_send), | ||
modifier = Modifier | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,4 +10,7 @@ | |||||
<!-- Chat sample strings --> | ||||||
<string name="chat_label">Message</string> | ||||||
<string name="action_send">Send</string> | ||||||
|
||||||
<!-- Image description --> | ||||||
<string name="nya_avatar_descritpion">Nya looking at something</string> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</resources> |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -15,4 +15,5 @@ dependencyResolutionManagement { | |||
} | ||||
} | ||||
|
||||
rootProject.name = "Soga" | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove this line?
Suggested change
|
||||
include(":app") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
The review comment correctly emphasizes the importance of optimizing image resources for different screen densities. However, the verification process revealed that "nya.png" is not optimized for different screen densities, as it exists only in the base
drawable
folder. This could lead to performance issues or a suboptimal user experience on devices with varying screen densities.Analysis chain
The addition of image handling capabilities with the
Image
component and related imports is a positive enhancement for avatar display. Ensure the UI remains responsive and test with various image sizes and screen densities.Scripts Executed
The following scripts were executed for the analysis:
Script:
Length of output: 120