diff --git a/app/src/main/java/com/rosetta/messenger/MainActivity.kt b/app/src/main/java/com/rosetta/messenger/MainActivity.kt index 68fec53..4895b21 100644 --- a/app/src/main/java/com/rosetta/messenger/MainActivity.kt +++ b/app/src/main/java/com/rosetta/messenger/MainActivity.kt @@ -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 } ) diff --git a/app/src/main/java/com/rosetta/messenger/ui/settings/OtherProfileScreen.kt b/app/src/main/java/com/rosetta/messenger/ui/settings/OtherProfileScreen.kt index 6b883c8..96ee8b1 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/settings/OtherProfileScreen.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/settings/OtherProfileScreen.kt @@ -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) diff --git a/app/src/main/java/com/rosetta/messenger/ui/settings/ProfileScreen.kt b/app/src/main/java/com/rosetta/messenger/ui/settings/ProfileScreen.kt index f2cebdd..c215ca8 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/settings/ProfileScreen.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/settings/ProfileScreen.kt @@ -121,27 +121,31 @@ fun ProfileScreen( hasChanges = editedName != accountName || editedUsername != accountUsername } - Column( + Box( modifier = Modifier .fillMaxSize() .background(backgroundColor) - .verticalScroll(rememberScrollState()) ) { - // ═════════════════════════════════════════════════════════════ - // 👤 PROFILE CARD with colored header - // ═════════════════════════════════════════════════════════════ - ProfileCard( - name = editedName.ifBlank { accountPublicKey.take(10) }, - username = editedUsername, - publicKey = accountPublicKey, - isDarkTheme = isDarkTheme, - onBack = onBack, - hasChanges = hasChanges, - onSave = { - onSaveProfile(editedName, editedUsername) - hasChanges = false - } - ) + Column( + modifier = Modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()) + ) { + // ═════════════════════════════════════════════════════════════ + // 👤 PROFILE CARD with colored header + // ═════════════════════════════════════════════════════════════ + ProfileCard( + name = editedName.ifBlank { accountPublicKey.take(10) }, + username = editedUsername, + publicKey = accountPublicKey, + isDarkTheme = isDarkTheme, + onBack = null, // Кнопка назад будет снаружи + hasChanges = hasChanges, + onSave = { + onSaveProfile(editedName, editedUsername) + hasChanges = false + } + ) Spacer(modifier = Modifier.height(16.dp)) @@ -270,6 +274,44 @@ 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 + ) + } + } } } @@ -277,12 +319,12 @@ fun ProfileScreen( // 📦 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,20 +334,21 @@ private fun ProfileCard( modifier = Modifier .fillMaxWidth() .background(avatarColors.backgroundColor) - .statusBarsPadding() ) { - // Back button - IconButton( - onClick = onBack, - modifier = Modifier - .align(Alignment.TopStart) - .padding(4.dp) - ) { - Icon( - imageVector = Icons.Filled.ArrowBack, - contentDescription = "Back", - tint = Color.White - ) + // Back button (if callback provided) + if (onBack != null) { + IconButton( + onClick = onBack, + modifier = Modifier + .align(Alignment.TopStart) + .padding(4.dp) + ) { + Icon( + imageVector = Icons.Filled.ArrowBack, + contentDescription = "Back", + tint = Color.White + ) + } } // Save button (if changes) diff --git a/app/src/main/java/com/rosetta/messenger/ui/settings/ThemeScreen.kt b/app/src/main/java/com/rosetta/messenger/ui/settings/ThemeScreen.kt index 34e111c..450185d 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/settings/ThemeScreen.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/settings/ThemeScreen.kt @@ -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"