feat: Add navigation for contacts in MainScreen and update ProfileCard visibility

This commit is contained in:
k1ngsterr1
2026-01-20 21:42:57 +05:00
parent c42dd57e3d
commit 9edcb712fc
4 changed files with 101 additions and 62 deletions

View File

@@ -477,6 +477,9 @@ fun MainScreen(
onNewGroupClick = {
// TODO: Navigate to new group
},
onContactsClick = {
// TODO: Navigate to contacts
},
onCallsClick = {
// TODO: Navigate to calls
},
@@ -648,9 +651,11 @@ fun MainScreen(
},
onLogout = onLogout,
onNavigateToTheme = {
showProfileScreen = false
showThemeScreen = true
},
onNavigateToSafety = {
showProfileScreen = false
showSafetyScreen = true
}
)

View File

@@ -17,18 +17,15 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.rosetta.messenger.network.SearchUser
@Composable
fun OtherProfileScreen(
user: SearchUser,
isDarkTheme: Boolean,
userName: String,
userUsername: String,
userPublicKey: String,
isBlocked: Boolean,
onBack: () -> Unit,
onBlockUser: () -> Unit,
onUnblockUser: () -> Unit
onBack: () -> Unit
) {
var isBlocked by remember { mutableStateOf(false) }
val backgroundColor = if (isDarkTheme) Color(0xFF1A1A1A) else Color(0xFFFFFFFF)
val surfaceColor = if (isDarkTheme) Color(0xFF2C2C2E) else Color(0xFFF2F2F7)
val textColor = if (isDarkTheme) Color.White else Color.Black
@@ -42,9 +39,9 @@ fun OtherProfileScreen(
) {
// Profile Card with avatar
ProfileCard(
name = userName,
username = userUsername,
publicKey = userPublicKey,
name = user.title.ifEmpty { "Unknown User" },
username = user.username.ifEmpty { "" },
publicKey = user.publicKey,
isDarkTheme = isDarkTheme,
onBack = onBack,
hasChanges = false,
@@ -55,7 +52,7 @@ fun OtherProfileScreen(
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
// Username Section (if available)
if (userUsername.isNotBlank()) {
if (user.username.isNotBlank()) {
Text(
text = "Username",
fontSize = 14.sp,
@@ -76,7 +73,7 @@ fun OtherProfileScreen(
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "@$userUsername",
text = "@${user.username}",
fontSize = 16.sp,
color = textColor,
modifier = Modifier.weight(1f)
@@ -126,7 +123,7 @@ fun OtherProfileScreen(
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = userPublicKey.take(20) + "..." + userPublicKey.takeLast(20),
text = user.publicKey.take(20) + "..." + user.publicKey.takeLast(20),
fontSize = 12.sp,
color = textColor,
modifier = Modifier.weight(1f)
@@ -167,7 +164,10 @@ fun OtherProfileScreen(
iconBackground = Color(0xFF2E7D32), // green
title = "Unblock User",
subtitle = "Allow this user to message you",
onClick = onUnblockUser,
onClick = {
isBlocked = false
// TODO: Implement actual unblock logic
},
isDarkTheme = isDarkTheme,
hideChevron = true,
textColor = Color(0xFF2E7D32)
@@ -178,7 +178,10 @@ fun OtherProfileScreen(
iconBackground = Color(0xFFEF4444), // red
title = "Block this user",
subtitle = "Prevent this user from messaging you",
onClick = onBlockUser,
onClick = {
isBlocked = true
// TODO: Implement actual block logic
},
isDarkTheme = isDarkTheme,
hideChevron = true,
textColor = Color(0xFFEF4444)

View File

@@ -121,10 +121,14 @@ fun ProfileScreen(
hasChanges = editedName != accountName || editedUsername != accountUsername
}
Column(
Box(
modifier = Modifier
.fillMaxSize()
.background(backgroundColor)
) {
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
) {
// ═════════════════════════════════════════════════════════════
@@ -135,7 +139,7 @@ fun ProfileScreen(
username = editedUsername,
publicKey = accountPublicKey,
isDarkTheme = isDarkTheme,
onBack = onBack,
onBack = null, // Кнопка назад будет снаружи
hasChanges = hasChanges,
onSave = {
onSaveProfile(editedName, editedUsername)
@@ -271,18 +275,56 @@ fun ProfileScreen(
Spacer(modifier = Modifier.height(32.dp))
}
// Fixed back button at top
IconButton(
onClick = onBack,
modifier = Modifier
.align(Alignment.TopStart)
.statusBarsPadding()
.padding(4.dp)
) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = "Back",
tint = Color.White
)
}
// Fixed save button (if changes)
AnimatedVisibility(
visible = hasChanges,
enter = fadeIn() + expandHorizontally(),
exit = fadeOut() + shrinkHorizontally(),
modifier = Modifier
.align(Alignment.TopEnd)
.statusBarsPadding()
.padding(4.dp)
) {
TextButton(onClick = {
onSaveProfile(editedName, editedUsername)
hasChanges = false
}) {
Text(
text = "Save",
color = Color.White,
fontWeight = FontWeight.SemiBold
)
}
}
}
}
// ═════════════════════════════════════════════════════════════
// 📦 PROFILE CARD COMPONENT - Large Avatar Telegram Style
// ═════════════════════════════════════════════════════════════
@Composable
private fun ProfileCard(
fun ProfileCard(
name: String,
username: String,
publicKey: String,
isDarkTheme: Boolean,
onBack: () -> Unit,
onBack: (() -> Unit)?,
hasChanges: Boolean,
onSave: () -> Unit
) {
@@ -292,9 +334,9 @@ private fun ProfileCard(
modifier = Modifier
.fillMaxWidth()
.background(avatarColors.backgroundColor)
.statusBarsPadding()
) {
// Back button
// Back button (if callback provided)
if (onBack != null) {
IconButton(
onClick = onBack,
modifier = Modifier
@@ -307,6 +349,7 @@ private fun ProfileCard(
tint = Color.White
)
}
}
// Save button (if changes)
AnimatedVisibility(

View File

@@ -33,21 +33,9 @@ fun ThemeScreen(
onBack: () -> Unit,
onThemeChange: (Boolean) -> Unit
) {
val backgroundColor by animateColorAsState(
targetValue = if (isDarkTheme) Color(0xFF1A1A1A) else Color(0xFFFFFFFF),
animationSpec = tween(300),
label = "backgroundColor"
)
val surfaceColor by animateColorAsState(
targetValue = if (isDarkTheme) Color(0xFF2C2C2E) else Color(0xFFF2F2F7),
animationSpec = tween(300),
label = "surfaceColor"
)
val textColor by animateColorAsState(
targetValue = if (isDarkTheme) Color.White else Color.Black,
animationSpec = tween(300),
label = "textColor"
)
val backgroundColor = if (isDarkTheme) Color(0xFF1A1A1A) else Color(0xFFFFFFFF)
val surfaceColor = if (isDarkTheme) Color(0xFF2C2C2E) else Color(0xFFF2F2F7)
val textColor = if (isDarkTheme) Color.White else Color.Black
val secondaryTextColor = if (isDarkTheme) Color(0xFF8E8E93) else Color(0xFF666666)
// Theme mode: "light", "dark", "auto"