feat: Add navigation for contacts in MainScreen and update ProfileCard visibility
This commit is contained in:
@@ -477,6 +477,9 @@ fun MainScreen(
|
|||||||
onNewGroupClick = {
|
onNewGroupClick = {
|
||||||
// TODO: Navigate to new group
|
// TODO: Navigate to new group
|
||||||
},
|
},
|
||||||
|
onContactsClick = {
|
||||||
|
// TODO: Navigate to contacts
|
||||||
|
},
|
||||||
onCallsClick = {
|
onCallsClick = {
|
||||||
// TODO: Navigate to calls
|
// TODO: Navigate to calls
|
||||||
},
|
},
|
||||||
@@ -648,9 +651,11 @@ fun MainScreen(
|
|||||||
},
|
},
|
||||||
onLogout = onLogout,
|
onLogout = onLogout,
|
||||||
onNavigateToTheme = {
|
onNavigateToTheme = {
|
||||||
|
showProfileScreen = false
|
||||||
showThemeScreen = true
|
showThemeScreen = true
|
||||||
},
|
},
|
||||||
onNavigateToSafety = {
|
onNavigateToSafety = {
|
||||||
|
showProfileScreen = false
|
||||||
showSafetyScreen = true
|
showSafetyScreen = true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,18 +17,15 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.rosetta.messenger.network.SearchUser
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun OtherProfileScreen(
|
fun OtherProfileScreen(
|
||||||
|
user: SearchUser,
|
||||||
isDarkTheme: Boolean,
|
isDarkTheme: Boolean,
|
||||||
userName: String,
|
onBack: () -> Unit
|
||||||
userUsername: String,
|
|
||||||
userPublicKey: String,
|
|
||||||
isBlocked: Boolean,
|
|
||||||
onBack: () -> Unit,
|
|
||||||
onBlockUser: () -> Unit,
|
|
||||||
onUnblockUser: () -> Unit
|
|
||||||
) {
|
) {
|
||||||
|
var isBlocked by remember { mutableStateOf(false) }
|
||||||
val backgroundColor = if (isDarkTheme) Color(0xFF1A1A1A) else Color(0xFFFFFFFF)
|
val backgroundColor = if (isDarkTheme) Color(0xFF1A1A1A) else Color(0xFFFFFFFF)
|
||||||
val surfaceColor = if (isDarkTheme) Color(0xFF2C2C2E) else Color(0xFFF2F2F7)
|
val surfaceColor = if (isDarkTheme) Color(0xFF2C2C2E) else Color(0xFFF2F2F7)
|
||||||
val textColor = if (isDarkTheme) Color.White else Color.Black
|
val textColor = if (isDarkTheme) Color.White else Color.Black
|
||||||
@@ -42,9 +39,9 @@ fun OtherProfileScreen(
|
|||||||
) {
|
) {
|
||||||
// Profile Card with avatar
|
// Profile Card with avatar
|
||||||
ProfileCard(
|
ProfileCard(
|
||||||
name = userName,
|
name = user.title.ifEmpty { "Unknown User" },
|
||||||
username = userUsername,
|
username = user.username.ifEmpty { "" },
|
||||||
publicKey = userPublicKey,
|
publicKey = user.publicKey,
|
||||||
isDarkTheme = isDarkTheme,
|
isDarkTheme = isDarkTheme,
|
||||||
onBack = onBack,
|
onBack = onBack,
|
||||||
hasChanges = false,
|
hasChanges = false,
|
||||||
@@ -55,7 +52,7 @@ fun OtherProfileScreen(
|
|||||||
|
|
||||||
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
|
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
|
||||||
// Username Section (if available)
|
// Username Section (if available)
|
||||||
if (userUsername.isNotBlank()) {
|
if (user.username.isNotBlank()) {
|
||||||
Text(
|
Text(
|
||||||
text = "Username",
|
text = "Username",
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
@@ -76,7 +73,7 @@ fun OtherProfileScreen(
|
|||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "@$userUsername",
|
text = "@${user.username}",
|
||||||
fontSize = 16.sp,
|
fontSize = 16.sp,
|
||||||
color = textColor,
|
color = textColor,
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
@@ -126,7 +123,7 @@ fun OtherProfileScreen(
|
|||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = userPublicKey.take(20) + "..." + userPublicKey.takeLast(20),
|
text = user.publicKey.take(20) + "..." + user.publicKey.takeLast(20),
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
color = textColor,
|
color = textColor,
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
@@ -167,7 +164,10 @@ fun OtherProfileScreen(
|
|||||||
iconBackground = Color(0xFF2E7D32), // green
|
iconBackground = Color(0xFF2E7D32), // green
|
||||||
title = "Unblock User",
|
title = "Unblock User",
|
||||||
subtitle = "Allow this user to message you",
|
subtitle = "Allow this user to message you",
|
||||||
onClick = onUnblockUser,
|
onClick = {
|
||||||
|
isBlocked = false
|
||||||
|
// TODO: Implement actual unblock logic
|
||||||
|
},
|
||||||
isDarkTheme = isDarkTheme,
|
isDarkTheme = isDarkTheme,
|
||||||
hideChevron = true,
|
hideChevron = true,
|
||||||
textColor = Color(0xFF2E7D32)
|
textColor = Color(0xFF2E7D32)
|
||||||
@@ -178,7 +178,10 @@ fun OtherProfileScreen(
|
|||||||
iconBackground = Color(0xFFEF4444), // red
|
iconBackground = Color(0xFFEF4444), // red
|
||||||
title = "Block this user",
|
title = "Block this user",
|
||||||
subtitle = "Prevent this user from messaging you",
|
subtitle = "Prevent this user from messaging you",
|
||||||
onClick = onBlockUser,
|
onClick = {
|
||||||
|
isBlocked = true
|
||||||
|
// TODO: Implement actual block logic
|
||||||
|
},
|
||||||
isDarkTheme = isDarkTheme,
|
isDarkTheme = isDarkTheme,
|
||||||
hideChevron = true,
|
hideChevron = true,
|
||||||
textColor = Color(0xFFEF4444)
|
textColor = Color(0xFFEF4444)
|
||||||
|
|||||||
@@ -121,27 +121,31 @@ fun ProfileScreen(
|
|||||||
hasChanges = editedName != accountName || editedUsername != accountUsername
|
hasChanges = editedName != accountName || editedUsername != accountUsername
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.background(backgroundColor)
|
.background(backgroundColor)
|
||||||
.verticalScroll(rememberScrollState())
|
|
||||||
) {
|
) {
|
||||||
// ═════════════════════════════════════════════════════════════
|
Column(
|
||||||
// 👤 PROFILE CARD with colored header
|
modifier = Modifier
|
||||||
// ═════════════════════════════════════════════════════════════
|
.fillMaxSize()
|
||||||
ProfileCard(
|
.verticalScroll(rememberScrollState())
|
||||||
name = editedName.ifBlank { accountPublicKey.take(10) },
|
) {
|
||||||
username = editedUsername,
|
// ═════════════════════════════════════════════════════════════
|
||||||
publicKey = accountPublicKey,
|
// 👤 PROFILE CARD with colored header
|
||||||
isDarkTheme = isDarkTheme,
|
// ═════════════════════════════════════════════════════════════
|
||||||
onBack = onBack,
|
ProfileCard(
|
||||||
hasChanges = hasChanges,
|
name = editedName.ifBlank { accountPublicKey.take(10) },
|
||||||
onSave = {
|
username = editedUsername,
|
||||||
onSaveProfile(editedName, editedUsername)
|
publicKey = accountPublicKey,
|
||||||
hasChanges = false
|
isDarkTheme = isDarkTheme,
|
||||||
}
|
onBack = null, // Кнопка назад будет снаружи
|
||||||
)
|
hasChanges = hasChanges,
|
||||||
|
onSave = {
|
||||||
|
onSaveProfile(editedName, editedUsername)
|
||||||
|
hasChanges = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
@@ -270,6 +274,44 @@ fun ProfileScreen(
|
|||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(32.dp))
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,12 +319,12 @@ fun ProfileScreen(
|
|||||||
// 📦 PROFILE CARD COMPONENT - Large Avatar Telegram Style
|
// 📦 PROFILE CARD COMPONENT - Large Avatar Telegram Style
|
||||||
// ═════════════════════════════════════════════════════════════
|
// ═════════════════════════════════════════════════════════════
|
||||||
@Composable
|
@Composable
|
||||||
private fun ProfileCard(
|
fun ProfileCard(
|
||||||
name: String,
|
name: String,
|
||||||
username: String,
|
username: String,
|
||||||
publicKey: String,
|
publicKey: String,
|
||||||
isDarkTheme: Boolean,
|
isDarkTheme: Boolean,
|
||||||
onBack: () -> Unit,
|
onBack: (() -> Unit)?,
|
||||||
hasChanges: Boolean,
|
hasChanges: Boolean,
|
||||||
onSave: () -> Unit
|
onSave: () -> Unit
|
||||||
) {
|
) {
|
||||||
@@ -292,20 +334,21 @@ private fun ProfileCard(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.background(avatarColors.backgroundColor)
|
.background(avatarColors.backgroundColor)
|
||||||
.statusBarsPadding()
|
|
||||||
) {
|
) {
|
||||||
// Back button
|
// Back button (if callback provided)
|
||||||
IconButton(
|
if (onBack != null) {
|
||||||
onClick = onBack,
|
IconButton(
|
||||||
modifier = Modifier
|
onClick = onBack,
|
||||||
.align(Alignment.TopStart)
|
modifier = Modifier
|
||||||
.padding(4.dp)
|
.align(Alignment.TopStart)
|
||||||
) {
|
.padding(4.dp)
|
||||||
Icon(
|
) {
|
||||||
imageVector = Icons.Filled.ArrowBack,
|
Icon(
|
||||||
contentDescription = "Back",
|
imageVector = Icons.Filled.ArrowBack,
|
||||||
tint = Color.White
|
contentDescription = "Back",
|
||||||
)
|
tint = Color.White
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save button (if changes)
|
// Save button (if changes)
|
||||||
|
|||||||
@@ -33,21 +33,9 @@ fun ThemeScreen(
|
|||||||
onBack: () -> Unit,
|
onBack: () -> Unit,
|
||||||
onThemeChange: (Boolean) -> Unit
|
onThemeChange: (Boolean) -> Unit
|
||||||
) {
|
) {
|
||||||
val backgroundColor by animateColorAsState(
|
val backgroundColor = if (isDarkTheme) Color(0xFF1A1A1A) else Color(0xFFFFFFFF)
|
||||||
targetValue = if (isDarkTheme) Color(0xFF1A1A1A) else Color(0xFFFFFFFF),
|
val surfaceColor = if (isDarkTheme) Color(0xFF2C2C2E) else Color(0xFFF2F2F7)
|
||||||
animationSpec = tween(300),
|
val textColor = if (isDarkTheme) Color.White else Color.Black
|
||||||
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 secondaryTextColor = if (isDarkTheme) Color(0xFF8E8E93) else Color(0xFF666666)
|
val secondaryTextColor = if (isDarkTheme) Color(0xFF8E8E93) else Color(0xFF666666)
|
||||||
|
|
||||||
// Theme mode: "light", "dark", "auto"
|
// Theme mode: "light", "dark", "auto"
|
||||||
|
|||||||
Reference in New Issue
Block a user