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) {
|
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,15 +829,36 @@ 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
|
||||||
|
) {
|
||||||
|
// 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(
|
IconButton(
|
||||||
onClick = { onAvatarMenuChange(true) },
|
onClick = { onAvatarMenuChange(true) },
|
||||||
@@ -845,10 +867,11 @@ private fun CollapsingProfileHeader(
|
|||||||
Icon(
|
Icon(
|
||||||
imageVector = TablerIcons.DotsVertical,
|
imageVector = TablerIcons.DotsVertical,
|
||||||
contentDescription = "Profile menu",
|
contentDescription = "Profile menu",
|
||||||
tint = Color.White,
|
tint = Color.White, // Всегда белые - на фоне аватара
|
||||||
modifier = Modifier.size(24.dp)
|
modifier = Modifier.size(24.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Меню для установки фото профиля
|
// Меню для установки фото профиля
|
||||||
com.rosetta.messenger.ui.chats.components.ProfilePhotoMenu(
|
com.rosetta.messenger.ui.chats.components.ProfilePhotoMenu(
|
||||||
@@ -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
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user