feat: Update ProfileScreen to include conditional save button and adjust avatar positioning

This commit is contained in:
k1ngsterr1
2026-01-30 05:00:38 +05:00
parent 116398d00d
commit f7240ddfe6

View File

@@ -689,7 +689,8 @@ private fun CollapsingProfileHeader(
if (collapseProgress < 0.4f) { if (collapseProgress < 0.4f) {
// Фаза 1: от полного размера до круга // Фаза 1: от полного размера до круга
val phase1Progress = collapseProgress / 0.4f 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) avatarHeight = androidx.compose.ui.unit.lerp(expandedHeight, circleSize, phase1Progress)
} else { } else {
// Фаза 2: от круга до 0 // Фаза 2: от круга до 0
@@ -701,8 +702,8 @@ private fun CollapsingProfileHeader(
// Для cornerRadius используем меньшую сторону // Для cornerRadius используем меньшую сторону
val avatarSize = minOf(avatarWidth, avatarHeight) val avatarSize = minOf(avatarWidth, avatarHeight)
// Позиция X: центрируем аватар // Позиция X: центрируем аватар (с учётом добавленных 4dp)
val avatarX = (screenWidthDp - avatarWidth) / 2 val avatarX = (screenWidthDp - avatarWidth) / 2 - 2.dp
// Позиция Y: от 0 до центра header, потом уходит вверх // Позиция Y: от 0 до центра header, потом уходит вверх
val avatarY = if (collapseProgress < 0.4f) { 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( Box(
modifier = Modifier modifier = Modifier
.align(Alignment.TopEnd) .align(Alignment.TopEnd)
.padding(top = statusBarHeight) .padding(top = statusBarHeight)
.padding(end = 4.dp, top = 4.dp) .padding(end = 4.dp, top = 4.dp),
.size(48.dp),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
IconButton( // Save button (when has changes)
onClick = { onAvatarMenuChange(true) }, AnimatedVisibility(
modifier = Modifier.size(48.dp) visible = hasChanges,
enter = fadeIn(),
exit = fadeOut()
) { ) {
Icon( TextButton(onClick = onSave) {
imageVector = TablerIcons.DotsVertical, Text(
contentDescription = "Profile menu", text = "Save",
tint = Color.White, color = if (isDarkTheme) Color.White else Color.Black,
modifier = Modifier.size(24.dp) 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) 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
)
}
}
} }
} }