diff --git a/core/resources/src/main/java/ru/tech/imageresizershrinker/core/resources/icons/StickerEmoji.kt b/core/resources/src/main/java/ru/tech/imageresizershrinker/core/resources/icons/StickerEmoji.kt new file mode 100644 index 000000000..ec8370292 --- /dev/null +++ b/core/resources/src/main/java/ru/tech/imageresizershrinker/core/resources/icons/StickerEmoji.kt @@ -0,0 +1,60 @@ +package ru.tech.imageresizershrinker.core.resources.icons + +import androidx.compose.material.icons.Icons +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.graphics.vector.path +import androidx.compose.ui.unit.dp + +val Icons.Outlined.StickerEmoji: ImageVector by lazy { + ImageVector.Builder( + name = "Outlined.StickerEmoji", + defaultWidth = 24.dp, + defaultHeight = 24.dp, + viewportWidth = 24f, + viewportHeight = 24f + ).apply { + path(fill = SolidColor(Color(0xFF000000))) { + moveTo(5.5f, 2f) + curveTo(3.56f, 2f, 2f, 3.56f, 2f, 5.5f) + verticalLineTo(18.5f) + curveTo(2f, 20.44f, 3.56f, 22f, 5.5f, 22f) + horizontalLineTo(16f) + lineTo(22f, 16f) + verticalLineTo(5.5f) + curveTo(22f, 3.56f, 20.44f, 2f, 18.5f, 2f) + horizontalLineTo(5.5f) + moveTo(5.75f, 4f) + horizontalLineTo(18.25f) + arcTo(1.75f, 1.75f, 0f, isMoreThanHalf = false, isPositiveArc = true, 20f, 5.75f) + verticalLineTo(15f) + horizontalLineTo(18.5f) + curveTo(16.56f, 15f, 15f, 16.56f, 15f, 18.5f) + verticalLineTo(20f) + horizontalLineTo(5.75f) + arcTo(1.75f, 1.75f, 0f, isMoreThanHalf = false, isPositiveArc = true, 4f, 18.25f) + verticalLineTo(5.75f) + arcTo(1.75f, 1.75f, 0f, isMoreThanHalf = false, isPositiveArc = true, 5.75f, 4f) + moveTo(14.44f, 6.77f) + curveTo(14.28f, 6.77f, 14.12f, 6.79f, 13.97f, 6.83f) + curveTo(13.03f, 7.09f, 12.5f, 8.05f, 12.74f, 9f) + curveTo(12.79f, 9.15f, 12.86f, 9.3f, 12.95f, 9.44f) + lineTo(16.18f, 8.56f) + curveTo(16.18f, 8.39f, 16.16f, 8.22f, 16.12f, 8.05f) + curveTo(15.91f, 7.3f, 15.22f, 6.77f, 14.44f, 6.77f) + moveTo(8.17f, 8.5f) + curveTo(8f, 8.5f, 7.85f, 8.5f, 7.7f, 8.55f) + curveTo(6.77f, 8.81f, 6.22f, 9.77f, 6.47f, 10.7f) + curveTo(6.5f, 10.86f, 6.59f, 11f, 6.68f, 11.16f) + lineTo(9.91f, 10.28f) + curveTo(9.91f, 10.11f, 9.89f, 9.94f, 9.85f, 9.78f) + curveTo(9.64f, 9f, 8.95f, 8.5f, 8.17f, 8.5f) + moveTo(16.72f, 11.26f) + lineTo(7.59f, 13.77f) + curveTo(8.91f, 15.3f, 11f, 15.94f, 12.95f, 15.41f) + curveTo(14.9f, 14.87f, 16.36f, 13.25f, 16.72f, 11.26f) + close() + } + }.build() +} diff --git a/core/resources/src/main/res/values/strings.xml b/core/resources/src/main/res/values/strings.xml index c9c128342..dfe851482 100644 --- a/core/resources/src/main/res/values/strings.xml +++ b/core/resources/src/main/res/values/strings.xml @@ -1563,4 +1563,5 @@ Edit EXIF Change metadata of single image without recompression Tap to edit available tags + Change Sticker \ No newline at end of file diff --git a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/image/Picture.kt b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/image/Picture.kt index 9159bb636..2a8409c7f 100644 --- a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/image/Picture.kt +++ b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/image/Picture.kt @@ -20,6 +20,8 @@ package ru.tech.imageresizershrinker.core.ui.widget.image import android.content.pm.ActivityInfo import android.graphics.Bitmap import android.os.Build +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.DisposableEffect @@ -89,7 +91,8 @@ fun Picture( allowHardware: Boolean = true, showTransparencyChecker: Boolean = true, isLoadingFromDifferentPlace: Boolean = false, - enableUltraHDRSupport: Boolean = false + enableUltraHDRSupport: Boolean = false, + contentPadding: PaddingValues = PaddingValues() ) { val context = LocalContext.current @@ -155,7 +158,8 @@ fun Picture( modifier = modifier .clip(shape) .then(if (showTransparencyChecker) Modifier.transparencyChecker() else Modifier) - .then(if (shimmerEnabled) Modifier.shimmer(shimmerVisible || isLoadingFromDifferentPlace) else Modifier), + .then(if (shimmerEnabled) Modifier.shimmer(shimmerVisible || isLoadingFromDifferentPlace) else Modifier) + .padding(contentPadding), contentScale = contentScale, loading = { if (loading != null) loading(it) diff --git a/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/presentation/components/additional/EmojiSelectionSheet.kt b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/sheets/EmojiSelectionSheet.kt similarity index 82% rename from feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/presentation/components/additional/EmojiSelectionSheet.kt rename to core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/sheets/EmojiSelectionSheet.kt index 5be9b37e1..ce6b25c27 100644 --- a/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/presentation/components/additional/EmojiSelectionSheet.kt +++ b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/sheets/EmojiSelectionSheet.kt @@ -1,6 +1,6 @@ /* * ImageToolbox is an image editor for android - * Copyright (c) 2024 T8RIN (Malik Mukhametzyanov) + * Copyright (c) 2025 T8RIN (Malik Mukhametzyanov) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package ru.tech.imageresizershrinker.feature.settings.presentation.components.additional +package ru.tech.imageresizershrinker.core.ui.widget.sheets import android.net.Uri import androidx.compose.animation.animateColorAsState @@ -67,6 +67,7 @@ import kotlinx.collections.immutable.ImmutableList import kotlinx.coroutines.delay import kotlinx.coroutines.launch import ru.tech.imageresizershrinker.core.resources.R +import ru.tech.imageresizershrinker.core.resources.emoji.Emoji import ru.tech.imageresizershrinker.core.resources.emoji.EmojiData import ru.tech.imageresizershrinker.core.ui.shapes.CloverShape import ru.tech.imageresizershrinker.core.ui.utils.provider.SafeLocalContainerColor @@ -85,9 +86,9 @@ import kotlin.random.Random @Composable fun EmojiSelectionSheet( - selectedEmojiIndex: Int, - emojiWithCategories: ImmutableList, - allEmojis: ImmutableList, + selectedEmojiIndex: Int?, + emojiWithCategories: ImmutableList = Emoji.allIconsCategorized(), + allEmojis: ImmutableList = Emoji.allIcons(), onEmojiPicked: (Int) -> Unit, visible: Boolean, onDismiss: () -> Unit @@ -96,7 +97,7 @@ fun EmojiSelectionSheet( LaunchedEffect(visible) { delay(600) - if (selectedEmojiIndex >= 0) { + if ((selectedEmojiIndex ?: -1) >= 0) { var count = 0 val item = emojiWithCategories.find { (_, _, emojis) -> count = 0 @@ -128,20 +129,22 @@ fun EmojiSelectionSheet( Row( verticalAlignment = Alignment.CenterVertically ) { - EnhancedIconButton( - containerColor = MaterialTheme.colorScheme.tertiaryContainer, - enabled = emojiEnabled, - onClick = { - onEmojiPicked(Random.nextInt(0, allEmojis.lastIndex)) - scope.launch { - state.animateScrollToItem(selectedEmojiIndex) - } - }, - ) { - Icon( - imageVector = Icons.Rounded.Shuffle, - contentDescription = stringResource(R.string.shuffle) - ) + if (selectedEmojiIndex != null) { + EnhancedIconButton( + containerColor = MaterialTheme.colorScheme.tertiaryContainer, + enabled = emojiEnabled, + onClick = { + onEmojiPicked(Random.nextInt(0, allEmojis.lastIndex)) + scope.launch { + state.animateScrollToItem(selectedEmojiIndex) + } + }, + ) { + Icon( + imageVector = Icons.Rounded.Shuffle, + contentDescription = stringResource(R.string.shuffle) + ) + } } EnhancedButton( containerColor = MaterialTheme.colorScheme.secondaryContainer, @@ -185,7 +188,7 @@ fun EmojiSelectionSheet( } var expandedCategories by rememberSaveable(visible) { mutableStateOf( - if (selectedEmojiIndex >= 0) { + if ((selectedEmojiIndex ?: -1) >= 0) { emojiWithCategories.find { (_, _, emojis) -> emojis.forEach { emoji -> val index = allEmojis.indexOf(emoji) @@ -323,38 +326,44 @@ fun EmojiSelectionSheet( } } - Column( - modifier = Modifier.onGloballyPositioned { - topPadding = with(density) { - it.size.height.toDp() + if (selectedEmojiIndex != null) { + Column( + modifier = Modifier.onGloballyPositioned { + topPadding = with(density) { + it.size.height.toDp() + } } + ) { + PreferenceRowSwitch( + title = stringResource(R.string.enable_emoji), + color = animateColorAsState( + if (emojiEnabled) MaterialTheme.colorScheme.primaryContainer + else MaterialTheme.colorScheme.surfaceContainer + ).value, + modifier = Modifier + .fillMaxWidth() + .background(EnhancedBottomSheetDefaults.containerColor) + .padding(start = 16.dp, top = 20.dp, bottom = 8.dp, end = 16.dp), + shape = RoundedCornerShape(28.dp), + checked = emojiEnabled, + startIcon = Icons.Outlined.Face6, + onClick = { + if (!emojiEnabled) onEmojiPicked(Random.nextInt(0, allEmojis.lastIndex)) + else onEmojiPicked(-1) + } + ) + GradientEdge( + modifier = Modifier + .fillMaxWidth() + .height(16.dp), + startColor = EnhancedBottomSheetDefaults.containerColor, + endColor = Color.Transparent + ) + } + } else { + LaunchedEffect(Unit) { + topPadding = 16.dp } - ) { - PreferenceRowSwitch( - title = stringResource(R.string.enable_emoji), - color = animateColorAsState( - if (emojiEnabled) MaterialTheme.colorScheme.primaryContainer - else MaterialTheme.colorScheme.surfaceContainer - ).value, - modifier = Modifier - .fillMaxWidth() - .background(EnhancedBottomSheetDefaults.containerColor) - .padding(start = 16.dp, top = 20.dp, bottom = 8.dp, end = 16.dp), - shape = RoundedCornerShape(28.dp), - checked = emojiEnabled, - startIcon = Icons.Outlined.Face6, - onClick = { - if (!emojiEnabled) onEmojiPicked(Random.nextInt(0, allEmojis.lastIndex)) - else onEmojiPicked(-1) - } - ) - GradientEdge( - modifier = Modifier - .fillMaxWidth() - .height(16.dp), - startColor = EnhancedBottomSheetDefaults.containerColor, - endColor = Color.Transparent - ) } } } diff --git a/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/domain/MarkupLayer.kt b/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/domain/MarkupLayer.kt index 3759b7692..ebcc5821b 100644 --- a/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/domain/MarkupLayer.kt +++ b/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/domain/MarkupLayer.kt @@ -97,9 +97,12 @@ sealed interface LayerType { } } - data class Image( - val imageData: Any + sealed class Picture( + open val imageData: Any ) : LayerType { + data class Image(override val imageData: Any) : Picture(imageData) + data class Sticker(override val imageData: Any) : Picture(imageData) + companion object { val Default by lazy { Image( diff --git a/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/EditLayerSheet.kt b/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/EditLayerSheet.kt index a21387a4b..80731822a 100644 --- a/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/EditLayerSheet.kt +++ b/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/EditLayerSheet.kt @@ -18,16 +18,23 @@ package ru.tech.imageresizershrinker.feature.markup_layers.presentation.components import androidx.compose.animation.AnimatedVisibility +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.AddPhotoAlternate import androidx.compose.material.icons.outlined.BorderColor import androidx.compose.material.icons.rounded.FormatColorFill import androidx.compose.material3.Icon @@ -38,8 +45,10 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.res.stringResource @@ -49,8 +58,11 @@ import com.smarttoolfactory.colordetector.util.ColorUtil.roundToTwoDigits import ru.tech.imageresizershrinker.core.domain.model.Outline import ru.tech.imageresizershrinker.core.domain.utils.ListUtils.toggle import ru.tech.imageresizershrinker.core.resources.R +import ru.tech.imageresizershrinker.core.resources.emoji.Emoji +import ru.tech.imageresizershrinker.core.resources.icons.MiniEdit import ru.tech.imageresizershrinker.core.resources.icons.MiniEditLarge import ru.tech.imageresizershrinker.core.settings.presentation.model.toUiFont +import ru.tech.imageresizershrinker.core.ui.shapes.MaterialStarShape import ru.tech.imageresizershrinker.core.ui.theme.inverseByLuma import ru.tech.imageresizershrinker.core.ui.theme.takeColorFromScheme import ru.tech.imageresizershrinker.core.ui.theme.toColor @@ -62,9 +74,12 @@ import ru.tech.imageresizershrinker.core.ui.widget.enhanced.EnhancedButton import ru.tech.imageresizershrinker.core.ui.widget.enhanced.EnhancedIconButton import ru.tech.imageresizershrinker.core.ui.widget.enhanced.EnhancedModalBottomSheet import ru.tech.imageresizershrinker.core.ui.widget.enhanced.EnhancedSliderItem +import ru.tech.imageresizershrinker.core.ui.widget.image.Picture import ru.tech.imageresizershrinker.core.ui.widget.modifier.ContainerShapeDefaults import ru.tech.imageresizershrinker.core.ui.widget.modifier.container +import ru.tech.imageresizershrinker.core.ui.widget.preferences.PreferenceItemOverload import ru.tech.imageresizershrinker.core.ui.widget.preferences.PreferenceRowSwitch +import ru.tech.imageresizershrinker.core.ui.widget.sheets.EmojiSelectionSheet import ru.tech.imageresizershrinker.core.ui.widget.text.RoundedTextField import ru.tech.imageresizershrinker.core.ui.widget.text.RoundedTextFieldColors import ru.tech.imageresizershrinker.core.ui.widget.text.TitleItem @@ -85,7 +100,7 @@ internal fun EditLayerSheet( onDismiss = onDismiss, title = { when (val type = layer.type) { - is LayerType.Image -> { + is LayerType.Picture -> { TitleItem( icon = Icons.Rounded.MiniEditLarge, text = stringResource(R.string.edit_layer) @@ -138,7 +153,7 @@ internal fun EditLayerSheet( .padding(16.dp) ) { when (val type = layer.type) { - is LayerType.Image -> { + is LayerType.Picture.Image -> { ImageSelector( value = type.imageData, onValueChange = { @@ -325,6 +340,68 @@ internal fun EditLayerSheet( } ) } + + is LayerType.Picture.Sticker -> { + var showEmojiPicker by rememberSaveable { + mutableStateOf(false) + } + + PreferenceItemOverload( + title = stringResource(R.string.change_sticker), + subtitle = null, + onClick = { + showEmojiPicker = true + }, + startIcon = { + Picture( + model = type.imageData, + contentPadding = PaddingValues(8.dp), + shape = MaterialStarShape, + modifier = Modifier.size(48.dp), + error = { + Icon( + imageVector = Icons.Outlined.AddPhotoAlternate, + contentDescription = null, + modifier = Modifier + .fillMaxSize() + .clip(MaterialStarShape) + .background( + color = MaterialTheme.colorScheme.secondaryContainer.copy( + 0.5f + ) + ) + .padding(8.dp) + ) + } + ) + }, + endIcon = { + Icon( + imageVector = Icons.Rounded.MiniEdit, + contentDescription = stringResource(R.string.edit) + ) + }, + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(20.dp), + color = Color.Unspecified, + drawStartIconContainer = false + ) + + val allEmojis = Emoji.allIcons() + + EmojiSelectionSheet( + selectedEmojiIndex = null, + allEmojis = allEmojis, + onEmojiPicked = { + onUpdateLayer(layer.copy(type.copy(allEmojis[it]))) + showEmojiPicker = false + }, + visible = showEmojiPicker, + onDismiss = { + showEmojiPicker = false + } + ) + } } } } diff --git a/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/LayerContent.kt b/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/LayerContent.kt index 943d59a18..bc5328a68 100644 --- a/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/LayerContent.kt +++ b/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/LayerContent.kt @@ -53,7 +53,7 @@ internal fun LayerContent( textFullSize: Int ) { when (type) { - is LayerType.Image -> { + is LayerType.Picture -> { Picture( model = ImageRequest.Builder(LocalContext.current) .data(type.imageData) diff --git a/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/MarkupLayersActions.kt b/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/MarkupLayersActions.kt index ccffbe21c..b5dfa57a7 100644 --- a/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/MarkupLayersActions.kt +++ b/feature/markup-layers/src/main/java/ru/tech/imageresizershrinker/feature/markup_layers/presentation/components/MarkupLayersActions.kt @@ -18,8 +18,10 @@ package ru.tech.imageresizershrinker.feature.markup_layers.presentation.components import android.net.Uri -import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.rounded.Redo @@ -31,14 +33,20 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.* import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import ru.tech.imageresizershrinker.core.resources.emoji.Emoji import ru.tech.imageresizershrinker.core.resources.icons.Stacks +import ru.tech.imageresizershrinker.core.resources.icons.StickerEmoji import ru.tech.imageresizershrinker.core.ui.theme.takeColorFromScheme import ru.tech.imageresizershrinker.core.ui.utils.content_pickers.rememberImagePicker import ru.tech.imageresizershrinker.core.ui.utils.helper.isPortraitOrientationAsState import ru.tech.imageresizershrinker.core.ui.widget.enhanced.EnhancedIconButton import ru.tech.imageresizershrinker.core.ui.widget.modifier.container +import ru.tech.imageresizershrinker.core.ui.widget.modifier.fadingEdges +import ru.tech.imageresizershrinker.core.ui.widget.sheets.EmojiSelectionSheet import ru.tech.imageresizershrinker.feature.markup_layers.domain.LayerType import ru.tech.imageresizershrinker.feature.markup_layers.presentation.components.model.UiMarkupLayer import ru.tech.imageresizershrinker.feature.markup_layers.presentation.screenLogic.MarkupLayersComponent @@ -54,15 +62,25 @@ internal fun MarkupLayersActions( component.deactivateAllLayers() component.addLayer( UiMarkupLayer( - type = LayerType.Image(uri) + type = LayerType.Picture.Image(uri) ) ) } var showTextEnteringDialog by rememberSaveable { mutableStateOf(false) } + var showEmojiPicker by rememberSaveable { + mutableStateOf(false) + } - Box { + val state = rememberScrollState() + Row( + modifier = Modifier + .fadingEdges(state) + .horizontalScroll(state) + .padding(vertical = 2.dp), + verticalAlignment = Alignment.CenterVertically + ) { EnhancedIconButton( containerColor = takeColorFromScheme { if (showLayersSelection) tertiary @@ -77,34 +95,64 @@ internal fun MarkupLayersActions( contentDescription = null ) } - } - EnhancedIconButton( - onClick = { - showTextEnteringDialog = true + EnhancedIconButton( + onClick = { + showTextEnteringDialog = true + } + ) { + Icon( + imageVector = Icons.Rounded.TextFields, + contentDescription = null + ) + } + EnhancedIconButton( + onClick = { + showEmojiPicker = true + } + ) { + Icon( + imageVector = Icons.Outlined.StickerEmoji, + contentDescription = null + ) + } + EnhancedIconButton( + onClick = layerImagePicker::pickImage + ) { + Icon( + imageVector = Icons.Outlined.Image, + contentDescription = null + ) } - ) { - Icon( - imageVector = Icons.Rounded.TextFields, - contentDescription = null - ) - } - EnhancedIconButton( - onClick = layerImagePicker::pickImage - ) { - Icon( - imageVector = Icons.Outlined.Image, - contentDescription = null - ) - } - val isPortrait by isPortraitOrientationAsState() - if (isPortrait) { - MarkupLayersUndoRedo( - component = component, - color = MaterialTheme.colorScheme.surface - ) + val isPortrait by isPortraitOrientationAsState() + if (isPortrait) { + MarkupLayersUndoRedo( + component = component, + color = MaterialTheme.colorScheme.surface + ) + } } + val allEmojis = Emoji.allIcons() + + EmojiSelectionSheet( + selectedEmojiIndex = null, + allEmojis = allEmojis, + onEmojiPicked = { + component.deactivateAllLayers() + component.addLayer( + UiMarkupLayer( + type = LayerType.Picture.Sticker(allEmojis[it]) + ) + ) + showEmojiPicker = false + }, + visible = showEmojiPicker, + onDismiss = { + showEmojiPicker = false + } + ) + AddTextLayerDialog( visible = showTextEnteringDialog, onDismiss = { showTextEnteringDialog = false }, diff --git a/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/presentation/components/EmojiSettingItem.kt b/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/presentation/components/EmojiSettingItem.kt index 1e9427dba..b9ddd9511 100644 --- a/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/presentation/components/EmojiSettingItem.kt +++ b/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/presentation/components/EmojiSettingItem.kt @@ -40,7 +40,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import kotlinx.coroutines.launch import ru.tech.imageresizershrinker.core.resources.R -import ru.tech.imageresizershrinker.core.resources.emoji.Emoji import ru.tech.imageresizershrinker.core.resources.icons.Cool import ru.tech.imageresizershrinker.core.resources.icons.Robot import ru.tech.imageresizershrinker.core.settings.presentation.provider.LocalSettingsState @@ -54,7 +53,7 @@ import ru.tech.imageresizershrinker.core.ui.widget.modifier.scaleOnTap import ru.tech.imageresizershrinker.core.ui.widget.other.EmojiItem import ru.tech.imageresizershrinker.core.ui.widget.other.LocalToastHostState import ru.tech.imageresizershrinker.core.ui.widget.preferences.PreferenceRow -import ru.tech.imageresizershrinker.feature.settings.presentation.components.additional.EmojiSelectionSheet +import ru.tech.imageresizershrinker.core.ui.widget.sheets.EmojiSelectionSheet @Composable fun EmojiSettingItem( @@ -140,8 +139,6 @@ fun EmojiSettingItem( ) EmojiSelectionSheet( selectedEmojiIndex = selectedEmojiIndex, - emojiWithCategories = Emoji.allIconsCategorized(), - allEmojis = Emoji.allIcons(), onEmojiPicked = onUpdateEmoji, visible = showEmojiDialog, onDismiss = {