From 1557f29ece7fadc5b9157b5c7b6217286de0cecf Mon Sep 17 00:00:00 2001 From: Diego Beraldin Date: Wed, 7 Feb 2024 22:59:26 +0100 Subject: [PATCH] feat: configure comment bar width; prefer nicknames (#511) --- .../repository/DefaultThemeRepository.kt | 9 +- .../appearance/repository/ThemeRepository.kt | 6 +- .../commonui/lemmyui/CollapsedCommentCard.kt | 2 + .../core/commonui/lemmyui/CommentCard.kt | 5 +- .../lemmyui/CommunityAndCreatorInfo.kt | 5 +- .../core/commonui/lemmyui/CommunityHeader.kt | 11 +- .../core/commonui/lemmyui/CommunityItem.kt | 9 +- .../core/commonui/lemmyui/InboxCard.kt | 2 + .../commonui/lemmyui/InboxReplySubtitle.kt | 5 +- .../core/commonui/lemmyui/PostCard.kt | 7 ++ .../core/commonui/lemmyui/UserHeader.kt | 9 +- .../core/commonui/lemmyui/UserItem.kt | 7 +- .../modals/CommentBarThicknessBottomSheet.kt | 101 ++++++++++++++++++ .../notifications/NotificationCenterEvent.kt | 1 + .../core/persistence/data/SettingsModel.kt | 2 + .../repository/DefaultSettingsRepository.kt | 12 +++ .../core/persistence/settings.sq | 14 ++- .../commonMain/sqldelight/migrations/24.sqm | 5 + .../domain/lemmy/data/CommunityModel.kt | 11 +- .../domain/lemmy/data/UserModel.kt | 11 +- .../feature/search/main/ExploreMviModel.kt | 1 + .../feature/search/main/ExploreScreen.kt | 4 + .../feature/search/main/ExploreViewModel.kt | 1 + .../colors/SettingsColorAndFontMviModel.kt | 1 + .../colors/SettingsColorAndFontScreen.kt | 11 ++ .../colors/SettingsColorAndFontViewModel.kt | 21 +++- .../feature/settings/main/SettingsMviModel.kt | 2 + .../feature/settings/main/SettingsScreen.kt | 11 ++ .../settings/main/SettingsViewModel.kt | 13 +++ .../commonMain/resources/MR/base/strings.xml | 2 + .../diegoberaldin/raccoonforlemmy/App.kt | 9 +- .../unit/chat/InboxChatMviModel.kt | 1 + .../unit/chat/InboxChatViewModel.kt | 7 +- .../CommunityDetailMviModel.kt | 1 + .../communitydetail/CommunityDetailScreen.kt | 1 + .../CommunityDetailViewModel.kt | 1 + .../communityinfo/CommunityInfoMviModel.kt | 1 + .../unit/communityinfo/CommunityInfoScreen.kt | 5 +- .../createcomment/CreateCommentMviModel.kt | 1 + .../unit/createcomment/CreateCommentScreen.kt | 2 + .../createcomment/CreateCommentViewModel.kt | 1 + .../unit/createpost/CreatePostMviModel.kt | 1 + .../unit/createpost/CreatePostScreen.kt | 1 + .../unit/createpost/CreatePostViewModel.kt | 4 +- .../unit/drawer/ModalDrawerContent.kt | 1 + .../unit/drawer/ModalDrawerMviModel.kt | 2 +- .../unit/drawer/ModalDrawerViewModel.kt | 9 +- .../unit/instanceinfo/InstanceInfoMviModel.kt | 1 + .../unit/instanceinfo/InstanceInfoScreen.kt | 1 + .../instanceinfo/InstanceInfoViewModel.kt | 7 +- .../manageaccounts/ManageAccountsMviModel.kt | 1 + .../manageaccounts/ManageAccountsViewModel.kt | 7 +- .../unit/manageban/ManageBanMviModel.kt | 1 + .../unit/manageban/ManageBanScreen.kt | 2 + .../unit/manageban/ManageBanViewModel.kt | 7 +- .../ManageSubscriptionsMviModel.kt | 1 + .../ManageSubscriptionsViewModel.kt | 7 +- .../unit/mentions/InboxMentionsMviModel.kt | 1 + .../unit/mentions/InboxMentionsScreen.kt | 1 + .../unit/mentions/InboxMentionsViewModel.kt | 1 + .../raccoonforlemmy/unit/messages/ChatCard.kt | 3 +- .../unit/messages/InboxMessagesMviModel.kt | 1 + .../unit/messages/InboxMessagesViewModel.kt | 7 +- .../unit/modlog/ModlogMviModel.kt | 1 + .../unit/modlog/ModlogViewModel.kt | 1 + .../unit/modlog/components/InnerModlogItem.kt | 5 +- .../unit/modlog/components/ModAddItem.kt | 4 +- .../components/ModBanFromCommunityItem.kt | 3 +- .../modlog/components/ModFeaturePostItem.kt | 2 + .../unit/modlog/components/ModLockPostItem.kt | 2 + .../modlog/components/ModRemoveCommentItem.kt | 2 + .../modlog/components/ModRemovePostItem.kt | 2 + .../components/ModTransferCommunityItem.kt | 3 +- .../detail/MultiCommunityMviModel.kt | 1 + .../detail/MultiCommunityScreen.kt | 3 +- .../detail/MultiCommunityViewModel.kt | 1 + .../editor/MultiCommunityEditorMviModel.kt | 1 + .../editor/MultiCommunityEditorScreen.kt | 1 + .../editor/MultiCommunityEditorViewModel.kt | 7 +- .../unit/myaccount/ProfileLoggedMviModel.kt | 1 + .../unit/myaccount/ProfileLoggedScreen.kt | 1 + .../unit/myaccount/ProfileLoggedViewModel.kt | 1 + .../unit/postdetail/PostDetailMviModel.kt | 1 + .../unit/postdetail/PostDetailScreen.kt | 4 +- .../unit/postdetail/PostDetailViewModel.kt | 1 + .../unit/postlist/PostListMviModel.kt | 1 + .../unit/postlist/PostListScreen.kt | 5 +- .../unit/postlist/PostListViewModel.kt | 1 + .../unit/replies/InboxRepliesMviModel.kt | 1 + .../unit/replies/InboxRepliesScreen.kt | 1 + .../unit/replies/InboxRepliesViewModel.kt | 1 + .../unit/reportlist/ReportListMviModel.kt | 1 + .../unit/reportlist/ReportListScreen.kt | 2 + .../unit/reportlist/ReportListViewModel.kt | 1 + .../components/CommentReportCard.kt | 2 + .../reportlist/components/InnerReportCard.kt | 5 +- .../reportlist/components/PostReportCard.kt | 2 + .../unit/saveditems/SavedItemsMviModel.kt | 1 + .../unit/saveditems/SavedItemsScreen.kt | 2 + .../unit/saveditems/SavedItemsViewModel.kt | 1 + .../selectcommunity/SelectCommunityDialog.kt | 1 + .../SelectCommunityMviModel.kt | 1 + .../SelectCommunityViewModel.kt | 7 +- .../unit/userdetail/UserDetailMviModel.kt | 1 + .../unit/userdetail/UserDetailScreen.kt | 4 +- .../unit/userdetail/UserDetailViewModel.kt | 1 + .../unit/userinfo/UserInfoMviModel.kt | 1 + .../unit/userinfo/UserInfoScreen.kt | 5 +- 108 files changed, 425 insertions(+), 69 deletions(-) create mode 100644 core/commonui/modals/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/modals/CommentBarThicknessBottomSheet.kt create mode 100644 core/persistence/src/commonMain/sqldelight/migrations/24.sqm diff --git a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/DefaultThemeRepository.kt b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/DefaultThemeRepository.kt index 1928d7197..e0683cb3e 100644 --- a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/DefaultThemeRepository.kt +++ b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/DefaultThemeRepository.kt @@ -24,6 +24,7 @@ internal class DefaultThemeRepository : ThemeRepository { override val saveColor = MutableStateFlow(null) override val postLayout = MutableStateFlow(PostLayout.Card) override val commentBarTheme = MutableStateFlow(CommentBarTheme.Blue) + override val commentBarThickness = MutableStateFlow(1) override fun changeUiTheme(value: UiTheme?) { uiTheme.value = value @@ -66,11 +67,11 @@ internal class DefaultThemeRepository : ThemeRepository { customSeedColor.value = color } - override fun changeUpvoteColor(color: Color?) { + override fun changeUpVoteColor(color: Color?) { upVoteColor.value = color } - override fun changeDownvoteColor(color: Color?) { + override fun changeDownVoteColor(color: Color?) { downVoteColor.value = color } @@ -128,4 +129,8 @@ internal class DefaultThemeRepository : ThemeRepository { this += Color(0xFFFF0000) } } + + override fun changeCommentBarThickness(value: Int) { + commentBarThickness.value = value + } } \ No newline at end of file diff --git a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/ThemeRepository.kt b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/ThemeRepository.kt index 87423f31d..c571d7bbc 100644 --- a/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/ThemeRepository.kt +++ b/core/appearance/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/appearance/repository/ThemeRepository.kt @@ -25,6 +25,7 @@ interface ThemeRepository { val saveColor: StateFlow val postLayout: StateFlow val commentBarTheme: StateFlow + val commentBarThickness: StateFlow fun changeUiTheme(value: UiTheme?) @@ -44,9 +45,9 @@ interface ThemeRepository { fun changeCustomSeedColor(color: Color?) - fun changeUpvoteColor(color: Color?) + fun changeUpVoteColor(color: Color?) - fun changeDownvoteColor(color: Color?) + fun changeDownVoteColor(color: Color?) fun changeReplyColor(color: Color?) fun changeSaveColor(color: Color?) @@ -54,6 +55,7 @@ interface ThemeRepository { fun changePostLayout(value: PostLayout) fun changeCommentBarTheme(value: CommentBarTheme) + fun changeCommentBarThickness(value: Int) fun getCommentBarColors(commentBarTheme: CommentBarTheme): List } diff --git a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CollapsedCommentCard.kt b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CollapsedCommentCard.kt index df258f24b..d2c79ea29 100644 --- a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CollapsedCommentCard.kt +++ b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CollapsedCommentCard.kt @@ -34,6 +34,7 @@ fun CollapsedCommentCard( modifier: Modifier = Modifier, voteFormat: VoteFormat = VoteFormat.Aggregated, autoLoadImages: Boolean = true, + preferNicknames: Boolean = true, showScores: Boolean = true, actionButtonsActive: Boolean = true, isOp: Boolean = false, @@ -83,6 +84,7 @@ fun CollapsedCommentCard( distinguished = comment.distinguished, isOp = isOp, autoLoadImages = autoLoadImages, + preferNicknames = preferNicknames, onToggleExpanded = { onToggleExpanded?.invoke() }, diff --git a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommentCard.kt b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommentCard.kt index 57d08e0de..f84bf4922 100644 --- a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommentCard.kt +++ b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommentCard.kt @@ -50,6 +50,7 @@ fun CommentCard( hideCommunity: Boolean = true, hideIndent: Boolean = false, autoLoadImages: Boolean = true, + preferNicknames: Boolean = true, showScores: Boolean = true, actionButtonsActive: Boolean = true, isOp: Boolean = false, @@ -71,6 +72,7 @@ fun CommentCard( val themeRepository = remember { getThemeRepository() } var commentHeight by remember { mutableStateOf(0f) } val commentBarTheme by themeRepository.commentBarTheme.collectAsState() + val commentBarThickness by themeRepository.commentBarThickness.collectAsState() val barColor = themeRepository.getCommentBarColor( depth = comment.depth, commentBarTheme = commentBarTheme, @@ -103,6 +105,7 @@ fun CommentCard( modifier = Modifier.padding(top = Spacing.xxs), iconSize = IconSize.s, autoLoadImages = autoLoadImages, + preferNicknames = preferNicknames, creator = comment.creator.takeIf { !hideAuthor }, community = comment.community.takeIf { !hideCommunity }, indicatorExpanded = comment.expanded, @@ -170,7 +173,7 @@ fun CommentCard( Box( modifier = Modifier .padding(top = Spacing.xxs) - .width(barWidth) + .width(barWidth * commentBarThickness) .height(commentHeight.toLocalDp()) .background(color = barColor) ) diff --git a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityAndCreatorInfo.kt b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityAndCreatorInfo.kt index f95ebe033..548f453c6 100644 --- a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityAndCreatorInfo.kt +++ b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityAndCreatorInfo.kt @@ -51,6 +51,7 @@ fun CommunityAndCreatorInfo( iconSize: Dp = IconSize.l, indicatorExpanded: Boolean? = null, autoLoadImages: Boolean = true, + preferNicknames: Boolean = true, community: CommunityModel? = null, creator: UserModel? = null, distinguished: Boolean = false, @@ -65,9 +66,9 @@ fun CommunityAndCreatorInfo( onDoubleClick: (() -> Unit)? = null, onLongClick: (() -> Unit)? = null, ) { - val communityName = community?.readableName.orEmpty() + val communityName = community?.readableName(preferNicknames).orEmpty() val communityIcon = community?.icon.orEmpty() - val creatorName = creator?.readableName.orEmpty() + val creatorName = creator?.readableName(preferNicknames).orEmpty() val creatorAvatar = creator?.avatar.orEmpty() val fullColor = MaterialTheme.colorScheme.onBackground val ancillaryColor = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.75f) diff --git a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityHeader.kt b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityHeader.kt index c83b2be0c..a98169585 100644 --- a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityHeader.kt +++ b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityHeader.kt @@ -35,8 +35,8 @@ import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.onClick import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.rememberCallback import com.github.diegoberaldin.raccoonforlemmy.core.utils.getPrettyNumber import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommunityModel +import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.readableHandle import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.readableName -import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.readableSimpleName import com.github.diegoberaldin.raccoonforlemmy.resources.MR import dev.icerock.moko.resources.compose.stringResource @@ -45,6 +45,7 @@ fun CommunityHeader( community: CommunityModel, modifier: Modifier = Modifier, autoLoadImages: Boolean = true, + preferNicknames: Boolean = true, onOpenImage: ((String) -> Unit)? = null, ) { Box( @@ -104,7 +105,7 @@ fun CommunityHeader( } else { PlaceholderImage( size = IconSize.xxl, - title = community.readableName, + title = community.readableName(preferNicknames), ) } @@ -113,13 +114,13 @@ fun CommunityHeader( verticalArrangement = Arrangement.spacedBy(Spacing.s), ) { Text( - text = community.readableName, + text = community.readableName(preferNicknames), style = MaterialTheme.typography.titleLarge, color = MaterialTheme.colorScheme.onBackground, ) - if (community.readableSimpleName != community.readableName) { + if (community.readableHandle != community.readableName(preferNicknames)) { Text( - text = community.readableSimpleName, + text = community.readableHandle, maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.titleSmall, diff --git a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityItem.kt b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityItem.kt index d29d63aa1..8930073a4 100644 --- a/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityItem.kt +++ b/core/commonui/lemmyui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/lemmyui/CommunityItem.kt @@ -41,8 +41,8 @@ import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.rememberCallb import com.github.diegoberaldin.raccoonforlemmy.core.utils.toLocalDp 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.readableHandle import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.readableName -import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.readableSimpleName @Composable fun CommunityItem( @@ -50,13 +50,14 @@ fun CommunityItem( modifier: Modifier = Modifier, small: Boolean = false, autoLoadImages: Boolean = true, + preferNicknames: Boolean = true, showSubscribers: Boolean = false, showFavorite: Boolean = false, options: List