Make avatar circular

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-09-12 14:52:33 +02:00 committed by Marcel Hibbe
parent f20ec95b5f
commit 6bc3b1a6e9
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
3 changed files with 15 additions and 5 deletions

View file

@ -15,7 +15,7 @@ import com.github.spotbugs.snom.SpotBugsTask
plugins {
id "org.jetbrains.kotlin.plugin.compose" version "2.0.20"
id "org.jetbrains.kotlin.kapt"
id 'com.google.devtools.ksp' version '2.0.20-1.0.25'
id 'com.google.devtools.ksp' version '2.0.20-1.0.24'
}
apply plugin: 'com.android.application'

View file

@ -33,6 +33,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
@ -58,7 +59,9 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.colorResource
@ -212,7 +215,7 @@ fun ConversationCreationScreen(
ConversationNameAndDescription(conversationCreationViewModel)
AddParticipants(launcher, context, conversationCreationViewModel)
RoomCreationOptions(conversationCreationViewModel)
CreateConversation(conversationCreationViewModel, context,selectedImageUri)
CreateConversation(conversationCreationViewModel, context, selectedImageUri)
}
}
)
@ -228,17 +231,21 @@ fun DefaultUserAvatar(selectedImageUri: Uri?) {
AsyncImage(
model = selectedImageUri,
contentDescription = stringResource(id = R.string.user_avatar),
contentScale = ContentScale.Crop,
modifier = Modifier
.size(84.dp)
.padding(top = 8.dp)
.clip(CircleShape)
)
} else {
AsyncImage(
model = R.drawable.ic_circular_group,
contentDescription = stringResource(id = R.string.user_avatar),
contentScale = ContentScale.Crop,
modifier = Modifier
.size(84.dp)
.padding(top = 8.dp)
.clip(CircleShape)
)
}
}
@ -571,7 +578,11 @@ fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: Con
}
@Composable
fun CreateConversation(conversationCreationViewModel: ConversationCreationViewModel, context: Context,selectedImageUri: Uri?) {
fun CreateConversation(
conversationCreationViewModel: ConversationCreationViewModel,
context: Context,
selectedImageUri: Uri?
) {
val selectedParticipants by conversationCreationViewModel.selectedParticipants.collectAsState()
Box(
modifier = Modifier

View file

@ -109,7 +109,7 @@ class ConversationCreationViewModel @Inject constructor(
repository.setPassword(token, _password.value)
}
repository.openConversation(token, scope)
if(selectedImageUri!= null){
if (selectedImageUri != null) {
repository.uploadConversationAvatar(selectedImageUri.toFile(), token)
}
onRoomCreated(token)
@ -166,4 +166,3 @@ sealed class AddParticipantsUiState {
data class Success(val participants: List<Conversation>?) : AddParticipantsUiState()
data class Error(val message: String) : AddParticipantsUiState()
}