From d78fb184c6299964217bc020131729c815bc2a36 Mon Sep 17 00:00:00 2001 From: k1ngsterr1 Date: Sat, 14 Mar 2026 15:10:46 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BA=D1=80=D1=8B=D1=82=20=D0=B8=D0=BD?= =?UTF-8?q?=D0=BF=D1=83=D1=82=20=D0=B8=20=D0=BE=D0=B2=D0=B5=D1=80=D0=BB?= =?UTF-8?q?=D0=B5=D0=B8=20=D0=BF=D1=80=D0=B8=20=D1=80=D0=B8=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=BD=D0=B0=20=D1=84=D0=BE?= =?UTF-8?q?=D1=82=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/SimpleFullscreenPhotoViewer.kt | 276 ++++++++++-------- 1 file changed, 148 insertions(+), 128 deletions(-) diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/components/SimpleFullscreenPhotoViewer.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/components/SimpleFullscreenPhotoViewer.kt index 599b2d2..9d41ba9 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/components/SimpleFullscreenPhotoViewer.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/components/SimpleFullscreenPhotoViewer.kt @@ -343,6 +343,7 @@ private fun SimpleFullscreenPhotoContent( localCaption = value } } + val isDrawingModeActive = currentTool == EditorTool.DRAW LaunchedEffect(imageUri, sourceThumbnail) { localCaption = caption @@ -394,6 +395,15 @@ private fun SimpleFullscreenPhotoContent( } } + LaunchedEffect(isDrawingModeActive) { + if (isDrawingModeActive) { + showEmojiPicker = false + val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(view.windowToken, 0) + focusManager.clearFocus(force = true) + } + } + fun hideKeyboard() { val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager imm.hideSoftInputFromWindow(view.windowToken, 0) @@ -851,16 +861,18 @@ private fun SimpleFullscreenPhotoContent( .statusBarsPadding() .padding(horizontal = 4.dp, vertical = 8.dp) ) { - IconButton( - onClick = { closeViewer() }, - modifier = Modifier.align(Alignment.CenterStart) - ) { - Icon( - painter = TelegramIcons.Close, - contentDescription = "Close", - tint = Color.White, - modifier = Modifier.size(28.dp) - ) + if (!isDrawingModeActive) { + IconButton( + onClick = { closeViewer() }, + modifier = Modifier.align(Alignment.CenterStart) + ) { + Icon( + painter = TelegramIcons.Close, + contentDescription = "Close", + tint = Color.White, + modifier = Modifier.size(28.dp) + ) + } } } @@ -990,136 +1002,144 @@ private fun SimpleFullscreenPhotoContent( } } - Box( - modifier = - Modifier.fillMaxWidth() - .background(Color.Black.copy(alpha = 0.75f)) - .padding( - start = 12.dp, - end = 12.dp, - top = 10.dp, - bottom = - if (isKeyboardVisible || coordinator.isEmojiBoxVisible) 10.dp - else 16.dp - ) - .then( - if (shouldAddNavBarPadding) Modifier.navigationBarsPadding() - else Modifier - ) + AnimatedVisibility( + visible = !isDrawingModeActive, + enter = fadeIn() + slideInVertically { it / 2 }, + exit = fadeOut() + slideOutVertically { it / 2 } ) { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(10.dp) + Box( + modifier = + Modifier.fillMaxWidth() + .background(Color.Black.copy(alpha = 0.75f)) + .padding( + start = 12.dp, + end = 12.dp, + top = 10.dp, + bottom = + if (isKeyboardVisible || coordinator.isEmojiBoxVisible) 10.dp + else 16.dp + ) + .then( + if (shouldAddNavBarPadding) Modifier.navigationBarsPadding() + else Modifier + ) ) { - IconButton( - onClick = { toggleEmojiPicker() }, - modifier = Modifier.size(32.dp) + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(10.dp) ) { - Crossfade( - targetState = showEmojiPicker, - animationSpec = tween(150), - label = "simpleViewerEmojiToggle" - ) { isEmoji -> - Icon( - painter = if (isEmoji) TelegramIcons.Keyboard else TelegramIcons.Smile, - contentDescription = if (isEmoji) "Keyboard" else "Emoji", - tint = Color.White.copy(alpha = 0.72f), - modifier = Modifier.size(26.dp) + IconButton( + onClick = { toggleEmojiPicker() }, + modifier = Modifier.size(32.dp) + ) { + Crossfade( + targetState = showEmojiPicker, + animationSpec = tween(150), + label = "simpleViewerEmojiToggle" + ) { isEmoji -> + Icon( + painter = if (isEmoji) TelegramIcons.Keyboard else TelegramIcons.Smile, + contentDescription = if (isEmoji) "Keyboard" else "Emoji", + tint = Color.White.copy(alpha = 0.72f), + modifier = Modifier.size(26.dp) + ) + } + } + + Box( + modifier = + Modifier.weight(1f) + .heightIn(min = 24.dp, max = 100.dp) + ) { + AppleEmojiTextField( + value = captionText, + onValueChange = updateCaption, + textColor = Color.White, + textSize = 16f, + hint = "Add a caption...", + hintColor = Color.White.copy(alpha = 0.5f), + modifier = Modifier.fillMaxWidth(), + requestFocus = false, + onViewCreated = { textView -> editTextView = textView }, + onFocusChanged = { hasFocus -> + if (hasFocus && showEmojiPicker) { + toggleEmojiPicker() + } + } ) } - } - Box( - modifier = - Modifier.weight(1f) - .heightIn(min = 24.dp, max = 100.dp) - ) { - AppleEmojiTextField( - value = captionText, - onValueChange = updateCaption, - textColor = Color.White, - textSize = 16f, - hint = "Add a caption...", - hintColor = Color.White.copy(alpha = 0.5f), - modifier = Modifier.fillMaxWidth(), - requestFocus = false, - onViewCreated = { textView -> editTextView = textView }, - onFocusChanged = { hasFocus -> - if (hasFocus && showEmojiPicker) { - toggleEmojiPicker() - } - } - ) - } - - Box( - modifier = - Modifier.size(44.dp) - .shadow( - elevation = 4.dp, - shape = CircleShape, - clip = false - ) - .clip(CircleShape) - .background(PrimaryBlue) - .clickable(enabled = !isSaving) { - if (isSaving || isClosing) return@clickable - showEmojiPicker = false - hideKeyboard() - focusManager.clearFocus(force = true) - scope.launch { - isSaving = true - val savedUri = - saveEditedImageSync( - context = context, - photoEditor = photoEditor, - photoEditorView = photoEditorView, - imageUri = currentImageUri, - hasDrawingEdits = hasDrawingEdits - ) - isSaving = false - val finalUri = savedUri ?: currentImageUri - if (onSend != null) { - onSend(finalUri, captionText) - } else { - closeViewer() + Box( + modifier = + Modifier.size(44.dp) + .shadow( + elevation = 4.dp, + shape = CircleShape, + clip = false + ) + .clip(CircleShape) + .background(PrimaryBlue) + .clickable(enabled = !isSaving) { + if (isSaving || isClosing) return@clickable + showEmojiPicker = false + hideKeyboard() + focusManager.clearFocus(force = true) + scope.launch { + isSaving = true + val savedUri = + saveEditedImageSync( + context = context, + photoEditor = photoEditor, + photoEditorView = photoEditorView, + imageUri = currentImageUri, + hasDrawingEdits = hasDrawingEdits + ) + isSaving = false + val finalUri = savedUri ?: currentImageUri + if (onSend != null) { + onSend(finalUri, captionText) + } else { + closeViewer() + } } - } - }, - contentAlignment = Alignment.Center - ) { - if (isSaving) { - CircularProgressIndicator( - modifier = Modifier.size(18.dp), - color = Color.White, - strokeWidth = 2.dp - ) - } else { - Icon( - painter = TelegramIcons.Send, - contentDescription = "Send", - tint = Color.White, - modifier = - Modifier.size(24.dp) - .offset(x = 1.dp) - ) + }, + contentAlignment = Alignment.Center + ) { + if (isSaving) { + CircularProgressIndicator( + modifier = Modifier.size(18.dp), + color = Color.White, + strokeWidth = 2.dp + ) + } else { + Icon( + painter = TelegramIcons.Send, + contentDescription = "Send", + tint = Color.White, + modifier = + Modifier.size(24.dp) + .offset(x = 1.dp) + ) + } } } } } - AnimatedKeyboardTransition( - coordinator = coordinator, - showEmojiPicker = showEmojiPicker - ) { - OptimizedEmojiPicker( - isVisible = true, - isDarkTheme = isDarkTheme, - onEmojiSelected = { emoji -> updateCaption(captionText + emoji) }, - onClose = { toggleEmojiPicker() }, - modifier = Modifier.fillMaxWidth() - ) + if (!isDrawingModeActive) { + AnimatedKeyboardTransition( + coordinator = coordinator, + showEmojiPicker = showEmojiPicker + ) { + OptimizedEmojiPicker( + isVisible = true, + isDarkTheme = isDarkTheme, + onEmojiSelected = { emoji -> updateCaption(captionText + emoji) }, + onClose = { toggleEmojiPicker() }, + modifier = Modifier.fillMaxWidth() + ) + } } } }