From 86ff95eff9c4fba433a7179d0e0aa87f32a3d8d5 Mon Sep 17 00:00:00 2001 From: Diego Beraldin Date: Wed, 25 Oct 2023 00:00:11 +0200 Subject: [PATCH] fix: click input in post title and body (#67) --- .../communitydetail/CommunityDetailScreen.kt | 61 ++++++++++--------- .../core/commonui/components/InboxCard.kt | 3 + .../core/commonui/components/PostCard.kt | 11 +++- .../core/commonui/components/PostCardBody.kt | 2 + .../core/commonui/components/PostCardTitle.kt | 4 +- .../commonui/postdetail/PostDetailScreen.kt | 30 ++++----- .../commonui/saveditems/SavedItemsScreen.kt | 10 +-- .../commonui/userdetail/UserDetailScreen.kt | 12 ++-- .../core/markdown/compose/CustomMarkdown.kt | 13 +++- .../compose/DefaultMarkwonProvider.kt | 3 +- .../core/markdown/compose/CustomMarkdown.kt | 1 + .../core/markdown/compose/CustomMarkdown.kt | 4 +- .../feature/home/postlist/PostListScreen.kt | 31 +++++----- .../profile/logged/ProfileLoggedScreen.kt | 18 +++--- .../feature/search/main/ExploreScreen.kt | 10 +-- .../detail/MultiCommunityScreen.kt | 22 +++---- 16 files changed, 131 insertions(+), 104 deletions(-) diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/communitydetail/CommunityDetailScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/communitydetail/CommunityDetailScreen.kt index 86fdd4f9d..7d431196a 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/communitydetail/CommunityDetailScreen.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/communitydetail/CommunityDetailScreen.kt @@ -399,19 +399,29 @@ class CommunityDetailScreen( ) }, content = { - PostCard(modifier = Modifier.onClick { - model.reduce( - CommunityDetailMviModel.Intent.MarkAsRead( - idx + PostCard( + post = post, + postLayout = uiState.postLayout, + fullHeightImage = uiState.fullHeightImages, + separateUpAndDownVotes = uiState.separateUpAndDownVotes, + autoLoadImages = uiState.autoLoadImages, + blurNsfw = when { + stateCommunity.nsfw -> false + else -> uiState.blurNsfw + }, + onClick = { + model.reduce( + CommunityDetailMviModel.Intent.MarkAsRead( + idx + ) ) - ) - navigator?.push( - PostDetailScreen( - post = post, - otherInstance = otherInstance, - ), - ) - }, + navigator?.push( + PostDetailScreen( + post = post, + otherInstance = otherInstance, + ), + ) + }, onOpenCreator = { user -> navigator?.push( UserDetailScreen( @@ -420,24 +430,6 @@ class CommunityDetailScreen( ), ) }, - post = post, - postLayout = uiState.postLayout, - fullHeightImage = uiState.fullHeightImages, - separateUpAndDownVotes = uiState.separateUpAndDownVotes, - autoLoadImages = uiState.autoLoadImages, - options = buildList { - add(stringResource(MR.strings.post_action_share)) - add(stringResource(MR.strings.post_action_hide)) - add(stringResource(MR.strings.post_action_report)) - if (post.creator?.id == uiState.currentUserId && !isOnOtherInstance) { - add(stringResource(MR.strings.post_action_edit)) - add(stringResource(MR.strings.comment_action_delete)) - } - }, - blurNsfw = when { - stateCommunity.nsfw -> false - else -> uiState.blurNsfw - }, onUpVote = { if (!isOnOtherInstance) { model.reduce( @@ -493,6 +485,15 @@ class CommunityDetailScreen( ZoomableImageScreen(url), ) }, + options = buildList { + add(stringResource(MR.strings.post_action_share)) + add(stringResource(MR.strings.post_action_hide)) + add(stringResource(MR.strings.post_action_report)) + if (post.creator?.id == uiState.currentUserId && !isOnOtherInstance) { + add(stringResource(MR.strings.post_action_edit)) + add(stringResource(MR.strings.comment_action_delete)) + } + }, onOptionSelected = { optionIdx -> when (optionIdx) { 4 -> model.reduce( diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/InboxCard.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/InboxCard.kt index 67f9a1aab..0133a1830 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/InboxCard.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/InboxCard.kt @@ -68,6 +68,9 @@ fun InboxCard( ), text = mention.comment.text, autoLoadImages = autoLoadImages, + onClick = { + onOpenPost(mention.post) + } ) } InboxReplySubtitle( diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt index e14d988c0..bd3f30db7 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt @@ -32,6 +32,7 @@ import androidx.compose.ui.unit.toSize import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.PostLayout import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.CornerSize import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing +import com.github.diegoberaldin.raccoonforlemmy.core.utils.onClick import com.github.diegoberaldin.raccoonforlemmy.core.utils.toLocalPixel import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommunityModel import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.PostModel @@ -58,6 +59,7 @@ fun PostCard( onReply: (() -> Unit)? = null, onImageClick: ((String) -> Unit)? = null, onOptionSelected: ((Int) -> Unit)? = null, + onClick: (() -> Unit)? = null, ) { Box( modifier = modifier.let { @@ -69,7 +71,7 @@ fun PostCard( } else { it } - }, + }.onClick { onClick?.invoke() }, ) { if (postLayout != PostLayout.Compact) { ExtendedPost( @@ -95,6 +97,7 @@ fun PostCard( onReply = onReply, onImageClick = onImageClick, onOptionSelected = onOptionSelected, + onClick = onClick, ) } else { CompactPost( @@ -112,6 +115,7 @@ fun PostCard( onReply = onReply, onImageClick = onImageClick, onOptionSelected = onOptionSelected, + onClick = onClick, ) } } @@ -134,6 +138,7 @@ private fun CompactPost( onReply: (() -> Unit)? = null, onImageClick: ((String) -> Unit)? = null, onOptionSelected: ((Int) -> Unit)? = null, + onClick: (() -> Unit)? = null, ) { Column( modifier = modifier.background(MaterialTheme.colorScheme.background), @@ -156,6 +161,7 @@ private fun CompactPost( modifier = Modifier.weight(0.75f), text = post.title, autoLoadImages = autoLoadImages, + onClick = onClick, ) } PostCardImage( @@ -215,6 +221,7 @@ private fun ExtendedPost( onReply: (() -> Unit)? = null, onImageClick: ((String) -> Unit)? = null, onOptionSelected: ((Int) -> Unit)? = null, + onClick: (() -> Unit)? = null, ) { Column( modifier = modifier.background(backgroundColor), @@ -236,6 +243,7 @@ private fun ExtendedPost( ), text = post.title, autoLoadImages = autoLoadImages, + onClick = onClick, ) } @@ -276,6 +284,7 @@ private fun ExtendedPost( }, text = post.text, autoLoadImages = autoLoadImages, + onClick = onClick, ) if (limitBodyHeight && textHeightPx >= maxHeightPx) { Box( diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardBody.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardBody.kt index 742e10230..a25de86ba 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardBody.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardBody.kt @@ -14,6 +14,7 @@ fun PostCardBody( modifier: Modifier = Modifier, text: String, autoLoadImages: Boolean = true, + onClick: (() -> Unit)? = null, ) { val uriHandler = LocalUriHandler.current val navigator = remember { getNavigationCoordinator().getRootNavigator() } @@ -36,6 +37,7 @@ fun PostCardBody( onOpenImage = { url -> navigator?.push(ZoomableImageScreen(url)) }, + onClick = onClick, ) } } diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardTitle.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardTitle.kt index 66d8243db..9c4c26437 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardTitle.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardTitle.kt @@ -13,6 +13,7 @@ fun PostCardTitle( text: String, autoLoadImages: Boolean = true, modifier: Modifier = Modifier, + onClick: (() -> Unit)? = null, ) { val uriHandler = LocalUriHandler.current val navigator = remember { getNavigationCoordinator().getRootNavigator() } @@ -29,6 +30,7 @@ fun PostCardTitle( uriHandler = uriHandler, navigator = navigator ) - } + }, + onClick = onClick, ) } diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt index 152726743..407f935f3 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt @@ -307,14 +307,6 @@ class PostDetailScreen( UserDetailScreen(user = user) ) }, - options = buildList { - add(stringResource(MR.strings.post_action_share)) - add(stringResource(MR.strings.post_action_report)) - if (statePost.creator?.id == uiState.currentUserId && !isOnOtherInstance) { - add(stringResource(MR.strings.post_action_edit)) - add(stringResource(MR.strings.comment_action_delete)) - } - }, onUpVote = { if (!isOnOtherInstance) { model.reduce( @@ -353,6 +345,14 @@ class PostDetailScreen( bottomSheetNavigator.show(screen) } }, + options = buildList { + add(stringResource(MR.strings.post_action_share)) + add(stringResource(MR.strings.post_action_report)) + if (statePost.creator?.id == uiState.currentUserId && !isOnOtherInstance) { + add(stringResource(MR.strings.post_action_edit)) + add(stringResource(MR.strings.comment_action_delete)) + } + }, onOptionSelected = { idx -> when (idx) { 3 -> model.reduce(PostDetailMviModel.Intent.DeletePost) @@ -513,13 +513,6 @@ class PostDetailScreen( comment = comment, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages, - options = buildList { - add(stringResource(MR.strings.post_action_report)) - if (comment.creator?.id == uiState.currentUserId) { - add(stringResource(MR.strings.post_action_edit)) - add(stringResource(MR.strings.comment_action_delete)) - } - }, onUpVote = { if (!isOnOtherInstance) { model.reduce( @@ -589,6 +582,13 @@ class PostDetailScreen( ) } }, + options = buildList { + add(stringResource(MR.strings.post_action_report)) + if (comment.creator?.id == uiState.currentUserId) { + add(stringResource(MR.strings.post_action_edit)) + add(stringResource(MR.strings.comment_action_delete)) + } + }, onOptionSelected = { optionId -> when (optionId) { 2 -> model.reduce( diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/saveditems/SavedItemsScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/saveditems/SavedItemsScreen.kt index 043da4627..e6a7eb6ac 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/saveditems/SavedItemsScreen.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/saveditems/SavedItemsScreen.kt @@ -223,17 +223,17 @@ class SavedItemsScreen : Screen { if (uiState.section == SavedItemsSection.Posts) { itemsIndexed(uiState.posts) { idx, post -> PostCard( - modifier = Modifier.onClick { - navigator?.push( - PostDetailScreen(post), - ) - }, post = post, postLayout = uiState.postLayout, fullHeightImage = uiState.fullHeightImages, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages, blurNsfw = uiState.blurNsfw, + onClick = { + navigator?.push( + PostDetailScreen(post), + ) + }, onOpenCommunity = { community -> navigator?.push( CommunityDetailScreen(community), diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/userdetail/UserDetailScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/userdetail/UserDetailScreen.kt index c22c5e23e..0369e0727 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/userdetail/UserDetailScreen.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/userdetail/UserDetailScreen.kt @@ -379,9 +379,6 @@ class UserDetailScreen( }, content = { PostCard( - modifier = Modifier.onClick { - navigator?.push(PostDetailScreen(post = post)) - }, post = post, hideAuthor = true, postLayout = uiState.postLayout, @@ -389,9 +386,8 @@ class UserDetailScreen( blurNsfw = uiState.blurNsfw, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages, - options = buildList { - add(stringResource(MR.strings.post_action_share)) - add(stringResource(MR.strings.post_action_report)) + onClick = { + navigator?.push(PostDetailScreen(post = post)) }, onUpVote = if (isOnOtherInstance) { null @@ -454,6 +450,10 @@ class UserDetailScreen( ZoomableImageScreen(url), ) }, + options = buildList { + add(stringResource(MR.strings.post_action_share)) + add(stringResource(MR.strings.post_action_report)) + }, onOptionSelected = { optionIdx -> when (optionIdx) { 1 -> { diff --git a/core-md/src/androidMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt b/core-md/src/androidMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt index 5b1aacd66..ea8af985e 100755 --- a/core-md/src/androidMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt +++ b/core-md/src/androidMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt @@ -6,6 +6,7 @@ import android.util.TypedValue import android.view.View import android.widget.TextView import androidx.annotation.IdRes +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider @@ -47,6 +48,7 @@ actual fun CustomMarkdown( inlineImages: Boolean, autoLoadImages: Boolean, onOpenImage: ((String) -> Unit)?, + onClick: (() -> Unit)?, ) { CompositionLocalProvider( LocalReferenceLinkHandler provides ReferenceLinkHandlerImpl(), @@ -58,7 +60,9 @@ actual fun CustomMarkdown( onOpenUrl = onOpenUrl, onOpenImage = onOpenImage, ) - BoxWithConstraints { + BoxWithConstraints( + modifier = modifier.clickable { onClick?.invoke() } + ) { val style = LocalMarkdownTypography.current.text val fontScale = LocalDensity.current.fontScale * 1.25f val canvasWidthMaybe = with(LocalDensity.current) { maxWidth.toPx() }.toInt() @@ -82,7 +86,11 @@ actual fun CustomMarkdown( style = style, typeface = typeface, fontSize = style.fontSize * fontScale, - ) + ).apply { + setOnClickListener { + onClick?.invoke() + } + } }, update = { textView -> val md = markwonProvider.markwon.toMarkdown(content) @@ -91,7 +99,6 @@ actual fun CustomMarkdown( } markwonProvider.markwon.setParsedMarkdown(textView, md) }, - modifier = modifier, ) } } diff --git a/core-md/src/androidMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/DefaultMarkwonProvider.kt b/core-md/src/androidMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/DefaultMarkwonProvider.kt index e41b5fac3..ee70e954b 100644 --- a/core-md/src/androidMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/DefaultMarkwonProvider.kt +++ b/core-md/src/androidMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/DefaultMarkwonProvider.kt @@ -38,6 +38,7 @@ class DefaultMarkwonProvider( } } } - ).build() + ) + .build() } } \ No newline at end of file diff --git a/core-md/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt b/core-md/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt index 20c88c0d8..516bb3719 100755 --- a/core-md/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt +++ b/core-md/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt @@ -37,4 +37,5 @@ expect fun CustomMarkdown( inlineImages: Boolean = true, autoLoadImages: Boolean = true, onOpenImage: ((String) -> Unit)? = null, + onClick: (() -> Unit)? = null, ) \ No newline at end of file diff --git a/core-md/src/iosMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt b/core-md/src/iosMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt index b2a5584b8..6c7aa0fe4 100755 --- a/core-md/src/iosMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt +++ b/core-md/src/iosMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/markdown/compose/CustomMarkdown.kt @@ -1,5 +1,6 @@ package com.github.diegoberaldin.raccoonforlemmy.core.markdown.compose +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height @@ -58,6 +59,7 @@ actual fun CustomMarkdown( inlineImages: Boolean, autoLoadImages: Boolean, onOpenImage: ((String) -> Unit)?, + onClick: (() -> Unit)?, ) { val matches = Regex("::: spoiler (?.*?)\\n(?<content>.*?)\\n:::\\n").findAll(content) val mangledContent = buildString { @@ -93,7 +95,7 @@ actual fun CustomMarkdown( LocalMarkdownColors provides colors, LocalMarkdownTypography provides typography, ) { - Column(modifier) { + Column(modifier.clickable { onClick?.invoke() }) { val parsedTree = MarkdownParser(flavour).buildMarkdownTreeFromString(mangledContent) parsedTree.children.forEach { node -> if (!node.handleElement( diff --git a/feature-home/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/home/postlist/PostListScreen.kt b/feature-home/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/home/postlist/PostListScreen.kt index 932339c0b..39f9e3310 100644 --- a/feature-home/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/home/postlist/PostListScreen.kt +++ b/feature-home/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/home/postlist/PostListScreen.kt @@ -75,7 +75,6 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.report.CreateRepor import com.github.diegoberaldin.raccoonforlemmy.core.commonui.userdetail.UserDetailScreen import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenterContractKeys import com.github.diegoberaldin.raccoonforlemmy.core.notifications.di.getNotificationCenter -import com.github.diegoberaldin.raccoonforlemmy.core.utils.onClick import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.ListingType import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.SortType import com.github.diegoberaldin.raccoonforlemmy.feature.home.di.getHomeScreenModel @@ -293,27 +292,18 @@ class PostListScreen : Screen { }, content = { PostCard( - modifier = Modifier.onClick { - model.reduce(PostListMviModel.Intent.MarkAsRead(idx)) - navigator?.push( - PostDetailScreen(post), - ) - }, post = post, postLayout = uiState.postLayout, fullHeightImage = uiState.fullHeightImages, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages, - options = buildList { - add(stringResource(MR.strings.post_action_share)) - add(stringResource(MR.strings.post_action_hide)) - add(stringResource(MR.strings.post_action_report)) - if (post.creator?.id == uiState.currentUserId) { - add(stringResource(MR.strings.post_action_edit)) - add(stringResource(MR.strings.comment_action_delete)) - } - }, blurNsfw = uiState.blurNsfw, + onClick = { + model.reduce(PostListMviModel.Intent.MarkAsRead(idx)) + navigator?.push( + PostDetailScreen(post), + ) + }, onOpenCommunity = { community -> navigator?.push( CommunityDetailScreen(community), @@ -367,6 +357,15 @@ class PostListScreen : Screen { ZoomableImageScreen(url), ) }, + options = buildList { + add(stringResource(MR.strings.post_action_share)) + add(stringResource(MR.strings.post_action_hide)) + add(stringResource(MR.strings.post_action_report)) + if (post.creator?.id == uiState.currentUserId) { + add(stringResource(MR.strings.post_action_edit)) + add(stringResource(MR.strings.comment_action_delete)) + } + }, onOptionSelected = { optionIdx -> when (optionIdx) { 4 -> model.reduce( diff --git a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/logged/ProfileLoggedScreen.kt b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/logged/ProfileLoggedScreen.kt index cee91ee12..c1c114f71 100644 --- a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/logged/ProfileLoggedScreen.kt +++ b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/logged/ProfileLoggedScreen.kt @@ -157,11 +157,6 @@ internal object ProfileLoggedScreen : Tab { } itemsIndexed(uiState.posts) { idx, post -> PostCard( - modifier = Modifier.onClick { - navigator?.push( - PostDetailScreen(post), - ) - }, post = post, postLayout = uiState.postLayout, fullHeightImage = uiState.fullHeightImages, @@ -169,10 +164,10 @@ internal object ProfileLoggedScreen : Tab { autoLoadImages = uiState.autoLoadImages, hideAuthor = true, blurNsfw = false, - options = buildList { - add(stringResource(MR.strings.post_action_share)) - add(stringResource(MR.strings.post_action_edit)) - add(stringResource(MR.strings.comment_action_delete)) + onClick = { + navigator?.push( + PostDetailScreen(post), + ) }, onOpenCommunity = { community -> navigator?.push( @@ -208,6 +203,11 @@ internal object ProfileLoggedScreen : Tab { ) ) }, + options = buildList { + add(stringResource(MR.strings.post_action_share)) + add(stringResource(MR.strings.post_action_edit)) + add(stringResource(MR.strings.comment_action_delete)) + }, onOptionSelected = { optionIdx -> when (optionIdx) { 1 -> { diff --git a/feature-search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/main/ExploreScreen.kt b/feature-search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/main/ExploreScreen.kt index 83ca0efea..5d5cd5f2d 100644 --- a/feature-search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/main/ExploreScreen.kt +++ b/feature-search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/main/ExploreScreen.kt @@ -293,17 +293,17 @@ class ExploreScreen : Screen { is PostModel -> { PostCard( - modifier = Modifier.onClick { - navigator?.push( - PostDetailScreen(result), - ) - }, post = result, postLayout = uiState.postLayout, fullHeightImage = uiState.fullHeightImages, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages, blurNsfw = uiState.blurNsfw, + onClick = { + navigator?.push( + PostDetailScreen(result), + ) + }, onOpenCommunity = { community -> navigator?.push( CommunityDetailScreen(community), diff --git a/feature-search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/multicommunity/detail/MultiCommunityScreen.kt b/feature-search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/multicommunity/detail/MultiCommunityScreen.kt index dec200eee..d2622b07e 100644 --- a/feature-search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/multicommunity/detail/MultiCommunityScreen.kt +++ b/feature-search/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/search/multicommunity/detail/MultiCommunityScreen.kt @@ -304,23 +304,18 @@ class MultiCommunityScreen( }, content = { PostCard( - modifier = Modifier.onClick { - model.reduce(MultiCommunityMviModel.Intent.MarkAsRead(idx)) - navigator?.push( - PostDetailScreen(post), - ) - }, post = post, postLayout = uiState.postLayout, fullHeightImage = uiState.fullHeightImages, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages, - options = buildList { - add(stringResource(MR.strings.post_action_share)) - add(stringResource(MR.strings.post_action_hide)) - add(stringResource(MR.strings.post_action_report)) - }, blurNsfw = uiState.blurNsfw, + onClick = { + model.reduce(MultiCommunityMviModel.Intent.MarkAsRead(idx)) + navigator?.push( + PostDetailScreen(post), + ) + }, onOpenCommunity = { community -> navigator?.push( CommunityDetailScreen(community), @@ -374,6 +369,11 @@ class MultiCommunityScreen( ZoomableImageScreen(url), ) }, + options = buildList { + add(stringResource(MR.strings.post_action_share)) + add(stringResource(MR.strings.post_action_hide)) + add(stringResource(MR.strings.post_action_report)) + }, onOptionSelected = { optionIdx -> when (optionIdx) { 2 -> {