From a19bd2f350c98fd6d921e97bc57ab5bcfb98ba46 Mon Sep 17 00:00:00 2001 From: Lars Benedetto Date: Fri, 16 Jun 2023 18:31:54 -0700 Subject: [PATCH] QOL Remove unnecessary clickable areas from PostListingList The PostListingList is too small to have multiple clickable areas, leading many users to accidentally click into the community or the users profile from the front page instead of opening the post like they intended. --- .../ui/components/community/CommunityLink.kt | 7 ++++++- .../ui/components/person/PersonProfileLink.kt | 7 ++++++- .../com/jerboa/ui/components/post/PostListing.kt | 14 ++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/jerboa/ui/components/community/CommunityLink.kt b/app/src/main/java/com/jerboa/ui/components/community/CommunityLink.kt index fb347a73d..423ae5336 100644 --- a/app/src/main/java/com/jerboa/ui/components/community/CommunityLink.kt +++ b/app/src/main/java/com/jerboa/ui/components/community/CommunityLink.kt @@ -70,12 +70,17 @@ fun CommunityLink( thumbnailSize: Int = ICON_THUMBNAIL_SIZE, style: TextStyle = MaterialTheme.typography.bodyMedium, onClick: (community: CommunitySafe) -> Unit, + clickable: Boolean = true, showDefaultIcon: Boolean, ) { Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(spacing), - modifier = modifier.clickable { onClick(community) }, + modifier = if (clickable) { + modifier.clickable { onClick(community) } + } else { + modifier + }, ) { community.icon?.let { CircularIcon( diff --git a/app/src/main/java/com/jerboa/ui/components/person/PersonProfileLink.kt b/app/src/main/java/com/jerboa/ui/components/person/PersonProfileLink.kt index 502890608..2516c5e84 100644 --- a/app/src/main/java/com/jerboa/ui/components/person/PersonProfileLink.kt +++ b/app/src/main/java/com/jerboa/ui/components/person/PersonProfileLink.kt @@ -58,6 +58,7 @@ fun PersonNamePreview() { fun PersonProfileLink( person: PersonSafe, onClick: (personId: Int) -> Unit, + clickable: Boolean = true, showTags: Boolean = false, isPostCreator: Boolean = false, isModerator: Boolean = false, @@ -68,7 +69,11 @@ fun PersonProfileLink( Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(SMALL_PADDING), - modifier = Modifier.clickable { onClick(person.id) }, + modifier = if (clickable) { + Modifier.clickable { onClick(person.id) } + } else { + Modifier + }, ) { if (showAvatar) { person.avatar?.also { diff --git a/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt b/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt index 3acd83488..bc34898da 100644 --- a/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt +++ b/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt @@ -908,8 +908,6 @@ fun PostListing( onDownvoteClick(it) }, onPostClick = onPostClick, - onCommunityClick = onCommunityClick, - onPersonClick = onPersonClick, isModerator = isModerator, showCommunityName = showCommunityName, account = account, @@ -972,8 +970,6 @@ fun PostListingList( onUpvoteClick: (postView: PostView) -> Unit, onDownvoteClick: (postView: PostView) -> Unit, onPostClick: (postView: PostView) -> Unit, - onCommunityClick: (community: CommunitySafe) -> Unit, - onPersonClick: (personId: Int) -> Unit, isModerator: Boolean, showCommunityName: Boolean = true, account: Account?, @@ -1017,7 +1013,8 @@ fun PostListingList( if (showCommunityName) { CommunityLink( community = postView.community, - onClick = onCommunityClick, + onClick = {}, + clickable = false, showDefaultIcon = false, ) DotSpacer(0.dp) @@ -1025,7 +1022,8 @@ fun PostListingList( PersonProfileLink( person = postView.creator, isModerator = isModerator, - onClick = onPersonClick, + onClick = {}, + clickable = false, color = MaterialTheme.colorScheme.onSurface.muted, showAvatar = showAvatar, ) @@ -1136,8 +1134,6 @@ fun PostListingListPreview() { onUpvoteClick = {}, onDownvoteClick = {}, onPostClick = {}, - onCommunityClick = {}, - onPersonClick = {}, isModerator = false, account = null, showVotingArrowsInListView = true, @@ -1162,8 +1158,6 @@ fun PostListingListWithThumbPreview() { onUpvoteClick = {}, onDownvoteClick = {}, onPostClick = {}, - onCommunityClick = {}, - onPersonClick = {}, isModerator = false, account = null, showVotingArrowsInListView = true,