feat: Add camera button to MediaGrid for quick access

This commit is contained in:
2026-01-29 21:54:17 +05:00
parent 5d1ba8144f
commit 8c30fc3549
4 changed files with 181 additions and 35 deletions

View File

@@ -7,7 +7,9 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.ui.graphics.Shape
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@@ -44,6 +46,7 @@ import kotlinx.coroutines.withContext
* @param onClick Обработчик клика (опционально)
* @param showOnlineIndicator Показывать индикатор онлайн
* @param isOnline Пользователь онлайн
* @param shape Форма аватара (по умолчанию круг)
*/
@Composable
fun AvatarImage(
@@ -53,7 +56,8 @@ fun AvatarImage(
isDarkTheme: Boolean,
onClick: (() -> Unit)? = null,
showOnlineIndicator: Boolean = false,
isOnline: Boolean = false
isOnline: Boolean = false,
shape: Shape = CircleShape
) {
// Получаем аватары из репозитория
val avatars by avatarRepository?.getAvatars(publicKey, allDecode = false)?.collectAsState()
@@ -85,7 +89,7 @@ fun AvatarImage(
Box(
modifier = Modifier
.size(size)
.clip(CircleShape)
.clip(shape)
.then(
if (onClick != null) {
Modifier.clickable(onClick = onClick)
@@ -113,7 +117,8 @@ fun AvatarImage(
AvatarPlaceholder(
publicKey = publicKey,
size = size,
isDarkTheme = isDarkTheme
isDarkTheme = isDarkTheme,
shape = shape
)
}
@@ -137,7 +142,8 @@ fun AvatarPlaceholder(
publicKey: String,
size: Dp = 40.dp,
isDarkTheme: Boolean,
fontSize: TextUnit? = null
fontSize: TextUnit? = null,
shape: Shape = CircleShape
) {
val avatarColors = getAvatarColor(publicKey, isDarkTheme)
val avatarText = getAvatarText(publicKey)
@@ -145,7 +151,7 @@ fun AvatarPlaceholder(
Box(
modifier = Modifier
.size(size)
.clip(CircleShape)
.clip(shape)
.background(avatarColors.backgroundColor),
contentAlignment = Alignment.Center
) {