From f7240ddfe65175ece825ede5bb68fe1a9d5e3ed2 Mon Sep 17 00:00:00 2001 From: k1ngsterr1 Date: Fri, 30 Jan 2026 05:00:38 +0500 Subject: [PATCH] feat: Update ProfileScreen to include conditional save button and adjust avatar positioning --- .../messenger/ui/settings/ProfileScreen.kt | 74 ++++++++++--------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/com/rosetta/messenger/ui/settings/ProfileScreen.kt b/app/src/main/java/com/rosetta/messenger/ui/settings/ProfileScreen.kt index 1ed43d0..ab2a912 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/settings/ProfileScreen.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/settings/ProfileScreen.kt @@ -689,7 +689,8 @@ private fun CollapsingProfileHeader( if (collapseProgress < 0.4f) { // Фаза 1: от полного размера до круга val phase1Progress = collapseProgress / 0.4f - avatarWidth = androidx.compose.ui.unit.lerp(screenWidthDp, circleSize, phase1Progress) + // Добавляем 4.dp чтобы гарантированно закрыть края + avatarWidth = androidx.compose.ui.unit.lerp(screenWidthDp , circleSize, phase1Progress) avatarHeight = androidx.compose.ui.unit.lerp(expandedHeight, circleSize, phase1Progress) } else { // Фаза 2: от круга до 0 @@ -701,8 +702,8 @@ private fun CollapsingProfileHeader( // Для cornerRadius используем меньшую сторону val avatarSize = minOf(avatarWidth, avatarHeight) - // Позиция X: центрируем аватар - val avatarX = (screenWidthDp - avatarWidth) / 2 + // Позиция X: центрируем аватар (с учётом добавленных 4dp) + val avatarX = (screenWidthDp - avatarWidth) / 2 - 2.dp // Позиция Y: от 0 до центра header, потом уходит вверх val avatarY = if (collapseProgress < 0.4f) { @@ -828,26 +829,48 @@ private fun CollapsingProfileHeader( } // ═══════════════════════════════════════════════════════════ - // ⋮ MENU BUTTON (top right corner, поверх аватара) + // ⋮ MENU BUTTON / 💾 SAVE BUTTON (top right corner) + // Показываем Save если есть изменения, иначе три точки меню // ═══════════════════════════════════════════════════════════ Box( modifier = Modifier .align(Alignment.TopEnd) .padding(top = statusBarHeight) - .padding(end = 4.dp, top = 4.dp) - .size(48.dp), + .padding(end = 4.dp, top = 4.dp), contentAlignment = Alignment.Center ) { - IconButton( - onClick = { onAvatarMenuChange(true) }, - modifier = Modifier.size(48.dp) + // Save button (when has changes) + AnimatedVisibility( + visible = hasChanges, + enter = fadeIn(), + exit = fadeOut() ) { - Icon( - imageVector = TablerIcons.DotsVertical, - contentDescription = "Profile menu", - tint = Color.White, - modifier = Modifier.size(24.dp) - ) + TextButton(onClick = onSave) { + Text( + text = "Save", + color = if (isDarkTheme) Color.White else Color.Black, + fontWeight = FontWeight.SemiBold + ) + } + } + + // Menu button (when no changes) + AnimatedVisibility( + visible = !hasChanges, + enter = fadeIn(), + exit = fadeOut() + ) { + IconButton( + onClick = { onAvatarMenuChange(true) }, + modifier = Modifier.size(48.dp) + ) { + Icon( + imageVector = TablerIcons.DotsVertical, + contentDescription = "Profile menu", + tint = Color.White, // Всегда белые - на фоне аватара + modifier = Modifier.size(24.dp) + ) + } } // Меню для установки фото профиля @@ -902,27 +925,6 @@ private fun CollapsingProfileHeader( color = Color(0xFF4CAF50) ) } - - // ═══════════════════════════════════════════════════════════ - // 💾 SAVE BUTTON (if changes) - // ═══════════════════════════════════════════════════════════ - AnimatedVisibility( - visible = hasChanges, - enter = fadeIn() + expandHorizontally(), - exit = fadeOut() + shrinkHorizontally(), - modifier = Modifier - .align(Alignment.TopEnd) - .padding(top = statusBarHeight) - .padding(end = 52.dp, top = 4.dp) // Сдвинуто левее чтобы не накладываться на меню - ) { - TextButton(onClick = onSave) { - Text( - text = "Save", - color = if (isDarkTheme) Color.White else Color.Black, - fontWeight = FontWeight.SemiBold - ) - } - } } }