Skip to content

Commit 71801b3

Browse files
committed
Fix some detekt issues
1 parent 0391512 commit 71801b3

File tree

5 files changed

+65
-45
lines changed

5 files changed

+65
-45
lines changed

app/src/main/kotlin/net/primal/android/core/compose/AvatarThumbnailListItemImage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private fun AvatarThumbnailListItemImage(
144144
listOf(AppTheme.colorScheme.primary, AppTheme.colorScheme.primary),
145145
),
146146
borderSize: Dp = 2.dp,
147-
hasGlow: Boolean = false,
147+
@Suppress("UnusedParameter") hasGlow: Boolean = false,
148148
backgroundColor: Color = AppTheme.extraColorScheme.surfaceVariantAlt1,
149149
onClick: (() -> Unit)? = null,
150150
defaultAvatar: @Composable () -> Unit,

app/src/main/kotlin/net/primal/android/drawer/PrimalDrawer.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import net.primal.android.core.compose.icons.primaliconpack.LightMode
6060
import net.primal.android.core.compose.icons.primaliconpack.QrCode
6161
import net.primal.android.core.compose.preview.PrimalPreview
6262
import net.primal.android.core.utils.formatNip05Identifier
63+
import net.primal.android.premium.legend.LegendaryCustomization
6364
import net.primal.android.premium.legend.LegendaryStyle
6465
import net.primal.android.premium.legend.asLegendaryCustomization
6566
import net.primal.android.theme.AppTheme
@@ -118,10 +119,8 @@ fun PrimalDrawer(
118119
) {
119120
DrawerHeader(
120121
userAccount = state.activeUserAccount,
121-
customBadge = state.customBadge,
122-
avatarGlow = state.avatarGlow,
123-
legendaryStyle = state.legendaryStyle,
124122
onQrCodeClick = onQrCodeClick,
123+
legendaryCustomization = state.legendaryCustomization,
125124
)
126125

127126
DrawerMenu(
@@ -150,9 +149,7 @@ fun PrimalDrawer(
150149
@Composable
151150
private fun DrawerHeader(
152151
userAccount: UserAccount?,
153-
customBadge: Boolean,
154-
avatarGlow: Boolean,
155-
legendaryStyle: LegendaryStyle?,
152+
legendaryCustomization: LegendaryCustomization?,
156153
onQrCodeClick: () -> Unit,
157154
) {
158155
val numberFormat = remember { NumberFormat.getNumberInstance() }
@@ -169,7 +166,7 @@ private fun DrawerHeader(
169166
},
170167
avatarSize = 52.dp,
171168
avatarCdnImage = userAccount?.avatarCdnImage,
172-
legendaryCustomization = userAccount?.primalLegendProfile?.asLegendaryCustomization(),
169+
legendaryCustomization = legendaryCustomization,
173170
)
174171

175172
NostrUserText(
@@ -181,7 +178,11 @@ private fun DrawerHeader(
181178
top.linkTo(avatarRef.bottom, margin = 16.dp)
182179
width = Dimension.preferredValue(220.dp)
183180
},
184-
customBadgeStyle = if (customBadge) legendaryStyle else null,
181+
customBadgeStyle = if (legendaryCustomization?.customBadge == true) {
182+
legendaryCustomization.legendaryStyle
183+
} else {
184+
null
185+
},
185186
)
186187

187188
IconButton(

app/src/main/kotlin/net/primal/android/drawer/PrimalDrawerContract.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.primal.android.drawer
22

3+
import net.primal.android.premium.legend.LegendaryCustomization
34
import net.primal.android.premium.legend.LegendaryStyle
45
import net.primal.android.user.domain.Badges
56
import net.primal.android.user.domain.UserAccount
@@ -12,9 +13,7 @@ interface PrimalDrawerContract {
1213
val activeUserAccount: UserAccount? = null,
1314
val badges: Badges = Badges(),
1415
val showPremiumBadge: Boolean = false,
15-
val customBadge: Boolean = false,
16-
val avatarGlow: Boolean = false,
17-
val legendaryStyle: LegendaryStyle? = null,
16+
val legendaryCustomization: LegendaryCustomization? = null,
1817
)
1918

2019
sealed class UiEvent {

app/src/main/kotlin/net/primal/android/drawer/PrimalDrawerViewModel.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.firstOrNull
1414
import kotlinx.coroutines.flow.getAndUpdate
1515
import kotlinx.coroutines.launch
1616
import net.primal.android.premium.legend.LegendaryStyle
17+
import net.primal.android.premium.legend.asLegendaryCustomization
1718
import net.primal.android.profile.repository.ProfileRepository
1819
import net.primal.android.theme.active.ActiveThemeStore
1920
import net.primal.android.theme.domain.PrimalTheme
@@ -82,9 +83,7 @@ class PrimalDrawerViewModel @Inject constructor(
8283
profileRepository.observeProfile(profileId = activeAccountStore.activeUserId()).collect {
8384
setState {
8485
copy(
85-
avatarGlow = it.metadata?.primalLegendProfile?.avatarGlow == true,
86-
customBadge = it.metadata?.primalLegendProfile?.customBadge == true,
87-
legendaryStyle = LegendaryStyle.valueById(it.metadata?.primalLegendProfile?.styleId),
86+
legendaryCustomization = it.metadata?.primalLegendProfile?.asLegendaryCustomization(),
8887
)
8988
}
9089
}

app/src/main/kotlin/net/primal/android/notes/feed/note/ui/NoteHeader.kt

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -88,36 +88,14 @@ fun FeedNoteHeader(
8888
)
8989
}
9090

91-
WrappedContentWithSuffix(
92-
wrappedContent = {
93-
NostrUserText(
94-
displayName = authorDisplayName,
95-
internetIdentifier = authorInternetIdentifier,
96-
annotatedStringSuffixBuilder = {
97-
append(suffixText)
98-
},
99-
style = topRowTextStyle,
100-
internetIdentifierBadgeSize = topRowTextStyle.fontSize.value.dp,
101-
overflow = TextOverflow.Ellipsis,
102-
customBadgeStyle = if (authorLegendaryCustomization?.customBadge == true) {
103-
authorLegendaryCustomization.legendaryStyle
104-
} else {
105-
null
106-
},
107-
)
108-
},
109-
suffixFixedContent = {
110-
if (postTimestamp != null) {
111-
Text(
112-
text = "${postTimestamp.asBeforeNowFormat()}",
113-
textAlign = TextAlign.Center,
114-
maxLines = 1,
115-
style = topRowTextStyle,
116-
fontSize = (displaySettings.contentAppearance.noteUsernameSize.value).sp,
117-
color = AppTheme.extraColorScheme.onSurfaceVariantAlt2,
118-
)
119-
}
120-
},
91+
NoteAuthorBadgeAndTimestampSection(
92+
authorDisplayName = authorDisplayName,
93+
authorInternetIdentifier = authorInternetIdentifier,
94+
suffixText = suffixText,
95+
topRowTextStyle = topRowTextStyle,
96+
authorLegendaryCustomization = authorLegendaryCustomization,
97+
postTimestamp = postTimestamp,
98+
displaySettings = displaySettings,
12199
)
122100

123101
if (!label.isNullOrEmpty() && !singleLine) {
@@ -142,6 +120,49 @@ fun FeedNoteHeader(
142120
}
143121
}
144122

123+
@Composable
124+
private fun NoteAuthorBadgeAndTimestampSection(
125+
authorDisplayName: String,
126+
authorInternetIdentifier: String?,
127+
suffixText: AnnotatedString,
128+
topRowTextStyle: TextStyle,
129+
authorLegendaryCustomization: LegendaryCustomization?,
130+
postTimestamp: Instant?,
131+
displaySettings: ContentDisplaySettings,
132+
) {
133+
WrappedContentWithSuffix(
134+
wrappedContent = {
135+
NostrUserText(
136+
displayName = authorDisplayName,
137+
internetIdentifier = authorInternetIdentifier,
138+
annotatedStringSuffixBuilder = {
139+
append(suffixText)
140+
},
141+
style = topRowTextStyle,
142+
internetIdentifierBadgeSize = topRowTextStyle.fontSize.value.dp,
143+
overflow = TextOverflow.Ellipsis,
144+
customBadgeStyle = if (authorLegendaryCustomization?.customBadge == true) {
145+
authorLegendaryCustomization.legendaryStyle
146+
} else {
147+
null
148+
},
149+
)
150+
},
151+
suffixFixedContent = {
152+
if (postTimestamp != null) {
153+
Text(
154+
text = "${postTimestamp.asBeforeNowFormat()}",
155+
textAlign = TextAlign.Center,
156+
maxLines = 1,
157+
style = topRowTextStyle,
158+
fontSize = (displaySettings.contentAppearance.noteUsernameSize.value).sp,
159+
color = AppTheme.extraColorScheme.onSurfaceVariantAlt2,
160+
)
161+
}
162+
},
163+
)
164+
}
165+
145166
@Preview
146167
@Composable
147168
fun PreviewLightNoteHeader() {

0 commit comments

Comments
 (0)