feat: Add Lottie animation for avatar in attachment UI and refactor file layout by removing search functionality

This commit is contained in:
2026-02-22 18:32:03 +05:00
parent 14ab10a1a0
commit 290143dfc4
5 changed files with 35 additions and 81 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,7 @@
package com.rosetta.messenger
import android.app.Application
import com.airbnb.lottie.L
import com.rosetta.messenger.data.DraftManager
import com.rosetta.messenger.utils.CrashReportManager
@@ -16,6 +17,8 @@ class RosettaApplication : Application() {
override fun onCreate() {
super.onCreate()
// Убираем красную букву "L" от Lottie
L.setTraceEnabled(false)
// Инициализируем crash reporter
initCrashReporting()

View File

@@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -11,7 +12,11 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.rosetta.messenger.ui.icons.TelegramIcons
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.LottieConstants
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
import com.rosetta.messenger.ui.onboarding.PrimaryBlue
/**
@@ -27,6 +32,12 @@ internal fun AttachAlertAvatarLayout(
val textColor = if (isDarkTheme) Color.White else Color.Black
val secondaryTextColor = Color(0xFF8E8E93)
val composition by rememberLottieComposition(LottieCompositionSpec.Asset("lottie/avatar.json"))
val progress by animateLottieCompositionAsState(
composition = composition,
iterations = LottieConstants.IterateForever
)
Box(
modifier = modifier.fillMaxWidth(),
contentAlignment = Alignment.Center
@@ -35,11 +46,10 @@ internal fun AttachAlertAvatarLayout(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(32.dp)
) {
Icon(
painter = TelegramIcons.Contact,
contentDescription = null,
tint = PrimaryBlue,
modifier = Modifier.size(72.dp)
LottieAnimation(
composition = composition,
progress = { progress },
modifier = Modifier.size(100.dp)
)
Spacer(modifier = Modifier.height(20.dp))
Text(

View File

@@ -14,7 +14,6 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@@ -106,8 +105,6 @@ internal fun AttachAlertFileLayout(
var currentDir by remember { mutableStateOf<File?>(null) }
var currentTitle by remember { mutableStateOf("Select File") }
var history by remember { mutableStateOf(listOf<HistoryEntry>()) }
var searchQuery by remember { mutableStateOf("") }
var isSearching by remember { mutableStateOf(false) }
// ── Gallery mode state ──
var showGallery by remember { mutableStateOf(false) }
@@ -127,11 +124,8 @@ internal fun AttachAlertFileLayout(
} else emptyList()
}
// ── Search filter ──
val displayedRecentFiles = if (searchQuery.isBlank()) recentFiles
else recentFiles.filter { it.name.contains(searchQuery, ignoreCase = true) }
val displayedDirContents = if (searchQuery.isBlank()) dirContents
else dirContents.filter { it.name.contains(searchQuery, ignoreCase = true) }
val displayedRecentFiles = recentFiles
val displayedDirContents = dirContents
// ── Back handler ──
val isAtRoot = currentDir == null
@@ -146,8 +140,6 @@ internal fun AttachAlertFileLayout(
currentDir = null
currentTitle = "Select File"
}
searchQuery = ""
isSearching = false
}
fun navigateToDir(dir: File) {
@@ -155,8 +147,6 @@ internal fun AttachAlertFileLayout(
history = history + HistoryEntry(currentDir ?: Environment.getExternalStorageDirectory(), currentTitle)
currentDir = dir
currentTitle = dir.name
searchQuery = ""
isSearching = false
}
if (showGallery) {
@@ -182,8 +172,6 @@ internal fun AttachAlertFileLayout(
FilePickerTopBar(
title = displayTitle,
showBack = showGallery || !isAtRoot,
isSearching = isSearching,
searchQuery = searchQuery,
onBackClick = {
if (showGallery) {
showGallery = false
@@ -192,8 +180,6 @@ internal fun AttachAlertFileLayout(
navigateBack()
}
},
onSearchToggle = { isSearching = !isSearching; if (!isSearching) searchQuery = "" },
onSearchQueryChange = { searchQuery = it },
textColor = textColor,
bgColor = bgColor
)
@@ -357,7 +343,7 @@ internal fun AttachAlertFileLayout(
}
)
}
} else if (searchQuery.isBlank()) {
} else {
item(key = "recent_empty_divider") {
Spacer(
modifier = Modifier
@@ -390,7 +376,7 @@ internal fun AttachAlertFileLayout(
contentAlignment = Alignment.Center
) {
Text(
text = if (searchQuery.isNotBlank()) "No results" else "Empty folder",
text = "Empty folder",
color = secondaryText,
fontSize = 15.sp
)
@@ -437,11 +423,7 @@ internal fun AttachAlertFileLayout(
private fun FilePickerTopBar(
title: String,
showBack: Boolean,
isSearching: Boolean,
searchQuery: String,
onBackClick: () -> Unit,
onSearchToggle: () -> Unit,
onSearchQueryChange: (String) -> Unit,
textColor: Color,
bgColor: Color
) {
@@ -465,44 +447,15 @@ private fun FilePickerTopBar(
Spacer(modifier = Modifier.width(12.dp))
}
if (isSearching) {
TextField(
value = searchQuery,
onValueChange = onSearchQueryChange,
placeholder = {
Text("Search", color = Color(0xFF8E8E93), fontSize = 16.sp)
},
singleLine = true,
colors = TextFieldDefaults.colors(
focusedContainerColor = Color.Transparent,
unfocusedContainerColor = Color.Transparent,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
cursorColor = PrimaryBlue,
focusedTextColor = textColor,
unfocusedTextColor = textColor
),
modifier = Modifier.weight(1f)
)
} else {
Text(
text = title,
color = textColor,
fontSize = 18.sp,
fontWeight = FontWeight.SemiBold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f)
)
}
IconButton(onClick = onSearchToggle) {
Icon(
imageVector = Icons.Default.Search,
contentDescription = "Search",
tint = textColor
)
}
Text(
text = title,
color = textColor,
fontSize = 18.sp,
fontWeight = FontWeight.SemiBold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f)
)
}
}

View File

@@ -675,26 +675,13 @@ fun ImageCollage(
val totalRows = rows.size
rows.forEachIndexed { rowIndex, rowItems ->
val isLastRow = rowIndex == totalRows - 1
val isIncompleteRow = rowItems.size < 3
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = if (isIncompleteRow)
Arrangement.Start
else
Arrangement.spacedBy(spacing)
horizontalArrangement = Arrangement.spacedBy(spacing)
) {
rowItems.forEachIndexed { index, attachment ->
val isLastItem = isLastRow && index == rowItems.size - 1
// Для неполных рядов используем фиксированную ширину = 1/3 от общей
val cellModifier = if (isIncompleteRow) {
Modifier
.fillMaxWidth(1f / 3f)
.padding(end = if (index < rowItems.size - 1) spacing else 0.dp)
.aspectRatio(1f)
} else {
Modifier.weight(1f).aspectRatio(1f)
}
Box(modifier = cellModifier) {
Box(modifier = Modifier.weight(1f).aspectRatio(1f)) {
ImageAttachment(
attachment = attachment,
chachaKey = chachaKey,