feat: Update ProfileScreen to include conditional save button and adjust avatar positioning
This commit is contained in:
@@ -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,15 +829,36 @@ 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
|
||||
) {
|
||||
// Save button (when has changes)
|
||||
AnimatedVisibility(
|
||||
visible = hasChanges,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
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) },
|
||||
@@ -845,10 +867,11 @@ private fun CollapsingProfileHeader(
|
||||
Icon(
|
||||
imageVector = TablerIcons.DotsVertical,
|
||||
contentDescription = "Profile menu",
|
||||
tint = Color.White,
|
||||
tint = Color.White, // Всегда белые - на фоне аватара
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Меню для установки фото профиля
|
||||
com.rosetta.messenger.ui.chats.components.ProfilePhotoMenu(
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user