From 544da29b5cc25d1c6d96c3d0a43eb59f98899afe Mon Sep 17 00:00:00 2001 From: Mehmedalija Karisik Date: Thu, 19 Dec 2024 03:07:43 +0100 Subject: [PATCH 1/5] Refactor User Badge component --- .../android/core/compose/NostrUserText.kt | 18 ++++++++++++++++-- .../net/primal/android/drawer/PrimalDrawer.kt | 6 +----- .../explore/home/people/ExplorePeople.kt | 6 +----- .../MessageConversationListScreen.kt | 2 +- .../android/notes/feed/note/ui/NoteHeader.kt | 6 +----- .../android/premium/home/PremiumHomeScreen.kt | 6 +----- .../become/amount/BecomeLegendAmountStage.kt | 5 ++++- .../LegendaryProfileCustomizationScreen.kt | 7 ++++++- .../nameChange/ConfirmNameChangeStage.kt | 6 +----- .../profile/details/ui/ProfileDetailsHeader.kt | 6 +----- .../profile/details/ui/ProfileTopCoverBar.kt | 7 +------ .../reactions/ui/GenericReactionsLazyColumn.kt | 6 +----- .../reactions/ui/ReactionsZapsLazyColumn.kt | 6 +----- .../articles/details/ui/ArticleAuthorRow.kt | 6 +----- .../details/ui/HighlightActivityBottomSheet.kt | 6 +----- 15 files changed, 38 insertions(+), 61 deletions(-) diff --git a/app/src/main/kotlin/net/primal/android/core/compose/NostrUserText.kt b/app/src/main/kotlin/net/primal/android/core/compose/NostrUserText.kt index 3dd0d278..ec54e096 100644 --- a/app/src/main/kotlin/net/primal/android/core/compose/NostrUserText.kt +++ b/app/src/main/kotlin/net/primal/android/core/compose/NostrUserText.kt @@ -41,6 +41,7 @@ import net.primal.android.core.compose.icons.primaliconpack.PrimalBadgeTeal import net.primal.android.core.compose.icons.primaliconpack.Verified import net.primal.android.core.compose.preview.PrimalPreview import net.primal.android.core.utils.isPrimalIdentifier +import net.primal.android.premium.legend.LegendaryCustomization import net.primal.android.premium.legend.LegendaryStyle import net.primal.android.theme.AppTheme import net.primal.android.theme.domain.PrimalTheme @@ -57,12 +58,18 @@ fun NostrUserText( maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, - customBadgeStyle: LegendaryStyle? = null, + authorLegendaryCustomization: LegendaryCustomization? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) { val verifiedBadge = !internetIdentifier.isNullOrEmpty() + val customBadgeStyle = if (authorLegendaryCustomization?.customBadge == true) { + authorLegendaryCustomization.legendaryStyle + } else { + null + } + val titleText = buildAnnotatedString { annotatedStringPrefixBuilder?.invoke(this) append( @@ -156,6 +163,7 @@ fun PreviewNostrUserTextWithPrimalBadge() { annotatedStringSuffixBuilder = { append("• 42 y. ago") }, + authorLegendaryCustomization = null, ) } } @@ -172,6 +180,7 @@ fun PreviewNostrUserTextWithRandomBadge() { annotatedStringSuffixBuilder = { append("• 42 y. ago") }, + authorLegendaryCustomization = null, ) } } @@ -188,6 +197,7 @@ fun PreviewNostrUserTextWithoutBadge() { annotatedStringSuffixBuilder = { append(" • 42 y. ago") }, + authorLegendaryCustomization = null, ) } } @@ -200,11 +210,15 @@ fun PreviewNostrUserTextWithCustomBadge() { Surface { NostrUserText( displayName = "Nostr Adamus", - customBadgeStyle = LegendaryStyle.GOLD, internetIdentifier = "legend@primal.net", annotatedStringSuffixBuilder = { append(" • 42 y. ago") }, + authorLegendaryCustomization = LegendaryCustomization( + customBadge = true, + avatarGlow = true, + legendaryStyle = LegendaryStyle.GOLD, + ), ) } } diff --git a/app/src/main/kotlin/net/primal/android/drawer/PrimalDrawer.kt b/app/src/main/kotlin/net/primal/android/drawer/PrimalDrawer.kt index e1b296a1..b7593765 100644 --- a/app/src/main/kotlin/net/primal/android/drawer/PrimalDrawer.kt +++ b/app/src/main/kotlin/net/primal/android/drawer/PrimalDrawer.kt @@ -175,11 +175,7 @@ private fun DrawerHeader( top.linkTo(avatarRef.bottom, margin = 16.dp) width = Dimension.preferredValue(220.dp) }, - customBadgeStyle = if (legendaryCustomization?.customBadge == true) { - legendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = legendaryCustomization, ) IconButton( diff --git a/app/src/main/kotlin/net/primal/android/explore/home/people/ExplorePeople.kt b/app/src/main/kotlin/net/primal/android/explore/home/people/ExplorePeople.kt index 007b95a3..cbf5e39e 100644 --- a/app/src/main/kotlin/net/primal/android/explore/home/people/ExplorePeople.kt +++ b/app/src/main/kotlin/net/primal/android/explore/home/people/ExplorePeople.kt @@ -199,11 +199,7 @@ private fun ExplorePersonListItem( NostrUserText( displayName = person.profile.userDisplayName, internetIdentifier = person.profile.internetIdentifier, - customBadgeStyle = if (person.profile.premiumDetails?.legendaryCustomization?.customBadge == true) { - person.profile.premiumDetails.legendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = person.profile.premiumDetails?.legendaryCustomization, ) person.profile.internetIdentifier?.let { Text( diff --git a/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListScreen.kt b/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListScreen.kt index 3d18bd4b..bfd7e417 100644 --- a/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListScreen.kt +++ b/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListScreen.kt @@ -312,7 +312,7 @@ private fun ConversationListItem( displayName = conversation.participantUsername, internetIdentifier = conversation.participantInternetIdentifier, annotatedStringSuffixBuilder = { append(suffixText) }, - customBadgeStyle = conversation.participantLegendaryCustomization?.legendaryStyle, + authorLegendaryCustomization = conversation.participantLegendaryCustomization, style = AppTheme.typography.bodyMedium, ) } diff --git a/app/src/main/kotlin/net/primal/android/notes/feed/note/ui/NoteHeader.kt b/app/src/main/kotlin/net/primal/android/notes/feed/note/ui/NoteHeader.kt index b071b079..f35f6c63 100644 --- a/app/src/main/kotlin/net/primal/android/notes/feed/note/ui/NoteHeader.kt +++ b/app/src/main/kotlin/net/primal/android/notes/feed/note/ui/NoteHeader.kt @@ -141,11 +141,7 @@ private fun NoteAuthorBadgeAndTimestampSection( style = topRowTextStyle, internetIdentifierBadgeSize = topRowTextStyle.fontSize.value.dp, overflow = TextOverflow.Ellipsis, - customBadgeStyle = if (authorLegendaryCustomization?.customBadge == true) { - authorLegendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = authorLegendaryCustomization, ) }, suffixFixedContent = { diff --git a/app/src/main/kotlin/net/primal/android/premium/home/PremiumHomeScreen.kt b/app/src/main/kotlin/net/primal/android/premium/home/PremiumHomeScreen.kt index b9c21c68..296167ac 100644 --- a/app/src/main/kotlin/net/primal/android/premium/home/PremiumHomeScreen.kt +++ b/app/src/main/kotlin/net/primal/android/premium/home/PremiumHomeScreen.kt @@ -147,11 +147,7 @@ private fun PremiumHomeScreen( internetIdentifier = "$primalName@primal.net", internetIdentifierBadgeSize = 24.dp, fontSize = 20.sp, - customBadgeStyle = if (state.avatarLegendaryCustomization?.customBadge == true) { - state.avatarLegendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = state.avatarLegendaryCustomization, ) } diff --git a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt index 6ba493fd..984b4b85 100644 --- a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt +++ b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt @@ -102,7 +102,10 @@ fun BecomeLegendAmountStage( internetIdentifier = "${state.primalName}@primal.net", internetIdentifierBadgeSize = 24.dp, fontSize = 20.sp, - customBadgeStyle = LegendaryStyle.GOLD, + authorLegendaryCustomization = LegendaryCustomization( + customBadge = true, + legendaryStyle = LegendaryStyle.GOLD + ), ) } diff --git a/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt b/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt index b8b0a6a4..72b77bc8 100644 --- a/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt +++ b/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt @@ -145,7 +145,12 @@ fun LegendaryProfileCustomizationScreen( displayName = primalName, internetIdentifier = "$primalName@primal.net", internetIdentifierBadgeSize = 24.dp, - customBadgeStyle = if (customBadge == true) selectedStyle else null, + authorLegendaryCustomization = + if (customBadge == true) { + LegendaryCustomization(customBadge = true, legendaryStyle = selectedStyle) + } else { + null + }, fontSize = 20.sp, ) } diff --git a/app/src/main/kotlin/net/primal/android/premium/manage/nameChange/ConfirmNameChangeStage.kt b/app/src/main/kotlin/net/primal/android/premium/manage/nameChange/ConfirmNameChangeStage.kt index de8bc843..ed039c7f 100644 --- a/app/src/main/kotlin/net/primal/android/premium/manage/nameChange/ConfirmNameChangeStage.kt +++ b/app/src/main/kotlin/net/primal/android/premium/manage/nameChange/ConfirmNameChangeStage.kt @@ -46,11 +46,7 @@ fun ConfirmNameChangeStage( internetIdentifier = "$primalName@primal.net", internetIdentifierBadgeSize = 24.dp, fontSize = 20.sp, - customBadgeStyle = if (profileLegendaryCustomization?.customBadge == true) { - profileLegendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = profileLegendaryCustomization, ) Text( modifier = Modifier.padding(horizontal = 12.dp), diff --git a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt index 92d82e1e..e1628824 100644 --- a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt +++ b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt @@ -357,11 +357,7 @@ private fun UserDisplayName( lineHeight = 20.sp, fontWeight = FontWeight.Bold, ), - customBadgeStyle = if (hasCustomBadge) { - profilePremiumDetails?.legendaryCustomization?.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = profilePremiumDetails?.legendaryCustomization, ) val isPremiumBadgeClickable = activeUserPremiumTier == null || diff --git a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileTopCoverBar.kt b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileTopCoverBar.kt index 53698eeb..a5dd71b1 100644 --- a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileTopCoverBar.kt +++ b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileTopCoverBar.kt @@ -177,7 +177,6 @@ private fun ProfileTopAppBar( enter = fadeIn(), exit = fadeOut(), ) { - val hasCustomBadge = state.profileDetails?.premiumDetails?.legendaryCustomization?.customBadge NostrUserText( modifier = Modifier.padding(top = 4.dp), displayName = state.profileDetails?.authorDisplayName @@ -185,11 +184,7 @@ private fun ProfileTopAppBar( internetIdentifier = state.profileDetails?.internetIdentifier, internetIdentifierBadgeSize = 20.dp, internetIdentifierBadgeAlign = PlaceholderVerticalAlign.Center, - customBadgeStyle = if (hasCustomBadge == true) { - state.profileDetails.premiumDetails.legendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = state.profileDetails?.premiumDetails?.legendaryCustomization, ) } }, diff --git a/app/src/main/kotlin/net/primal/android/stats/reactions/ui/GenericReactionsLazyColumn.kt b/app/src/main/kotlin/net/primal/android/stats/reactions/ui/GenericReactionsLazyColumn.kt index d3035283..9f2e5701 100644 --- a/app/src/main/kotlin/net/primal/android/stats/reactions/ui/GenericReactionsLazyColumn.kt +++ b/app/src/main/kotlin/net/primal/android/stats/reactions/ui/GenericReactionsLazyColumn.kt @@ -86,11 +86,7 @@ private fun GenericReactionListItem( NostrUserText( displayName = item.profile.authorDisplayName, internetIdentifier = item.profile.internetIdentifier, - customBadgeStyle = if (item.profile.premiumDetails?.legendaryCustomization?.customBadge == true) { - item.profile.premiumDetails.legendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = item.profile.premiumDetails?.legendaryCustomization, ) }, trailingContent = { diff --git a/app/src/main/kotlin/net/primal/android/stats/reactions/ui/ReactionsZapsLazyColumn.kt b/app/src/main/kotlin/net/primal/android/stats/reactions/ui/ReactionsZapsLazyColumn.kt index 88c7956f..a45fe74a 100644 --- a/app/src/main/kotlin/net/primal/android/stats/reactions/ui/ReactionsZapsLazyColumn.kt +++ b/app/src/main/kotlin/net/primal/android/stats/reactions/ui/ReactionsZapsLazyColumn.kt @@ -92,11 +92,7 @@ private fun NoteZapListItem(data: EventZapUiModel, onProfileClick: (profileId: S NostrUserText( displayName = data.zapperName, internetIdentifier = data.zapperInternetIdentifier, - customBadgeStyle = if (data.zapperLegendaryCustomization?.customBadge == true) { - data.zapperLegendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = data.zapperLegendaryCustomization, ) }, supportingContent = { diff --git a/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/ArticleAuthorRow.kt b/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/ArticleAuthorRow.kt index 22c48f38..50be1bca 100644 --- a/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/ArticleAuthorRow.kt +++ b/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/ArticleAuthorRow.kt @@ -72,11 +72,7 @@ fun ArticleAuthorRow( fontSize = 16.sp, lineHeight = 16.sp, ), - customBadgeStyle = if (authorLegendaryCustomization?.customBadge == true) { - authorLegendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = authorLegendaryCustomization, ) if (!authorInternetIdentifier.isNullOrBlank()) { diff --git a/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/HighlightActivityBottomSheet.kt b/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/HighlightActivityBottomSheet.kt index 5f0ccec0..1a8f1c18 100644 --- a/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/HighlightActivityBottomSheet.kt +++ b/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/HighlightActivityBottomSheet.kt @@ -155,11 +155,7 @@ fun CommentRow(modifier: Modifier = Modifier, comment: CommentUi) { modifier = Modifier.padding(start = 8.dp), displayName = comment.authorDisplayName ?: "", internetIdentifier = comment.authorInternetIdentifier, - customBadgeStyle = if (comment.authorLegendaryCustomization?.customBadge == true) { - comment.authorLegendaryCustomization.legendaryStyle - } else { - null - }, + authorLegendaryCustomization = comment.authorLegendaryCustomization, ) Text( text = stringResource(id = R.string.article_details_highlight_activity_commented), From b0b4e38f70a1474a40f61d2c0262142410a8ba18 Mon Sep 17 00:00:00 2001 From: Mehmedalija Karisik Date: Thu, 19 Dec 2024 03:21:07 +0100 Subject: [PATCH 2/5] run formater --- .../premium/legend/become/amount/BecomeLegendAmountStage.kt | 2 +- .../primal/android/profile/details/ui/ProfileDetailsHeader.kt | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt index 984b4b85..601a0f31 100644 --- a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt +++ b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt @@ -104,7 +104,7 @@ fun BecomeLegendAmountStage( fontSize = 20.sp, authorLegendaryCustomization = LegendaryCustomization( customBadge = true, - legendaryStyle = LegendaryStyle.GOLD + legendaryStyle = LegendaryStyle.GOLD, ), ) } diff --git a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt index e1628824..e8f62812 100644 --- a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt +++ b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt @@ -340,8 +340,6 @@ private fun UserDisplayName( activeUserPremiumTier: String?, onPremiumBadgeClick: (tier: String) -> Unit, ) { - val hasCustomBadge = profilePremiumDetails?.legendaryCustomization?.customBadge == true - Row( modifier = modifier.padding(top = 12.dp, bottom = 3.dp), verticalAlignment = Alignment.CenterVertically, From 9bd3d32fa64da7aa316495160017578f6e54ef73 Mon Sep 17 00:00:00 2001 From: Mehmedalija Karisik Date: Thu, 19 Dec 2024 11:24:08 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=C3=84modify=20detekt-baseline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/detekt-baseline.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/detekt-baseline.xml b/app/detekt-baseline.xml index 6df3048b..558c8175 100644 --- a/app/detekt-baseline.xml +++ b/app/detekt-baseline.xml @@ -13,7 +13,7 @@ CyclomaticComplexMethod:FeedNoteCard.kt$@Composable private fun FeedNote( data: FeedPostUi, fullWidthContent: Boolean, avatarSizeDp: Dp, avatarPaddingValues: PaddingValues, notePaddingValues: PaddingValues, enableTweetsMode: Boolean, headerSingleLine: Boolean, showReplyTo: Boolean, forceContentIndent: Boolean, expanded: Boolean, textSelectable: Boolean, showNoteStatCounts: Boolean, noteCallbacks: NoteCallbacks, onPostAction: ((FeedPostAction) -> Unit)? = null, onPostLongClickAction: ((FeedPostAction) -> Unit)? = null, contentFooter: @Composable () -> Unit = {}, ) CyclomaticComplexMethod:FeedNoteCard.kt$@ExperimentalMaterial3Api @Composable private fun FeedNoteCard( data: FeedPostUi, state: NoteContract.UiState, eventPublisher: (UiEvent) -> Unit, modifier: Modifier = Modifier, shape: Shape = CardDefaults.shape, colors: CardColors = noteCardColors(), cardPadding: PaddingValues = PaddingValues(all = 0.dp), enableTweetsMode: Boolean = false, headerSingleLine: Boolean = true, fullWidthContent: Boolean = false, forceContentIndent: Boolean = false, drawLineAboveAvatar: Boolean = false, drawLineBelowAvatar: Boolean = false, expanded: Boolean = false, textSelectable: Boolean = false, showReplyTo: Boolean = true, noteOptionsMenuEnabled: Boolean = true, showNoteStatCounts: Boolean = true, noteCallbacks: NoteCallbacks = NoteCallbacks(), onGoToWallet: (() -> Unit)? = null, contentFooter: @Composable () -> Unit = {}, ) CyclomaticComplexMethod:MessagesRemoteMediator.kt$MessagesRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState<Int, DirectMessage>): MediatorResult - CyclomaticComplexMethod:NostrUserText.kt$@Composable fun NostrUserText( displayName: String, internetIdentifier: String?, modifier: Modifier = Modifier, displayNameColor: Color = AppTheme.colorScheme.onSurface, fontSize: TextUnit = TextUnit.Unspecified, style: TextStyle = LocalTextStyle.current, overflow: TextOverflow = TextOverflow.Ellipsis, maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, customBadgeStyle: LegendaryStyle? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) + CyclomaticComplexMethod:NostrUserText.kt$@Composable fun NostrUserText( displayName: String, internetIdentifier: String?, modifier: Modifier = Modifier, displayNameColor: Color = AppTheme.colorScheme.onSurface, fontSize: TextUnit = TextUnit.Unspecified, style: TextStyle = LocalTextStyle.current, overflow: TextOverflow = TextOverflow.Ellipsis, maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, authorLegendaryCustomization: LegendaryCustomization? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) CyclomaticComplexMethod:NoteActionsRow.kt$@Composable fun FeedNoteActionsRow( modifier: Modifier, eventStats: EventStatsUi, isBookmarked: Boolean, highlightedNote: Boolean = false, showBookmark: Boolean = false, showCounts: Boolean = true, onPostAction: ((FeedPostAction) -> Unit)? = null, onPostLongPressAction: ((FeedPostAction) -> Unit)? = null, ) CyclomaticComplexMethod:NoteContent.kt$@OptIn(ExperimentalFoundationApi::class) @Composable fun NoteContent( modifier: Modifier = Modifier, data: NoteContentUi, expanded: Boolean, noteCallbacks: NoteCallbacks, maxLines: Int = Int.MAX_VALUE, overflow: TextOverflow = TextOverflow.Clip, enableTweetsMode: Boolean = false, textSelectable: Boolean = false, referencedEventsHaveBorder: Boolean = false, highlightColor: Color = AppTheme.colorScheme.secondary, contentColor: Color = AppTheme.colorScheme.onSurface, referencedEventsContainerColor: Color = AppTheme.extraColorScheme.surfaceVariantAlt1, onClick: ((offset: Offset) -> Unit)? = null, onUrlClick: ((url: String) -> Unit)? = null, ) CyclomaticComplexMethod:NoteFeedLazyColumn.kt$@ExperimentalMaterial3Api @ExperimentalFoundationApi @Composable fun NoteFeedLazyColumn( modifier: Modifier = Modifier, pagingItems: LazyPagingItems<FeedPostUi>, listState: LazyListState, showPaywall: Boolean, noteCallbacks: NoteCallbacks, onGoToWallet: () -> Unit, showTopZaps: Boolean = false, shouldShowLoadingState: Boolean = true, shouldShowNoContentState: Boolean = true, showReplyTo: Boolean = true, noContentVerticalArrangement: Arrangement.Vertical = Arrangement.Center, noContentPaddingValues: PaddingValues = PaddingValues(all = 0.dp), noContentText: String = stringResource(id = R.string.feed_no_content), contentPadding: PaddingValues = PaddingValues(all = 0.dp), header: @Composable (LazyItemScope.() -> Unit)? = null, stickyHeader: @Composable (LazyItemScope.() -> Unit)? = null, onUiError: ((UiError) -> Unit)? = null, ) @@ -54,7 +54,7 @@ LongMethod:MessageConversationListScreen.kt$@Composable private fun ConversationListItem( conversation: MessageConversationUi, onConversationClick: (String) -> Unit, onProfileClick: (profileId: String) -> Unit, ) LongMethod:MessageConversationListScreen.kt$@Composable private fun MessagesTabs( relation: ConversationRelation, onFollowsTabClick: () -> Unit, onOtherTabClick: () -> Unit, onMarkAllRead: () -> Unit, ) LongMethod:MultipleUserPicker.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun MultipleUserPicker( modifier: Modifier = Modifier, sheetTitle: String, placeholderText: String, onDismissRequest: () -> Unit, onUsersSelected: (Set<UserProfileItemUi>) -> Unit, sheetState: SheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true), startingSelectedUsers: Set<UserProfileItemUi>, ) - LongMethod:NostrUserText.kt$@Composable fun NostrUserText( displayName: String, internetIdentifier: String?, modifier: Modifier = Modifier, displayNameColor: Color = AppTheme.colorScheme.onSurface, fontSize: TextUnit = TextUnit.Unspecified, style: TextStyle = LocalTextStyle.current, overflow: TextOverflow = TextOverflow.Ellipsis, maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, customBadgeStyle: LegendaryStyle? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) + LongMethod:NostrUserText.kt$@Composable fun NostrUserText( displayName: String, internetIdentifier: String?, modifier: Modifier = Modifier, displayNameColor: Color = AppTheme.colorScheme.onSurface, fontSize: TextUnit = TextUnit.Unspecified, style: TextStyle = LocalTextStyle.current, overflow: TextOverflow = TextOverflow.Ellipsis, maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, authorLegendaryCustomization: LegendaryCustomization? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) LongMethod:NoteActionsRow.kt$@Composable fun FeedNoteActionsRow( modifier: Modifier, eventStats: EventStatsUi, isBookmarked: Boolean, highlightedNote: Boolean = false, showBookmark: Boolean = false, showCounts: Boolean = true, onPostAction: ((FeedPostAction) -> Unit)? = null, onPostLongPressAction: ((FeedPostAction) -> Unit)? = null, ) LongMethod:NoteContent.kt$@OptIn(ExperimentalFoundationApi::class) @Composable fun NoteContent( modifier: Modifier = Modifier, data: NoteContentUi, expanded: Boolean, noteCallbacks: NoteCallbacks, maxLines: Int = Int.MAX_VALUE, overflow: TextOverflow = TextOverflow.Clip, enableTweetsMode: Boolean = false, textSelectable: Boolean = false, referencedEventsHaveBorder: Boolean = false, highlightColor: Color = AppTheme.colorScheme.secondary, contentColor: Color = AppTheme.colorScheme.onSurface, referencedEventsContainerColor: Color = AppTheme.extraColorScheme.surfaceVariantAlt1, onClick: ((offset: Offset) -> Unit)? = null, onUrlClick: ((url: String) -> Unit)? = null, ) LongMethod:NoteDropdownMenu.kt$@Composable fun NoteDropdownMenuIcon( modifier: Modifier, noteId: String, noteContent: String, noteRawData: String, authorId: String, isBookmarked: Boolean, enabled: Boolean = true, onBookmarkClick: (() -> Unit)? = null, onMuteUserClick: (() -> Unit)? = null, onReportContentClick: (() -> Unit)? = null, ) From f7c474898188834f65212c89029947ef2457ba9d Mon Sep 17 00:00:00 2001 From: Mehmedalija Karisik Date: Fri, 20 Dec 2024 00:55:29 +0100 Subject: [PATCH 4/5] Resolve comments --- app/detekt-baseline.xml | 5 +++-- .../primal/android/core/compose/NostrUserText.kt | 14 +++++++------- .../net/primal/android/drawer/PrimalDrawer.kt | 2 +- .../android/explore/home/people/ExplorePeople.kt | 2 +- .../conversation/MessageConversationListScreen.kt | 2 +- .../android/notes/feed/note/ui/NoteHeader.kt | 2 +- .../notifications/list/ui/NotificationListItem.kt | 1 + .../buying/purchase/PremiumPurchaseStage.kt | 1 + .../android/premium/home/PremiumHomeScreen.kt | 2 +- .../become/amount/BecomeLegendAmountStage.kt | 2 +- .../LegendaryProfileCustomizationScreen.kt | 10 +++++----- .../manage/nameChange/ConfirmNameChangeStage.kt | 2 +- .../profile/details/ui/ProfileDetailsHeader.kt | 2 +- .../profile/details/ui/ProfileTopCoverBar.kt | 2 +- .../settings/muted/list/MutedSettingsScreen.kt | 1 + .../reactions/ui/GenericReactionsLazyColumn.kt | 2 +- .../stats/reactions/ui/ReactionsZapsLazyColumn.kt | 2 +- .../thread/articles/details/ui/ArticleAuthorRow.kt | 2 +- .../details/ui/HighlightActivityBottomSheet.kt | 2 +- 19 files changed, 31 insertions(+), 27 deletions(-) diff --git a/app/detekt-baseline.xml b/app/detekt-baseline.xml index 558c8175..c4bc14e3 100644 --- a/app/detekt-baseline.xml +++ b/app/detekt-baseline.xml @@ -13,7 +13,7 @@ CyclomaticComplexMethod:FeedNoteCard.kt$@Composable private fun FeedNote( data: FeedPostUi, fullWidthContent: Boolean, avatarSizeDp: Dp, avatarPaddingValues: PaddingValues, notePaddingValues: PaddingValues, enableTweetsMode: Boolean, headerSingleLine: Boolean, showReplyTo: Boolean, forceContentIndent: Boolean, expanded: Boolean, textSelectable: Boolean, showNoteStatCounts: Boolean, noteCallbacks: NoteCallbacks, onPostAction: ((FeedPostAction) -> Unit)? = null, onPostLongClickAction: ((FeedPostAction) -> Unit)? = null, contentFooter: @Composable () -> Unit = {}, ) CyclomaticComplexMethod:FeedNoteCard.kt$@ExperimentalMaterial3Api @Composable private fun FeedNoteCard( data: FeedPostUi, state: NoteContract.UiState, eventPublisher: (UiEvent) -> Unit, modifier: Modifier = Modifier, shape: Shape = CardDefaults.shape, colors: CardColors = noteCardColors(), cardPadding: PaddingValues = PaddingValues(all = 0.dp), enableTweetsMode: Boolean = false, headerSingleLine: Boolean = true, fullWidthContent: Boolean = false, forceContentIndent: Boolean = false, drawLineAboveAvatar: Boolean = false, drawLineBelowAvatar: Boolean = false, expanded: Boolean = false, textSelectable: Boolean = false, showReplyTo: Boolean = true, noteOptionsMenuEnabled: Boolean = true, showNoteStatCounts: Boolean = true, noteCallbacks: NoteCallbacks = NoteCallbacks(), onGoToWallet: (() -> Unit)? = null, contentFooter: @Composable () -> Unit = {}, ) CyclomaticComplexMethod:MessagesRemoteMediator.kt$MessagesRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState<Int, DirectMessage>): MediatorResult - CyclomaticComplexMethod:NostrUserText.kt$@Composable fun NostrUserText( displayName: String, internetIdentifier: String?, modifier: Modifier = Modifier, displayNameColor: Color = AppTheme.colorScheme.onSurface, fontSize: TextUnit = TextUnit.Unspecified, style: TextStyle = LocalTextStyle.current, overflow: TextOverflow = TextOverflow.Ellipsis, maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, authorLegendaryCustomization: LegendaryCustomization? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) + CyclomaticComplexMethod:NostrUserText.kt$@Composable fun NostrUserText( displayName: String, internetIdentifier: String?, modifier: Modifier = Modifier, displayNameColor: Color = AppTheme.colorScheme.onSurface, fontSize: TextUnit = TextUnit.Unspecified, style: TextStyle = LocalTextStyle.current, overflow: TextOverflow = TextOverflow.Ellipsis, maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, legendaryCustomization: LegendaryCustomization? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) CyclomaticComplexMethod:NoteActionsRow.kt$@Composable fun FeedNoteActionsRow( modifier: Modifier, eventStats: EventStatsUi, isBookmarked: Boolean, highlightedNote: Boolean = false, showBookmark: Boolean = false, showCounts: Boolean = true, onPostAction: ((FeedPostAction) -> Unit)? = null, onPostLongPressAction: ((FeedPostAction) -> Unit)? = null, ) CyclomaticComplexMethod:NoteContent.kt$@OptIn(ExperimentalFoundationApi::class) @Composable fun NoteContent( modifier: Modifier = Modifier, data: NoteContentUi, expanded: Boolean, noteCallbacks: NoteCallbacks, maxLines: Int = Int.MAX_VALUE, overflow: TextOverflow = TextOverflow.Clip, enableTweetsMode: Boolean = false, textSelectable: Boolean = false, referencedEventsHaveBorder: Boolean = false, highlightColor: Color = AppTheme.colorScheme.secondary, contentColor: Color = AppTheme.colorScheme.onSurface, referencedEventsContainerColor: Color = AppTheme.extraColorScheme.surfaceVariantAlt1, onClick: ((offset: Offset) -> Unit)? = null, onUrlClick: ((url: String) -> Unit)? = null, ) CyclomaticComplexMethod:NoteFeedLazyColumn.kt$@ExperimentalMaterial3Api @ExperimentalFoundationApi @Composable fun NoteFeedLazyColumn( modifier: Modifier = Modifier, pagingItems: LazyPagingItems<FeedPostUi>, listState: LazyListState, showPaywall: Boolean, noteCallbacks: NoteCallbacks, onGoToWallet: () -> Unit, showTopZaps: Boolean = false, shouldShowLoadingState: Boolean = true, shouldShowNoContentState: Boolean = true, showReplyTo: Boolean = true, noContentVerticalArrangement: Arrangement.Vertical = Arrangement.Center, noContentPaddingValues: PaddingValues = PaddingValues(all = 0.dp), noContentText: String = stringResource(id = R.string.feed_no_content), contentPadding: PaddingValues = PaddingValues(all = 0.dp), header: @Composable (LazyItemScope.() -> Unit)? = null, stickyHeader: @Composable (LazyItemScope.() -> Unit)? = null, onUiError: ((UiError) -> Unit)? = null, ) @@ -54,7 +54,7 @@ LongMethod:MessageConversationListScreen.kt$@Composable private fun ConversationListItem( conversation: MessageConversationUi, onConversationClick: (String) -> Unit, onProfileClick: (profileId: String) -> Unit, ) LongMethod:MessageConversationListScreen.kt$@Composable private fun MessagesTabs( relation: ConversationRelation, onFollowsTabClick: () -> Unit, onOtherTabClick: () -> Unit, onMarkAllRead: () -> Unit, ) LongMethod:MultipleUserPicker.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun MultipleUserPicker( modifier: Modifier = Modifier, sheetTitle: String, placeholderText: String, onDismissRequest: () -> Unit, onUsersSelected: (Set<UserProfileItemUi>) -> Unit, sheetState: SheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true), startingSelectedUsers: Set<UserProfileItemUi>, ) - LongMethod:NostrUserText.kt$@Composable fun NostrUserText( displayName: String, internetIdentifier: String?, modifier: Modifier = Modifier, displayNameColor: Color = AppTheme.colorScheme.onSurface, fontSize: TextUnit = TextUnit.Unspecified, style: TextStyle = LocalTextStyle.current, overflow: TextOverflow = TextOverflow.Ellipsis, maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, authorLegendaryCustomization: LegendaryCustomization? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) + LongMethod:NostrUserText.kt$@Composable fun NostrUserText( displayName: String, internetIdentifier: String?, modifier: Modifier = Modifier, displayNameColor: Color = AppTheme.colorScheme.onSurface, fontSize: TextUnit = TextUnit.Unspecified, style: TextStyle = LocalTextStyle.current, overflow: TextOverflow = TextOverflow.Ellipsis, maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, legendaryCustomization: LegendaryCustomization? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) LongMethod:NoteActionsRow.kt$@Composable fun FeedNoteActionsRow( modifier: Modifier, eventStats: EventStatsUi, isBookmarked: Boolean, highlightedNote: Boolean = false, showBookmark: Boolean = false, showCounts: Boolean = true, onPostAction: ((FeedPostAction) -> Unit)? = null, onPostLongPressAction: ((FeedPostAction) -> Unit)? = null, ) LongMethod:NoteContent.kt$@OptIn(ExperimentalFoundationApi::class) @Composable fun NoteContent( modifier: Modifier = Modifier, data: NoteContentUi, expanded: Boolean, noteCallbacks: NoteCallbacks, maxLines: Int = Int.MAX_VALUE, overflow: TextOverflow = TextOverflow.Clip, enableTweetsMode: Boolean = false, textSelectable: Boolean = false, referencedEventsHaveBorder: Boolean = false, highlightColor: Color = AppTheme.colorScheme.secondary, contentColor: Color = AppTheme.colorScheme.onSurface, referencedEventsContainerColor: Color = AppTheme.extraColorScheme.surfaceVariantAlt1, onClick: ((offset: Offset) -> Unit)? = null, onUrlClick: ((url: String) -> Unit)? = null, ) LongMethod:NoteDropdownMenu.kt$@Composable fun NoteDropdownMenuIcon( modifier: Modifier, noteId: String, noteContent: String, noteRawData: String, authorId: String, isBookmarked: Boolean, enabled: Boolean = true, onBookmarkClick: (() -> Unit)? = null, onMuteUserClick: (() -> Unit)? = null, onReportContentClick: (() -> Unit)? = null, ) @@ -109,6 +109,7 @@ MagicNumber:PrimalDrawer.kt$0.5f MagicNumber:PrimalDrawerScaffold.kt$0.5f MatchingDeclarationName:__PrimalIcons.kt$PrimalIcons + MaxLineLength:LegendaryProfileCustomizationScreen.kt$legendaryCustomization = customBadge?.let { LegendaryCustomization(customBadge = it, legendaryStyle = selectedStyle) } ReturnCount:LnInvoiceUtils.kt$LnInvoiceUtils$private fun getAmount(invoice: String): BigDecimal ReturnCount:MessagesRemoteMediator.kt$MessagesRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState<Int, DirectMessage>): MediatorResult ReturnCount:NostrResources.kt$private fun String.nostrUriToBytes(): ByteArray? diff --git a/app/src/main/kotlin/net/primal/android/core/compose/NostrUserText.kt b/app/src/main/kotlin/net/primal/android/core/compose/NostrUserText.kt index ec54e096..d4700978 100644 --- a/app/src/main/kotlin/net/primal/android/core/compose/NostrUserText.kt +++ b/app/src/main/kotlin/net/primal/android/core/compose/NostrUserText.kt @@ -58,14 +58,14 @@ fun NostrUserText( maxLines: Int = 1, internetIdentifierBadgeSize: Dp = 14.dp, internetIdentifierBadgeAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Center, - authorLegendaryCustomization: LegendaryCustomization? = null, + legendaryCustomization: LegendaryCustomization? = null, annotatedStringPrefixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, annotatedStringSuffixBuilder: (AnnotatedString.Builder.() -> Unit)? = null, ) { val verifiedBadge = !internetIdentifier.isNullOrEmpty() - val customBadgeStyle = if (authorLegendaryCustomization?.customBadge == true) { - authorLegendaryCustomization.legendaryStyle + val customBadgeStyle = if (legendaryCustomization?.customBadge == true) { + legendaryCustomization.legendaryStyle } else { null } @@ -163,7 +163,7 @@ fun PreviewNostrUserTextWithPrimalBadge() { annotatedStringSuffixBuilder = { append("• 42 y. ago") }, - authorLegendaryCustomization = null, + legendaryCustomization = null, ) } } @@ -180,7 +180,7 @@ fun PreviewNostrUserTextWithRandomBadge() { annotatedStringSuffixBuilder = { append("• 42 y. ago") }, - authorLegendaryCustomization = null, + legendaryCustomization = null, ) } } @@ -197,7 +197,7 @@ fun PreviewNostrUserTextWithoutBadge() { annotatedStringSuffixBuilder = { append(" • 42 y. ago") }, - authorLegendaryCustomization = null, + legendaryCustomization = null, ) } } @@ -214,7 +214,7 @@ fun PreviewNostrUserTextWithCustomBadge() { annotatedStringSuffixBuilder = { append(" • 42 y. ago") }, - authorLegendaryCustomization = LegendaryCustomization( + legendaryCustomization = LegendaryCustomization( customBadge = true, avatarGlow = true, legendaryStyle = LegendaryStyle.GOLD, diff --git a/app/src/main/kotlin/net/primal/android/drawer/PrimalDrawer.kt b/app/src/main/kotlin/net/primal/android/drawer/PrimalDrawer.kt index b7593765..a52f2dd4 100644 --- a/app/src/main/kotlin/net/primal/android/drawer/PrimalDrawer.kt +++ b/app/src/main/kotlin/net/primal/android/drawer/PrimalDrawer.kt @@ -175,7 +175,7 @@ private fun DrawerHeader( top.linkTo(avatarRef.bottom, margin = 16.dp) width = Dimension.preferredValue(220.dp) }, - authorLegendaryCustomization = legendaryCustomization, + legendaryCustomization = legendaryCustomization, ) IconButton( diff --git a/app/src/main/kotlin/net/primal/android/explore/home/people/ExplorePeople.kt b/app/src/main/kotlin/net/primal/android/explore/home/people/ExplorePeople.kt index cbf5e39e..815b6b27 100644 --- a/app/src/main/kotlin/net/primal/android/explore/home/people/ExplorePeople.kt +++ b/app/src/main/kotlin/net/primal/android/explore/home/people/ExplorePeople.kt @@ -199,7 +199,7 @@ private fun ExplorePersonListItem( NostrUserText( displayName = person.profile.userDisplayName, internetIdentifier = person.profile.internetIdentifier, - authorLegendaryCustomization = person.profile.premiumDetails?.legendaryCustomization, + legendaryCustomization = person.profile.premiumDetails?.legendaryCustomization, ) person.profile.internetIdentifier?.let { Text( diff --git a/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListScreen.kt b/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListScreen.kt index bfd7e417..42b3a1dd 100644 --- a/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListScreen.kt +++ b/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListScreen.kt @@ -312,7 +312,7 @@ private fun ConversationListItem( displayName = conversation.participantUsername, internetIdentifier = conversation.participantInternetIdentifier, annotatedStringSuffixBuilder = { append(suffixText) }, - authorLegendaryCustomization = conversation.participantLegendaryCustomization, + legendaryCustomization = conversation.participantLegendaryCustomization, style = AppTheme.typography.bodyMedium, ) } diff --git a/app/src/main/kotlin/net/primal/android/notes/feed/note/ui/NoteHeader.kt b/app/src/main/kotlin/net/primal/android/notes/feed/note/ui/NoteHeader.kt index f35f6c63..149da112 100644 --- a/app/src/main/kotlin/net/primal/android/notes/feed/note/ui/NoteHeader.kt +++ b/app/src/main/kotlin/net/primal/android/notes/feed/note/ui/NoteHeader.kt @@ -141,7 +141,7 @@ private fun NoteAuthorBadgeAndTimestampSection( style = topRowTextStyle, internetIdentifierBadgeSize = topRowTextStyle.fontSize.value.dp, overflow = TextOverflow.Ellipsis, - authorLegendaryCustomization = authorLegendaryCustomization, + legendaryCustomization = authorLegendaryCustomization, ) }, suffixFixedContent = { diff --git a/app/src/main/kotlin/net/primal/android/notifications/list/ui/NotificationListItem.kt b/app/src/main/kotlin/net/primal/android/notifications/list/ui/NotificationListItem.kt index 26436dea..f1e06c0c 100644 --- a/app/src/main/kotlin/net/primal/android/notifications/list/ui/NotificationListItem.kt +++ b/app/src/main/kotlin/net/primal/android/notifications/list/ui/NotificationListItem.kt @@ -422,6 +422,7 @@ private fun HeaderContent( if (firstNotification.actionUserInternetIdentifier.isNullOrEmpty()) append(' ') append(appendText) }, + legendaryCustomization = firstNotification.actionUserLegendaryCustomization, ) } diff --git a/app/src/main/kotlin/net/primal/android/premium/buying/purchase/PremiumPurchaseStage.kt b/app/src/main/kotlin/net/primal/android/premium/buying/purchase/PremiumPurchaseStage.kt index 013a8d5e..2f1f89b1 100644 --- a/app/src/main/kotlin/net/primal/android/premium/buying/purchase/PremiumPurchaseStage.kt +++ b/app/src/main/kotlin/net/primal/android/premium/buying/purchase/PremiumPurchaseStage.kt @@ -129,6 +129,7 @@ fun PremiumPurchaseStage( internetIdentifier = "${state.primalName}@primal.net", internetIdentifierBadgeSize = 24.dp, fontSize = 20.sp, + legendaryCustomization = state.profile.premiumDetails?.legendaryCustomization, ) if (!state.isExtendingPremium) { Text( diff --git a/app/src/main/kotlin/net/primal/android/premium/home/PremiumHomeScreen.kt b/app/src/main/kotlin/net/primal/android/premium/home/PremiumHomeScreen.kt index 296167ac..e8ab44b1 100644 --- a/app/src/main/kotlin/net/primal/android/premium/home/PremiumHomeScreen.kt +++ b/app/src/main/kotlin/net/primal/android/premium/home/PremiumHomeScreen.kt @@ -147,7 +147,7 @@ private fun PremiumHomeScreen( internetIdentifier = "$primalName@primal.net", internetIdentifierBadgeSize = 24.dp, fontSize = 20.sp, - authorLegendaryCustomization = state.avatarLegendaryCustomization, + legendaryCustomization = state.avatarLegendaryCustomization, ) } diff --git a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt index 601a0f31..a8603845 100644 --- a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt +++ b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt @@ -102,7 +102,7 @@ fun BecomeLegendAmountStage( internetIdentifier = "${state.primalName}@primal.net", internetIdentifierBadgeSize = 24.dp, fontSize = 20.sp, - authorLegendaryCustomization = LegendaryCustomization( + legendaryCustomization = LegendaryCustomization( customBadge = true, legendaryStyle = LegendaryStyle.GOLD, ), diff --git a/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt b/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt index 72b77bc8..0c6d5ba0 100644 --- a/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt +++ b/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt @@ -145,11 +145,11 @@ fun LegendaryProfileCustomizationScreen( displayName = primalName, internetIdentifier = "$primalName@primal.net", internetIdentifierBadgeSize = 24.dp, - authorLegendaryCustomization = - if (customBadge == true) { - LegendaryCustomization(customBadge = true, legendaryStyle = selectedStyle) - } else { - null + legendaryCustomization = customBadge?.let { + LegendaryCustomization( + customBadge = it, + legendaryStyle = selectedStyle, + ) }, fontSize = 20.sp, ) diff --git a/app/src/main/kotlin/net/primal/android/premium/manage/nameChange/ConfirmNameChangeStage.kt b/app/src/main/kotlin/net/primal/android/premium/manage/nameChange/ConfirmNameChangeStage.kt index ed039c7f..80b304f2 100644 --- a/app/src/main/kotlin/net/primal/android/premium/manage/nameChange/ConfirmNameChangeStage.kt +++ b/app/src/main/kotlin/net/primal/android/premium/manage/nameChange/ConfirmNameChangeStage.kt @@ -46,7 +46,7 @@ fun ConfirmNameChangeStage( internetIdentifier = "$primalName@primal.net", internetIdentifierBadgeSize = 24.dp, fontSize = 20.sp, - authorLegendaryCustomization = profileLegendaryCustomization, + legendaryCustomization = profileLegendaryCustomization, ) Text( modifier = Modifier.padding(horizontal = 12.dp), diff --git a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt index e8f62812..1930c316 100644 --- a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt +++ b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileDetailsHeader.kt @@ -355,7 +355,7 @@ private fun UserDisplayName( lineHeight = 20.sp, fontWeight = FontWeight.Bold, ), - authorLegendaryCustomization = profilePremiumDetails?.legendaryCustomization, + legendaryCustomization = profilePremiumDetails?.legendaryCustomization, ) val isPremiumBadgeClickable = activeUserPremiumTier == null || diff --git a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileTopCoverBar.kt b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileTopCoverBar.kt index a5dd71b1..ad9678ae 100644 --- a/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileTopCoverBar.kt +++ b/app/src/main/kotlin/net/primal/android/profile/details/ui/ProfileTopCoverBar.kt @@ -184,7 +184,7 @@ private fun ProfileTopAppBar( internetIdentifier = state.profileDetails?.internetIdentifier, internetIdentifierBadgeSize = 20.dp, internetIdentifierBadgeAlign = PlaceholderVerticalAlign.Center, - authorLegendaryCustomization = state.profileDetails?.premiumDetails?.legendaryCustomization, + legendaryCustomization = state.profileDetails?.premiumDetails?.legendaryCustomization, ) } }, diff --git a/app/src/main/kotlin/net/primal/android/settings/muted/list/MutedSettingsScreen.kt b/app/src/main/kotlin/net/primal/android/settings/muted/list/MutedSettingsScreen.kt index f5c793f7..af15c1b2 100644 --- a/app/src/main/kotlin/net/primal/android/settings/muted/list/MutedSettingsScreen.kt +++ b/app/src/main/kotlin/net/primal/android/settings/muted/list/MutedSettingsScreen.kt @@ -130,6 +130,7 @@ fun MutedUserListItem( displayName = item.displayName, fontSize = 14.sp, internetIdentifier = item.internetIdentifier, + legendaryCustomization = item.legendaryCustomization, ) }, supportingContent = { diff --git a/app/src/main/kotlin/net/primal/android/stats/reactions/ui/GenericReactionsLazyColumn.kt b/app/src/main/kotlin/net/primal/android/stats/reactions/ui/GenericReactionsLazyColumn.kt index 9f2e5701..e9843c1c 100644 --- a/app/src/main/kotlin/net/primal/android/stats/reactions/ui/GenericReactionsLazyColumn.kt +++ b/app/src/main/kotlin/net/primal/android/stats/reactions/ui/GenericReactionsLazyColumn.kt @@ -86,7 +86,7 @@ private fun GenericReactionListItem( NostrUserText( displayName = item.profile.authorDisplayName, internetIdentifier = item.profile.internetIdentifier, - authorLegendaryCustomization = item.profile.premiumDetails?.legendaryCustomization, + legendaryCustomization = item.profile.premiumDetails?.legendaryCustomization, ) }, trailingContent = { diff --git a/app/src/main/kotlin/net/primal/android/stats/reactions/ui/ReactionsZapsLazyColumn.kt b/app/src/main/kotlin/net/primal/android/stats/reactions/ui/ReactionsZapsLazyColumn.kt index a45fe74a..00076a3d 100644 --- a/app/src/main/kotlin/net/primal/android/stats/reactions/ui/ReactionsZapsLazyColumn.kt +++ b/app/src/main/kotlin/net/primal/android/stats/reactions/ui/ReactionsZapsLazyColumn.kt @@ -92,7 +92,7 @@ private fun NoteZapListItem(data: EventZapUiModel, onProfileClick: (profileId: S NostrUserText( displayName = data.zapperName, internetIdentifier = data.zapperInternetIdentifier, - authorLegendaryCustomization = data.zapperLegendaryCustomization, + legendaryCustomization = data.zapperLegendaryCustomization, ) }, supportingContent = { diff --git a/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/ArticleAuthorRow.kt b/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/ArticleAuthorRow.kt index 50be1bca..fc6227aa 100644 --- a/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/ArticleAuthorRow.kt +++ b/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/ArticleAuthorRow.kt @@ -72,7 +72,7 @@ fun ArticleAuthorRow( fontSize = 16.sp, lineHeight = 16.sp, ), - authorLegendaryCustomization = authorLegendaryCustomization, + legendaryCustomization = authorLegendaryCustomization, ) if (!authorInternetIdentifier.isNullOrBlank()) { diff --git a/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/HighlightActivityBottomSheet.kt b/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/HighlightActivityBottomSheet.kt index 1a8f1c18..1c4eaa16 100644 --- a/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/HighlightActivityBottomSheet.kt +++ b/app/src/main/kotlin/net/primal/android/thread/articles/details/ui/HighlightActivityBottomSheet.kt @@ -155,7 +155,7 @@ fun CommentRow(modifier: Modifier = Modifier, comment: CommentUi) { modifier = Modifier.padding(start = 8.dp), displayName = comment.authorDisplayName ?: "", internetIdentifier = comment.authorInternetIdentifier, - authorLegendaryCustomization = comment.authorLegendaryCustomization, + legendaryCustomization = comment.authorLegendaryCustomization, ) Text( text = stringResource(id = R.string.article_details_highlight_activity_commented), From 0668491838e7ff8abeac574019ef6f5dfb89d924 Mon Sep 17 00:00:00 2001 From: Mehmedalija Karisik Date: Fri, 20 Dec 2024 01:47:04 +0100 Subject: [PATCH 5/5] Refactor legendaryCustomization with let --- app/detekt-baseline.xml | 1 - .../LegendaryProfileCustomizationScreen.kt | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/detekt-baseline.xml b/app/detekt-baseline.xml index c4bc14e3..73e6c6dc 100644 --- a/app/detekt-baseline.xml +++ b/app/detekt-baseline.xml @@ -109,7 +109,6 @@ MagicNumber:PrimalDrawer.kt$0.5f MagicNumber:PrimalDrawerScaffold.kt$0.5f MatchingDeclarationName:__PrimalIcons.kt$PrimalIcons - MaxLineLength:LegendaryProfileCustomizationScreen.kt$legendaryCustomization = customBadge?.let { LegendaryCustomization(customBadge = it, legendaryStyle = selectedStyle) } ReturnCount:LnInvoiceUtils.kt$LnInvoiceUtils$private fun getAmount(invoice: String): BigDecimal ReturnCount:MessagesRemoteMediator.kt$MessagesRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState<Int, DirectMessage>): MediatorResult ReturnCount:NostrResources.kt$private fun String.nostrUriToBytes(): ByteArray? diff --git a/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt b/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt index 0c6d5ba0..b2ca335f 100644 --- a/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt +++ b/app/src/main/kotlin/net/primal/android/premium/legend/custimization/LegendaryProfileCustomizationScreen.kt @@ -145,12 +145,10 @@ fun LegendaryProfileCustomizationScreen( displayName = primalName, internetIdentifier = "$primalName@primal.net", internetIdentifierBadgeSize = 24.dp, - legendaryCustomization = customBadge?.let { - LegendaryCustomization( - customBadge = it, - legendaryStyle = selectedStyle, - ) - }, + legendaryCustomization = LegendaryCustomization( + customBadge = customBadge == true, + legendaryStyle = selectedStyle, + ), fontSize = 20.sp, ) }