diff --git a/client-mobile/.gradle/8.5/executionHistory/executionHistory.bin b/client-mobile/.gradle/8.5/executionHistory/executionHistory.bin index 19a1f6d..6d6b5a9 100644 Binary files a/client-mobile/.gradle/8.5/executionHistory/executionHistory.bin and b/client-mobile/.gradle/8.5/executionHistory/executionHistory.bin differ diff --git a/client-mobile/.gradle/8.5/executionHistory/executionHistory.lock b/client-mobile/.gradle/8.5/executionHistory/executionHistory.lock index 0074cdd..70d3f74 100644 Binary files a/client-mobile/.gradle/8.5/executionHistory/executionHistory.lock and b/client-mobile/.gradle/8.5/executionHistory/executionHistory.lock differ diff --git a/client-mobile/.gradle/8.5/fileHashes/fileHashes.bin b/client-mobile/.gradle/8.5/fileHashes/fileHashes.bin index 4a5a6bc..a3016be 100644 Binary files a/client-mobile/.gradle/8.5/fileHashes/fileHashes.bin and b/client-mobile/.gradle/8.5/fileHashes/fileHashes.bin differ diff --git a/client-mobile/.gradle/8.5/fileHashes/fileHashes.lock b/client-mobile/.gradle/8.5/fileHashes/fileHashes.lock index 862107c..6d426be 100644 Binary files a/client-mobile/.gradle/8.5/fileHashes/fileHashes.lock and b/client-mobile/.gradle/8.5/fileHashes/fileHashes.lock differ diff --git a/client-mobile/.gradle/8.5/fileHashes/resourceHashesCache.bin b/client-mobile/.gradle/8.5/fileHashes/resourceHashesCache.bin index 74725ed..d6a1389 100644 Binary files a/client-mobile/.gradle/8.5/fileHashes/resourceHashesCache.bin and b/client-mobile/.gradle/8.5/fileHashes/resourceHashesCache.bin differ diff --git a/client-mobile/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/client-mobile/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 826695e..834a9ae 100644 Binary files a/client-mobile/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/client-mobile/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/client-mobile/.gradle/buildOutputCleanup/outputFiles.bin b/client-mobile/.gradle/buildOutputCleanup/outputFiles.bin index 0ce2ce6..ead1509 100644 Binary files a/client-mobile/.gradle/buildOutputCleanup/outputFiles.bin and b/client-mobile/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/client-mobile/chats/presentation/chat_list/ChatListViewModel.kt b/client-mobile/chats/presentation/chat_list/ChatListViewModel.kt index a1141b1..7382d54 100644 --- a/client-mobile/chats/presentation/chat_list/ChatListViewModel.kt +++ b/client-mobile/chats/presentation/chat_list/ChatListViewModel.kt @@ -58,13 +58,19 @@ class ChatListViewModel @Inject constructor( _state.update { it.copy(isLoading = true) } try { val chats = repository.getChats() - _state.update { it.copy(chats = chats, isLoading = false) } + _state.update { it.copy(chats = sortChats(chats), isLoading = false) } } catch (e: Exception) { _state.update { it.copy(isLoading = false, error = e.message) } } } } + private fun sortChats(chats: List): List { + return chats.sortedWith(compareByDescending { + it.name.equals("Избранное", ignoreCase = true) || it.name.equals("Saved Messages", ignoreCase = true) + }.thenByDescending { it.lastMessage?.createdAt }) + } + private fun observeSignalREvents() { signalrClient.events .onEach { event -> @@ -94,9 +100,9 @@ class ChatListViewModel @Inject constructor( unreadCount = chat.unreadCount + 1 ) } else chat - }.sortedByDescending { it.lastMessage?.createdAt } + } - currentState.copy(chats = updatedChats) + currentState.copy(chats = sortChats(updatedChats)) } } } diff --git a/client-mobile/chats/presentation/components/ChatItem.kt b/client-mobile/chats/presentation/components/ChatItem.kt index e2ef497..1bfdaee 100644 --- a/client-mobile/chats/presentation/components/ChatItem.kt +++ b/client-mobile/chats/presentation/components/ChatItem.kt @@ -11,6 +11,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp @@ -18,8 +19,9 @@ import androidx.compose.ui.unit.sp import chats.domain.model.Chat import androidx.compose.foundation.shape.RoundedCornerShape -import coil.compose.AsyncImage -import androidx.compose.ui.layout.ContentScale +import core.presentation.components.AppAvatar +import chats.domain.model.MediaType +import androidx.compose.runtime.remember @Composable fun ChatItem( @@ -33,28 +35,11 @@ fun ChatItem( .padding(12.dp), verticalAlignment = Alignment.CenterVertically ) { - // Аватар (мягкий квадрат) - Box( - modifier = Modifier - .size(50.dp) - .clip(RoundedCornerShape(12.dp)) - .background(MaterialTheme.colorScheme.primaryContainer), - contentAlignment = Alignment.Center - ) { - if (chat.avatar != null) { - AsyncImage( - model = chat.avatar, - contentDescription = null, - modifier = Modifier.fillMaxSize(), - contentScale = ContentScale.Crop - ) - } else { - Text( - text = chat.name.take(1).uppercase(), - style = MaterialTheme.typography.titleMedium - ) - } - } + AppAvatar( + url = chat.avatar, + name = chat.name, + size = 50.dp + ) Spacer(modifier = Modifier.width(12.dp)) @@ -70,8 +55,15 @@ fun ChatItem( overflow = TextOverflow.Ellipsis ) chat.lastMessage?.let { + val formattedTime = remember(it.createdAt) { + try { + it.createdAt.substringAfter('T').take(5) + } catch (e: Exception) { + "" + } + } Text( - text = it.createdAt.takeLast(5), // Упрощенный формат времени + text = formattedTime, style = MaterialTheme.typography.labelSmall, color = Color.Gray ) @@ -82,8 +74,27 @@ fun ChatItem( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { + val previewText = remember(chat.lastMessage) { + val msg = chat.lastMessage + if (msg == null) return@remember "No messages yet" + + if (!msg.content.isNullOrBlank()) { + msg.content + } else if (msg.mediaType == MediaType.AUDIO) { + "Голосовое сообщение" + } else if (msg.media.isNotEmpty()) { + when (msg.mediaType) { + MediaType.IMAGE -> "Фото" + MediaType.VIDEO -> "Видео" + MediaType.FILE -> "Файл" + else -> "Медиа" + } + } else { + "Сообщение" + } + } Text( - text = chat.lastMessage?.content ?: "No messages yet", + text = previewText, style = MaterialTheme.typography.bodyMedium, color = Color.Gray, maxLines = 1, diff --git a/client-mobile/chats/presentation/components/MessageBubble.kt b/client-mobile/chats/presentation/components/MessageBubble.kt index d65ac94..2c5c1a5 100644 --- a/client-mobile/chats/presentation/components/MessageBubble.kt +++ b/client-mobile/chats/presentation/components/MessageBubble.kt @@ -35,6 +35,9 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.material3.Icon import androidx.compose.ui.text.style.TextOverflow import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.filled.PlayArrow +import androidx.compose.material.icons.filled.VolumeOff +import core.presentation.components.AppMediaLightbox @OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class) @Composable @@ -46,11 +49,12 @@ fun MessageBubble( ) { val context = LocalContext.current var showReactionPicker by remember { mutableStateOf(false) } + var lightboxMedia by remember { mutableStateOf?>(null) } val backgroundColor = if (isCurrentUser) { - Color(0xFF3390EC) // Telegram Blue + Color(0xFF3096E5) // Updated Blue } else { - Color(0xFF2B2B2B) // Dark Grey + Color(0xFF212121) // Updated Dark Grey } val contentColor = Color.White @@ -119,13 +123,14 @@ fun MessageBubble( modifier = Modifier .fillMaxHeight() .width(2.dp) - .background(if (isCurrentUser) Color.White else Color(0xFF3390EC)) + .background(if (isCurrentUser) Color.White else Color(0xFF3096E5)) ) Column(modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp)) { + val accentColor = if (isCurrentUser) Color.White else Color(0xFF3096E5) Text( text = reply.senderName, style = MaterialTheme.typography.labelMedium, - color = if (isCurrentUser) Color.White else Color(0xFF3390EC), + color = accentColor, maxLines = 1, fontWeight = androidx.compose.ui.text.font.FontWeight.Bold ) @@ -153,22 +158,41 @@ fun MessageBubble( .fillMaxWidth() .clip(RoundedCornerShape(12.dp)) .clickable { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(mediaUrl)) - context.startActivity(intent) + lightboxMedia = mediaUrl to "image" }, contentScale = ContentScale.FillWidth ) } MediaType.VIDEO -> { - AppVideoPlayer( - url = mediaUrl, + Box( modifier = Modifier .fillMaxWidth() .height(200.dp) - .clip(RoundedCornerShape(12.dp)), - useController = true, - autoPlay = false - ) + .clip(RoundedCornerShape(12.dp)) + .background(Color.Black) + .clickable { + lightboxMedia = mediaUrl to "video" + }, + contentAlignment = Alignment.Center + ) { + AppVideoPlayer( + url = mediaUrl, + modifier = Modifier.fillMaxSize(), + useController = false, + autoPlay = true, + isMuted = true + ) + // Volume Off icon in top right + Icon( + imageVector = Icons.Default.VolumeOff, + contentDescription = null, + tint = Color.White.copy(alpha = 0.7f), + modifier = Modifier + .align(Alignment.TopEnd) + .padding(8.dp) + .size(20.dp) + ) + } } MediaType.AUDIO -> { AppAudioPlayer( @@ -186,6 +210,7 @@ fun MessageBubble( // Photo Grid for multiple images PhotoGrid( urls = message.media, + onMediaClick = { lightboxMedia = it to "image" }, modifier = Modifier .fillMaxWidth() .height(300.dp) @@ -218,11 +243,20 @@ fun MessageBubble( modifier = Modifier.padding(end = 4.dp) ) } + val formattedTime = remember(message.createdAt) { + try { + // Handle ISO 8601 strings like 2024-05-14T10:49:02.12Z + val timePart = message.createdAt.substringAfter('T').take(5) + if (timePart.contains(':')) timePart else "00:00" + } catch (e: Exception) { + "00:00" + } + } Text( - text = message.createdAt.takeLast(5), + text = formattedTime, style = MaterialTheme.typography.labelSmall, color = contentColor.copy(alpha = 0.6f), - fontSize = 10.sp + fontSize = 11.sp ) if (isCurrentUser) { Spacer(modifier = Modifier.width(2.dp)) @@ -236,6 +270,14 @@ fun MessageBubble( } } } + + lightboxMedia?.let { (url, type) -> + AppMediaLightbox( + url = url, + type = type, + onClose = { lightboxMedia = null } + ) + } } @Composable @@ -331,7 +373,7 @@ fun FileItem(mediaUrl: String, isCurrentUser: Boolean, contentColor: Color) { } @Composable -fun PhotoGrid(urls: List, modifier: Modifier = Modifier) { +fun PhotoGrid(urls: List, onMediaClick: (String) -> Unit, modifier: Modifier = Modifier) { val items = urls.take(4) Column(modifier = modifier) { val rows = (items.size + 1) / 2 @@ -344,7 +386,8 @@ fun PhotoGrid(urls: List, modifier: Modifier = Modifier) { modifier = Modifier .weight(1f) .fillMaxHeight() - .padding(1.dp), + .padding(1.dp) + .clickable { onMediaClick(items[firstIndex]) }, contentScale = ContentScale.Crop ) if (firstIndex + 1 < items.size) { @@ -354,7 +397,8 @@ fun PhotoGrid(urls: List, modifier: Modifier = Modifier) { modifier = Modifier .weight(1f) .fillMaxHeight() - .padding(1.dp), + .padding(1.dp) + .clickable { onMediaClick(items[firstIndex + 1]) }, contentScale = ContentScale.Crop ) } else if (rows > 1) { diff --git a/client-mobile/core/presentation/components/AppAudioPlayer.kt b/client-mobile/core/presentation/components/AppAudioPlayer.kt index 178274f..6c2f619 100644 --- a/client-mobile/core/presentation/components/AppAudioPlayer.kt +++ b/client-mobile/core/presentation/components/AppAudioPlayer.kt @@ -26,6 +26,10 @@ import kotlinx.coroutines.delay import androidx.compose.material.icons.filled.Download import androidx.compose.material.icons.filled.GraphicEq import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.unit.IntSize @Composable fun AppAudioPlayer( @@ -47,6 +51,7 @@ fun AppAudioPlayer( var currentPosition by remember { mutableLongStateOf(0L) } var duration by remember { mutableLongStateOf(0L) } var playbackSpeed by remember { mutableFloatStateOf(1.0f) } + var layoutSize by remember { mutableStateOf(IntSize.Zero) } val fileName = remember(url) { url.substringAfterLast("/") } @@ -110,7 +115,7 @@ fun AppAudioPlayer( ) { Box( modifier = Modifier - .size(36.dp) + .size(40.dp) .clip(CircleShape) .background(Color.White) .clickable { if (isPlaying) exoPlayer.pause() else exoPlayer.play() }, @@ -119,8 +124,8 @@ fun AppAudioPlayer( Icon( imageVector = if (isPlaying) Icons.Default.Pause else Icons.Default.PlayArrow, contentDescription = null, - tint = Color(0xFF3390EC), - modifier = Modifier.size(24.dp) + tint = Color(0xFF3096E5), + modifier = Modifier.size(28.dp) ) } @@ -129,68 +134,94 @@ fun AppAudioPlayer( .weight(1f) .padding(horizontal = 12.dp) ) { - Slider( - value = if (duration > 0) currentPosition.toFloat() / duration.toFloat() else 0f, - onValueChange = { - val newPos = (it * duration).toLong() - exoPlayer.seekTo(newPos) - currentPosition = newPos - }, - modifier = Modifier.height(16.dp), - colors = SliderDefaults.colors( - thumbColor = Color.White, - activeTrackColor = Color.White, - inactiveTrackColor = Color.White.copy(alpha = 0.3f) - ) - ) + // Waveform / Progress + Box( + modifier = Modifier + .fillMaxWidth() + .height(32.dp) + .onSizeChanged { layoutSize = it } + .pointerInput(duration) { + detectTapGestures { offset -> + if (duration > 0 && layoutSize.width > 0) { + val pct = offset.x / layoutSize.width.toFloat() + val newPos = (pct * duration).toLong() + exoPlayer.seekTo(newPos) + currentPosition = newPos + } + } + }, + contentAlignment = Alignment.CenterStart + ) { + androidx.compose.foundation.Canvas(modifier = Modifier.fillMaxSize()) { + val barCount = 35 + val barSpacing = 2.dp.toPx() + val barWidth = (size.width - (barCount - 1) * barSpacing) / barCount + val progress = if (duration > 0) currentPosition.toFloat() / duration.toFloat() else 0f + + // Fake consistent waveform items + val barHeights = listOf( + 0.4f, 0.6f, 0.3f, 0.8f, 0.5f, 0.9f, 0.4f, 0.7f, 0.5f, 0.8f, + 0.3f, 0.7f, 0.6f, 0.9f, 0.4f, 0.8f, 0.5f, 0.7f, 0.3f, 0.9f, + 0.5f, 0.6f, 0.4f, 0.8f, 0.6f, 0.7f, 0.5f, 0.4f, 0.5f, 0.7f, + 0.4f, 0.3f, 0.5f, 0.6f, 0.4f + ) + + for (i in 0 until barCount) { + val x = i * (barWidth + barSpacing) + val heightPct = barHeights[i % barHeights.size] + val barHeight = size.height * heightPct + val isActive = (i.toFloat() / barCount) <= progress + + drawRoundRect( + color = if (isActive) Color.White else Color.White.copy(alpha = 0.25f), + topLeft = androidx.compose.ui.geometry.Offset(x, (size.height - barHeight) / 2), + size = androidx.compose.ui.geometry.Size(barWidth, barHeight), + cornerRadius = androidx.compose.ui.geometry.CornerRadius(2.dp.toPx()) + ) + } + } + } + Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { Text( - text = formatDuration(currentPosition), - fontSize = 10.sp, + text = "${formatDuration(currentPosition)} / ${formatDuration(duration)}", + fontSize = 11.sp, color = contentColor.copy(alpha = 0.7f) ) - Row(verticalAlignment = Alignment.CenterVertically) { - Text( - text = "3.3 MB", // Mock size - fontSize = 10.sp, - color = contentColor.copy(alpha = 0.7f) - ) - Spacer(modifier = Modifier.width(4.dp)) + if (!isVoiceMessage) { Icon( Icons.Default.Download, contentDescription = null, tint = contentColor.copy(alpha = 0.7f), - modifier = Modifier.size(12.dp) + modifier = Modifier.size(14.dp) ) } } } - if (isVoiceMessage) { - Surface( - onClick = { - playbackSpeed = when (playbackSpeed) { - 1.0f -> 1.5f - 1.5f -> 2.0f - else -> 1.0f - } - exoPlayer.playbackParameters = PlaybackParameters(playbackSpeed) - }, - color = Color.White.copy(alpha = 0.2f), - shape = CircleShape, - modifier = Modifier.size(32.dp) - ) { - Box(contentAlignment = Alignment.Center) { - Text( - text = "${if (playbackSpeed % 1.0f == 0.0f) playbackSpeed.toInt() else playbackSpeed}x", - fontSize = 10.sp, - fontWeight = FontWeight.Bold, - color = Color.White - ) + Surface( + onClick = { + playbackSpeed = when (playbackSpeed) { + 1.0f -> 1.5f + 1.5f -> 2.0f + else -> 1.0f } + exoPlayer.playbackParameters = PlaybackParameters(playbackSpeed) + }, + color = Color.White.copy(alpha = 0.15f), + shape = CircleShape, + modifier = Modifier.size(36.dp) + ) { + Box(contentAlignment = Alignment.Center) { + Text( + text = "${if (playbackSpeed % 1.0f == 0.0f) playbackSpeed.toInt() else playbackSpeed}x", + fontSize = 11.sp, + fontWeight = FontWeight.Black, + color = Color.White + ) } } } diff --git a/client-mobile/core/presentation/components/AppAvatar.kt b/client-mobile/core/presentation/components/AppAvatar.kt index 935c62b..cf8def9 100644 --- a/client-mobile/core/presentation/components/AppAvatar.kt +++ b/client-mobile/core/presentation/components/AppAvatar.kt @@ -10,6 +10,8 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Bookmark import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -24,22 +26,30 @@ fun AppAvatar( size: Dp = 48.dp, modifier: Modifier = Modifier ) { + val isSavedMessages = remember(name) { + name.equals("Избранное", ignoreCase = true) || name.equals("Saved Messages", ignoreCase = true) + } + val initials = remember(name) { - val words = name.trim().split("\\s+".toRegex()) - if (words.size >= 2) { - (words[0].take(1) + words[1].take(1)).uppercase() - } else if (name.length >= 2) { - name.take(2).uppercase() - } else { - name.take(1).uppercase() + if (isSavedMessages) "" else { + val words = name.trim().split("\\s+".toRegex()) + if (words.size >= 2) { + (words[0].take(1) + words[1].take(1)).uppercase() + } else if (name.length >= 2) { + name.take(2).uppercase() + } else { + name.take(1).uppercase() + } } } + val avatarColor = Color(0xFF4AA6F3) // Premium Telegram Blue (Web) + Box( modifier = modifier .size(size) .clip(SoftSquareShape) - .background(MaterialTheme.colorScheme.primary.copy(alpha = 0.2f)), + .background(avatarColor), contentAlignment = Alignment.Center ) { if (!url.isNullOrBlank()) { @@ -49,10 +59,17 @@ fun AppAvatar( modifier = Modifier.size(size), contentScale = ContentScale.Crop ) + } else if (isSavedMessages) { + Icon( + imageVector = Icons.Default.Bookmark, + contentDescription = null, + tint = Color.White, + modifier = Modifier.size((size.value * 0.5).dp) + ) } else { Text( text = initials, - color = MaterialTheme.colorScheme.primary, + color = Color.White, fontSize = (size.value * 0.4).sp, fontWeight = androidx.compose.ui.text.font.FontWeight.Bold, style = MaterialTheme.typography.titleMedium diff --git a/client-mobile/core/presentation/components/AppMediaLightbox.kt b/client-mobile/core/presentation/components/AppMediaLightbox.kt new file mode 100644 index 0000000..d794fa1 --- /dev/null +++ b/client-mobile/core/presentation/components/AppMediaLightbox.kt @@ -0,0 +1,105 @@ +package core.presentation.components + +import androidx.compose.animation.* +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectTransformGestures +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Close +import androidx.compose.material.icons.filled.Download +import androidx.compose.material3.* +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogProperties +import coil.compose.AsyncImage + +@Composable +fun AppMediaLightbox( + url: String, + type: String = "image", + onClose: () -> Unit +) { + Dialog( + onDismissRequest = onClose, + properties = DialogProperties( + usePlatformDefaultWidth = false, + decorFitsSystemWindows = false + ) + ) { + var scale by remember { mutableFloatStateOf(1f) } + var offset by remember { mutableStateOf(androidx.compose.ui.geometry.Offset.Zero) } + + Box( + modifier = Modifier + .fillMaxSize() + .background(Color.Black) + .pointerInput(Unit) { + detectTransformGestures { _, pan, zoom, _ -> + scale = (scale * zoom).coerceIn(1f, 5f) + offset += pan + } + } + ) { + if (type == "video") { + AppVideoPlayer( + url = url, + modifier = Modifier.fillMaxSize(), + useController = true, + autoPlay = true + ) + } else { + AsyncImage( + model = url, + contentDescription = null, + modifier = Modifier + .fillMaxSize() + .graphicsLayer( + scaleX = scale, + scaleY = scale, + translationX = offset.x, + translationY = offset.y + ), + contentScale = ContentScale.Fit + ) + } + + // Top Bar + Row( + modifier = Modifier + .fillMaxWidth() + .statusBarsPadding() + .padding(16.dp), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically + ) { + IconButton( + onClick = onClose, + modifier = Modifier + .clip(CircleShape) + .background(Color.Black.copy(alpha = 0.5f)) + ) { + Icon(Icons.Default.Close, contentDescription = null, tint = Color.White) + } + + IconButton( + onClick = { /* Handle download */ }, + modifier = Modifier + .clip(CircleShape) + .background(Color.Black.copy(alpha = 0.5f)) + ) { + Icon(Icons.Default.Download, contentDescription = null, tint = Color.White) + } + } + } + } +} diff --git a/client-mobile/core/presentation/components/AppVideoPlayer.kt b/client-mobile/core/presentation/components/AppVideoPlayer.kt index 2a4a62e..1948a69 100644 --- a/client-mobile/core/presentation/components/AppVideoPlayer.kt +++ b/client-mobile/core/presentation/components/AppVideoPlayer.kt @@ -20,6 +20,7 @@ fun AppVideoPlayer( modifier: Modifier = Modifier, useController: Boolean = true, autoPlay: Boolean = true, + isMuted: Boolean = false, onVideoFinished: () -> Unit = {} ) { val context = LocalContext.current @@ -28,6 +29,7 @@ fun AppVideoPlayer( ExoPlayer.Builder(context).build().apply { val mediaItem = MediaItem.fromUri(url) setMediaItem(mediaItem) + volume = if (isMuted) 0f else 1f prepare() playWhenReady = autoPlay addListener(object : Player.Listener { @@ -40,6 +42,10 @@ fun AppVideoPlayer( } } + LaunchedEffect(isMuted) { + exoPlayer.volume = if (isMuted) 0f else 1f + } + // Очистка ресурсов при выходе DisposableEffect(Unit) { onDispose { diff --git a/client-mobile/core/presentation/theme/Theme.kt b/client-mobile/core/presentation/theme/Theme.kt index d6664e7..d655276 100644 --- a/client-mobile/core/presentation/theme/Theme.kt +++ b/client-mobile/core/presentation/theme/Theme.kt @@ -25,7 +25,7 @@ private val DarkColors = darkColorScheme( onSurfaceVariant = OnSurfaceVariant ) -val SoftSquareShape = RoundedCornerShape(24.dp) // "Мягкий квадрат" +val SoftSquareShape = RoundedCornerShape(14.dp) // "Мягкий квадрат" как в вэб @Composable fun ForkMessengerTheme(content: @Composable () -> Unit) { diff --git a/client-mobile/gradle/wrapper/gradle-wrapper.jar b/client-mobile/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e644113 Binary files /dev/null and b/client-mobile/gradle/wrapper/gradle-wrapper.jar differ diff --git a/client-mobile/gradlew b/client-mobile/gradlew new file mode 100644 index 0000000..b740cf1 --- /dev/null +++ b/client-mobile/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/client-mobile/gradlew.bat b/client-mobile/gradlew.bat new file mode 100644 index 0000000..25da30d --- /dev/null +++ b/client-mobile/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega