Профиль, редактирование без аватара

This commit is contained in:
Халимов Рустам
2026-04-16 15:41:22 +03:00
parent 8409c51842
commit cea3f4d669
45 changed files with 1063 additions and 178 deletions

View File

@@ -41,13 +41,17 @@ fun ProfileScreen(
) {
val state by viewModel.state.collectAsState()
LaunchedEffect(profileId) {
// Загружаем профиль при первом запуске
LaunchedEffect(Unit) {
android.util.Log.d("ProfileScreen", "Loading profile with profileId=$profileId")
viewModel.loadProfile(profileId)
}
val profile = state.profile
val isOwnProfile = profileId == null
android.util.Log.d("ProfileScreen", "Profile loaded: displayName=${profile?.displayName}, bio=${profile?.bio}, birthday=${profile?.birthday}")
val mediaTabs = listOf(
stringResource(R.string.media),
"GIF",
@@ -68,7 +72,7 @@ fun ProfileScreen(
Scaffold(
topBar = {
TopAppBar(
title = { Text(if (isOwnProfile) stringResource(R.string.profile) else stringResource(R.string.profile)) },
title = { Text(if (isOwnProfile) stringResource(R.string.profile) else stringResource(R.string.profile), fontWeight = FontWeight.Bold) },
navigationIcon = {
IconButton(onClick = onBack) {
Icon(Icons.Default.ArrowBack, contentDescription = stringResource(R.string.back))
@@ -80,7 +84,13 @@ fun ProfileScreen(
Icon(Icons.Default.Edit, contentDescription = stringResource(R.string.edit_profile))
}
}
}
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = Color.Transparent,
titleContentColor = Color.White,
actionIconContentColor = Color.White,
navigationIconContentColor = Color.White
)
)
}
) { paddingValues ->
@@ -95,6 +105,7 @@ fun ProfileScreen(
displayName = profile?.displayName,
avatarUrl = profile?.avatarUrl,
bio = profile?.bio,
birthday = profile?.birthday,
isOwnProfile = isOwnProfile,
isCallsEnabled = true,
onSendMessage = { profile?.id?.let { id -> onSendMessage(id) } },
@@ -143,6 +154,7 @@ fun ProfileHeader(
displayName: String?,
avatarUrl: String?,
bio: String?,
birthday: String?,
isOwnProfile: Boolean,
isCallsEnabled: Boolean,
onSendMessage: () -> Unit,
@@ -190,11 +202,27 @@ fun ProfileHeader(
}
}
if (bio != null) {
if (bio != null || birthday != null) {
Spacer(modifier = Modifier.height(24.dp))
Column(modifier = Modifier.fillMaxWidth()) {
Text(text = stringResource(R.string.bio), style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)
Text(text = bio, style = MaterialTheme.typography.bodyMedium)
if (birthday != null) {
Text(text = "Дата рождения", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)
// Форматируем дату из ISO8601 в dd.MM.yyyy
val formattedBirthday = try {
val format = java.text.SimpleDateFormat("yyyy-MM-dd", java.util.Locale.getDefault())
val date = format.parse(birthday)
val outputFormat = java.text.SimpleDateFormat("dd.MM.yyyy", java.util.Locale.getDefault())
date?.let { outputFormat.format(it) } ?: birthday
} catch (e: Exception) {
birthday
}
Text(text = formattedBirthday, style = MaterialTheme.typography.bodyMedium)
Spacer(modifier = Modifier.height(8.dp))
}
if (bio != null) {
Text(text = stringResource(R.string.bio), style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)
Text(text = bio, style = MaterialTheme.typography.bodyMedium)
}
}
}
}