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) {
// Фаза 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
)
}
}
}
}