Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement hide/show highlights context option on ArticleDetailsScreen #253

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>ComplexCondition:NostrResources.kt$isNote() || isNoteUri() || isNEventUri() || isNEvent()</ID>
<ID>CyclomaticComplexMethod:ArticleDetailsScreen.kt$@OptIn(ExperimentalLayoutApi::class) @Composable private fun ArticleContentWithComments( state: ArticleDetailsContract.UiState, articleParts: List&lt;ArticlePartRender&gt;, listState: LazyListState = rememberLazyListState(), paddingValues: PaddingValues, onArticleCommentClick: (naddr: String) -&gt; Unit, onArticleHashtagClick: (hashtag: String) -&gt; Unit, onZapOptionsClick: () -&gt; Unit, noteCallbacks: NoteCallbacks, onGoToWallet: () -&gt; Unit, onPostAction: ((FeedPostAction) -&gt; Unit)? = null, onPostLongPressAction: ((FeedPostAction) -&gt; Unit)? = null, onFollowUnfollowClick: (() -&gt; Unit)? = null, onUiError: ((UiError) -&gt; Unit)? = null, )</ID>
<ID>CyclomaticComplexMethod:ArticleDetailsScreen.kt$@OptIn(ExperimentalLayoutApi::class) @Composable private fun ArticleContentWithComments( state: ArticleDetailsContract.UiState, articleParts: List&lt;ArticlePartRender&gt;, listState: LazyListState = rememberLazyListState(), showHighlights: Boolean, paddingValues: PaddingValues, onArticleCommentClick: (naddr: String) -&gt; Unit, onArticleHashtagClick: (hashtag: String) -&gt; Unit, onZapOptionsClick: () -&gt; Unit, noteCallbacks: NoteCallbacks, onGoToWallet: () -&gt; Unit, onPostAction: ((FeedPostAction) -&gt; Unit)? = null, onPostLongPressAction: ((FeedPostAction) -&gt; Unit)? = null, onFollowUnfollowClick: (() -&gt; Unit)? = null, onUiError: ((UiError) -&gt; Unit)? = null, )</ID>
<ID>CyclomaticComplexMethod:ArticleDetailsScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable private fun ArticleDetailsScreen( detailsState: ArticleDetailsContract.UiState, articleState: ArticleContract.UiState, detailsEventPublisher: (UiEvent) -&gt; Unit, articleEventPublisher: (ArticleContract.UiEvent) -&gt; Unit, onArticleHashtagClick: (hashtag: String) -&gt; Unit, noteCallbacks: NoteCallbacks, onGoToWallet: () -&gt; Unit, onClose: () -&gt; Unit, )</ID>
<ID>CyclomaticComplexMethod:ChatScreen.kt$@Composable private fun ChatMessageListItem( chatMessage: ChatMessageUi, previousMessage: ChatMessageUi? = null, nextMessage: ChatMessageUi? = null, onUrlClick: (String) -&gt; Unit, noteCallbacks: NoteCallbacks, )</ID>
<ID>CyclomaticComplexMethod:CreateTransactionScreen.kt$@ExperimentalComposeUiApi @ExperimentalMaterial3Api @Composable fun CreateTransactionScreen( state: CreateTransactionContract.UiState, eventPublisher: (CreateTransactionContract.UiEvent) -&gt; Unit, onClose: () -&gt; Unit, )</ID>
Expand Down Expand Up @@ -33,11 +33,10 @@
<ID>CyclomaticComplexMethod:WalletDashboardScreen.kt$@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) @Composable fun WalletDashboardScreen( state: WalletDashboardContract.UiState, onPrimaryDestinationChanged: (PrimalTopLevelDestination) -&gt; Unit, onDrawerDestinationClick: (DrawerScreenDestination) -&gt; Unit, onDrawerQrCodeClick: () -&gt; Unit, onWalletActivateClick: () -&gt; Unit, onProfileClick: (String) -&gt; Unit, onTransactionClick: (String) -&gt; Unit, onSendClick: () -&gt; Unit, onScanClick: () -&gt; Unit, onReceiveClick: () -&gt; Unit, eventPublisher: (UiEvent) -&gt; Unit, )</ID>
<ID>CyclomaticComplexMethod:WalletTransactionsMediator.kt$WalletTransactionsMediator$override suspend fun load(loadType: LoadType, state: PagingState&lt;Int, WalletTransaction&gt;): MediatorResult</ID>
<ID>DestructuringDeclarationWithTooManyEntries:PrimalDrawer.kt$val (avatarRef, usernameRef, iconRef, identifierRef, statsRef) = createRefs()</ID>
<ID>LongMethod:ArticleDetailsScreen.kt$@OptIn(ExperimentalLayoutApi::class) @Composable private fun ArticleContentWithComments( state: ArticleDetailsContract.UiState, articleParts: List&lt;ArticlePartRender&gt;, listState: LazyListState = rememberLazyListState(), paddingValues: PaddingValues, onArticleCommentClick: (naddr: String) -&gt; Unit, onArticleHashtagClick: (hashtag: String) -&gt; Unit, onZapOptionsClick: () -&gt; Unit, noteCallbacks: NoteCallbacks, onGoToWallet: () -&gt; Unit, onPostAction: ((FeedPostAction) -&gt; Unit)? = null, onPostLongPressAction: ((FeedPostAction) -&gt; Unit)? = null, onFollowUnfollowClick: (() -&gt; Unit)? = null, onUiError: ((UiError) -&gt; Unit)? = null, )</ID>
<ID>LongMethod:ArticleDetailsScreen.kt$@OptIn(ExperimentalLayoutApi::class) @Composable private fun ArticleContentWithComments( state: ArticleDetailsContract.UiState, articleParts: List&lt;ArticlePartRender&gt;, listState: LazyListState = rememberLazyListState(), showHighlights: Boolean, paddingValues: PaddingValues, onArticleCommentClick: (naddr: String) -&gt; Unit, onArticleHashtagClick: (hashtag: String) -&gt; Unit, onZapOptionsClick: () -&gt; Unit, noteCallbacks: NoteCallbacks, onGoToWallet: () -&gt; Unit, onPostAction: ((FeedPostAction) -&gt; Unit)? = null, onPostLongPressAction: ((FeedPostAction) -&gt; Unit)? = null, onFollowUnfollowClick: (() -&gt; Unit)? = null, onUiError: ((UiError) -&gt; Unit)? = null, )</ID>
<ID>LongMethod:ArticleDetailsScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable private fun ArticleDetailsScreen( detailsState: ArticleDetailsContract.UiState, articleState: ArticleContract.UiState, detailsEventPublisher: (UiEvent) -&gt; Unit, articleEventPublisher: (ArticleContract.UiEvent) -&gt; Unit, onArticleHashtagClick: (hashtag: String) -&gt; Unit, noteCallbacks: NoteCallbacks, onGoToWallet: () -&gt; Unit, onClose: () -&gt; Unit, )</ID>
<ID>LongMethod:ArticleDropdownMenu.kt$@ExperimentalMaterial3Api @Composable fun ArticleDropdownMenuIcon( modifier: Modifier, articleId: String, articleContent: String?, articleRawData: String?, authorId: String, isBookmarked: Boolean, enabled: Boolean = true, onBookmarkClick: (() -&gt; Unit)? = null, onMuteUserClick: (() -&gt; Unit)? = null, onReportContentClick: ((reportType: ReportType) -&gt; Unit)? = null, icon: @Composable () -&gt; Unit, )</ID>
<ID>LongMethod:ArticleDropdownMenu.kt$@ExperimentalMaterial3Api @Composable fun ArticleDropdownMenuIcon( modifier: Modifier, articleId: String, articleContent: String?, articleRawData: String?, authorId: String, isBookmarked: Boolean, enabled: Boolean = true, showHighlights: Boolean? = null, onToggleHighlightsClick: (() -&gt; Unit)? = null, onBookmarkClick: (() -&gt; Unit)? = null, onMuteUserClick: (() -&gt; Unit)? = null, onReportContentClick: ((reportType: ReportType) -&gt; Unit)? = null, icon: @Composable () -&gt; Unit, )</ID>
<ID>LongMethod:ArticleFeedList.kt$@ExperimentalMaterial3Api @ExperimentalFoundationApi @Composable private fun ArticleFeedLazyColumn( articleState: ArticleContract.UiState, pagingItems: LazyPagingItems&lt;FeedArticleUi&gt;, listState: LazyListState, showPaywall: Boolean, onArticleClick: (naddr: String) -&gt; Unit, onGetPremiumClick: () -&gt; Unit, articleEventPublisher: (ArticleContract.UiEvent) -&gt; Unit, modifier: Modifier = Modifier, noContentText: String = stringResource(id = R.string.article_feed_no_content), noContentVerticalArrangement: Arrangement.Vertical = Arrangement.Center, noContentPaddingValues: PaddingValues = PaddingValues(all = 0.dp), contentPadding: PaddingValues = PaddingValues(all = 0.dp), header: @Composable (LazyItemScope.() -&gt; Unit)? = null, stickyHeader: @Composable (LazyItemScope.() -&gt; Unit)? = null, )</ID>
<ID>LongMethod:BecomeLegendAmountStage.kt$@ExperimentalMaterial3Api @Composable fun BecomeLegendAmountStage( modifier: Modifier, state: PremiumBecomeLegendContract.UiState, eventPublisher: (PremiumBecomeLegendContract.UiEvent) -&gt; Unit, onClose: () -&gt; Unit, onNext: () -&gt; Unit, )</ID>
<ID>LongMethod:ChatScreen.kt$@Composable private fun ChatList( messages: LazyPagingItems&lt;ChatMessageUi&gt;, noteCallbacks: NoteCallbacks, modifier: Modifier = Modifier, state: LazyListState = rememberLazyListState(), contentPadding: PaddingValues = PaddingValues(0.dp), )</ID>
<ID>LongMethod:ChatScreen.kt$@Composable private fun ChatMessageListItem( chatMessage: ChatMessageUi, previousMessage: ChatMessageUi? = null, nextMessage: ChatMessageUi? = null, onUrlClick: (String) -&gt; Unit, noteCallbacks: NoteCallbacks, )</ID>
<ID>LongMethod:ContentDisplaySettingsScreen.kt$@Composable @ExperimentalMaterial3Api private fun ContentDisplaySettingsScreen( state: ContentDisplaySettingsContract.UiState, onClose: () -&gt; Unit, eventPublisher: (UiEvent) -&gt; Unit, )</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ import net.primal.android.core.compose.icons.primaliconpack.ContextCopyNoteLink
import net.primal.android.core.compose.icons.primaliconpack.ContextCopyNoteText
import net.primal.android.core.compose.icons.primaliconpack.ContextCopyPublicKey
import net.primal.android.core.compose.icons.primaliconpack.ContextCopyRawData
import net.primal.android.core.compose.icons.primaliconpack.ContextHideHighlightsOutlined
import net.primal.android.core.compose.icons.primaliconpack.ContextMuteUser
import net.primal.android.core.compose.icons.primaliconpack.ContextRemoveBookmark
import net.primal.android.core.compose.icons.primaliconpack.ContextReportUser
import net.primal.android.core.compose.icons.primaliconpack.ContextShare
import net.primal.android.core.compose.icons.primaliconpack.ContextShowHighlightsOutlined
import net.primal.android.core.utils.copyText
import net.primal.android.core.utils.resolvePrimalArticleLink
import net.primal.android.core.utils.systemShareText
Expand All @@ -50,6 +52,8 @@ fun ArticleDropdownMenuIcon(
authorId: String,
isBookmarked: Boolean,
enabled: Boolean = true,
showHighlights: Boolean? = null,
onToggleHighlightsClick: (() -> Unit)? = null,
onBookmarkClick: (() -> Unit)? = null,
onMuteUserClick: (() -> Unit)? = null,
onReportContentClick: ((reportType: ReportType) -> Unit)? = null,
Expand Down Expand Up @@ -103,6 +107,24 @@ fun ArticleDropdownMenuIcon(
menuVisible = false
},
)
if (showHighlights != null) {
DropdownPrimalMenuItem(
trailingIconVector = if (showHighlights) {
PrimalIcons.ContextHideHighlightsOutlined
} else {
PrimalIcons.ContextShowHighlightsOutlined
},
text = if (showHighlights) {
stringResource(id = R.string.article_feed_context_hide_highglights)
} else {
stringResource(id = R.string.article_feed_context_show_highglights)
},
onClick = {
onToggleHighlightsClick?.invoke()
menuVisible = false
},
)
}
DropdownPrimalMenuItem(
trailingIconVector = PrimalIcons.ContextCopyNoteLink,
text = stringResource(id = R.string.article_feed_context_copy_article_link),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import net.primal.android.core.compose.icons.primaliconpack.ContextCopyNoteLink
import net.primal.android.core.compose.icons.primaliconpack.ContextCopyNoteText
import net.primal.android.core.compose.icons.primaliconpack.ContextCopyPublicKey
import net.primal.android.core.compose.icons.primaliconpack.ContextCopyRawData
import net.primal.android.core.compose.icons.primaliconpack.ContextHideHighlightsOutlined
import net.primal.android.core.compose.icons.primaliconpack.ContextMuteConversation
import net.primal.android.core.compose.icons.primaliconpack.ContextMuteUser
import net.primal.android.core.compose.icons.primaliconpack.ContextRemoveBookmark
import net.primal.android.core.compose.icons.primaliconpack.ContextReportUser
import net.primal.android.core.compose.icons.primaliconpack.ContextShare
import net.primal.android.core.compose.icons.primaliconpack.ContextShowHighlightsOutlined
import net.primal.android.core.compose.icons.primaliconpack.Copy
import net.primal.android.core.compose.icons.primaliconpack.CopyAlt
import net.primal.android.core.compose.icons.primaliconpack.DarkMode
Expand Down Expand Up @@ -64,6 +66,7 @@ import net.primal.android.core.compose.icons.primaliconpack.FeedZapsFilled
import net.primal.android.core.compose.icons.primaliconpack.FontSize
import net.primal.android.core.compose.icons.primaliconpack.GenericLinkIcon
import net.primal.android.core.compose.icons.primaliconpack.Help
import net.primal.android.core.compose.icons.primaliconpack.Highlight
import net.primal.android.core.compose.icons.primaliconpack.Home
import net.primal.android.core.compose.icons.primaliconpack.HomeFilled
import net.primal.android.core.compose.icons.primaliconpack.ImportPhotoFromCamera
Expand Down Expand Up @@ -111,6 +114,7 @@ import net.primal.android.core.compose.icons.primaliconpack.PrimalPremium
import net.primal.android.core.compose.icons.primaliconpack.QrCode
import net.primal.android.core.compose.icons.primaliconpack.Quote
import net.primal.android.core.compose.icons.primaliconpack.Read
import net.primal.android.core.compose.icons.primaliconpack.RemoveHighlight
import net.primal.android.core.compose.icons.primaliconpack.Report
import net.primal.android.core.compose.icons.primaliconpack.Repost
import net.primal.android.core.compose.icons.primaliconpack.Search
Expand Down Expand Up @@ -198,8 +202,12 @@ val PrimalIcons.PrimalIcons: ____KtList<ImageVector>
Zap,
Repost,
Quote,
Highlight,
RemoveHighlight,
ContextCopyNoteLink,
ContextCopyNoteId,
ContextShowHighlightsOutlined,
ContextHideHighlightsOutlined,
ContextCopyPublicKey,
ContextReportUser,
ContextCopyRawData,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package net.primal.android.core.compose.icons.primaliconpack

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType
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
import net.primal.android.core.compose.icons.PrimalIcons
import kotlin.Suppress

val PrimalIcons.ContextHideHighlightsOutlined: ImageVector
get() {
if (_ContextHideHighlightsOutlined != null) {
return _ContextHideHighlightsOutlined!!
}
_ContextHideHighlightsOutlined = ImageVector.Builder(
name = "ContextHideHighlightsOutlined",
defaultWidth = 20.dp,
defaultHeight = 20.dp,
viewportWidth = 20f,
viewportHeight = 20f
).apply {
path(fill = SolidColor(Color(0xFFFFFFFF))) {
moveTo(0.251f, 1.443f)
curveTo(-0.084f, 1.113f, -0.084f, 0.578f, 0.251f, 0.248f)
curveTo(0.586f, -0.083f, 1.128f, -0.083f, 1.463f, 0.248f)
lineTo(19.749f, 18.276f)
curveTo(20.084f, 18.606f, 20.084f, 19.141f, 19.749f, 19.471f)
curveTo(19.414f, 19.801f, 18.872f, 19.801f, 18.537f, 19.471f)
lineTo(0.251f, 1.443f)
close()
}
path(fill = SolidColor(Color(0xFFFFFFFF))) {
moveTo(4.643f, 7.81f)
lineTo(3.387f, 8.671f)
curveTo(1.915f, 9.681f, 1.516f, 11.573f, 2.307f, 13.039f)
curveTo(2.465f, 13.332f, 2.67f, 13.608f, 2.923f, 13.856f)
lineTo(6.884f, 17.738f)
curveTo(7.137f, 17.987f, 7.419f, 18.188f, 7.717f, 18.343f)
curveTo(9.213f, 19.118f, 11.143f, 18.727f, 12.174f, 17.284f)
lineTo(13.033f, 16.081f)
lineTo(11.951f, 15.015f)
lineTo(10.953f, 16.413f)
curveTo(10.256f, 17.389f, 8.804f, 17.52f, 7.934f, 16.667f)
lineTo(3.973f, 12.785f)
curveTo(3.129f, 11.957f, 3.243f, 10.589f, 4.235f, 9.908f)
lineTo(5.731f, 8.882f)
lineTo(4.643f, 7.81f)
close()
}
path(fill = SolidColor(Color(0xFFFFFFFF))) {
moveTo(9.26f, 6.461f)
lineTo(8.172f, 5.388f)
lineTo(13.5f, 1.732f)
curveTo(15.142f, 0.605f, 17.373f, 0.797f, 18.79f, 2.186f)
curveTo(20.207f, 3.575f, 20.403f, 5.761f, 19.253f, 7.371f)
lineTo(15.506f, 12.618f)
lineTo(14.424f, 11.552f)
lineTo(18.033f, 6.499f)
curveTo(18.75f, 5.494f, 18.632f, 4.132f, 17.74f, 3.257f)
curveTo(16.837f, 2.372f, 15.403f, 2.246f, 14.349f, 2.969f)
lineTo(9.26f, 6.461f)
close()
}
path(
fill = SolidColor(Color(0xFFFFFFFF)),
pathFillType = PathFillType.EvenOdd
) {
moveTo(5.242f, 18.668f)
lineTo(5.72f, 18.199f)
lineTo(2.453f, 14.997f)
lineTo(0.341f, 17.067f)
curveTo(-0.387f, 17.78f, 0.128f, 19f, 1.158f, 19f)
lineTo(4.425f, 19f)
curveTo(4.731f, 19f, 5.025f, 18.881f, 5.242f, 18.668f)
close()
}
}.build()

return _ContextHideHighlightsOutlined!!
}

@Suppress("ObjectPropertyName")
private var _ContextHideHighlightsOutlined: ImageVector? = null
Loading