Skip to content

Commit

Permalink
Various fixes.
Browse files Browse the repository at this point in the history
- Show comment upvote count when there are downvotes. Fixes #97
- Fix muted colors for titles, top app bars. Fixes #98
- Smoother comment scrolling. Fixes #99
- Mute post title color on read. Fixes #100
  • Loading branch information
dessalines committed Feb 19, 2022
1 parent 936e88a commit e590369
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ fun CommentFooterLine(
item = commentView,
type = VoteType.Upvote,
onVoteClick = onUpvoteClick,
showNumber = false,
showNumber = (downvotes != 0),
account = account,
)
VoteGeneric(
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/jerboa/ui/components/common/AppBars.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jerboa.ui.components.common

import android.annotation.SuppressLint
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ExperimentalFoundationApi
Expand All @@ -12,7 +13,8 @@ import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithContent
Expand Down Expand Up @@ -410,6 +412,7 @@ fun CommentsAndPosts(
}
}

@SuppressLint("ComposableModifierFactory")
@Composable
fun Modifier.simpleVerticalScrollbar(
state: LazyListState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fun PreviewLines(
fun MyMarkdownText(
markdown: String,
modifier: Modifier = Modifier,
color: Color = MaterialTheme.typography.body1.color,
color: Color = MaterialTheme.colors.onSurface,
) {

// val fontSize = TextUnit(MaterialTheme.typography.body1.fontSize.value, type = TextUnitType.Sp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ fun CommunityTopSection(
) {
Text(
text = communityView.community.title,
style = MaterialTheme.typography.h6
style = MaterialTheme.typography.h6,
color = MaterialTheme.colors.onSurface,
)
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Icon(
Expand Down Expand Up @@ -195,7 +196,8 @@ fun CommunityHeaderTitle(
Column {
Text(
text = communityName,
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.subtitle1,
color = MaterialTheme.colors.onSurface,
)
Text(
text = selectedSortType.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ fun CommunityName(

Text(
text = communityNameShown(community),
color = color,
style = style,
color = color,
)
}

Expand Down Expand Up @@ -71,7 +71,7 @@ fun CommunityLink(
usersPerMonth?.also {
Text(
text = "$usersPerMonth users / month",
color = Muted
color = MaterialTheme.colors.onSurface,
)
}
}
Expand All @@ -85,7 +85,7 @@ fun CommunityLinkLarger(
) {
CommunityLink(
community = community,
color = Color.Unspecified,
color = MaterialTheme.colors.onSurface,
size = LINK_ICON_SIZE,
thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE,
spacing = DRAWER_ITEM_SPACING,
Expand All @@ -105,7 +105,7 @@ fun CommunityLinkLargerWithUserCount(
CommunityLink(
community = communityView.community,
usersPerMonth = communityView.counts.users_active_month,
color = Color.Unspecified,
color = MaterialTheme.colors.onSurface,
size = LINK_ICON_SIZE,
thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE,
spacing = DRAWER_ITEM_SPACING,
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/jerboa/ui/components/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ fun HomeHeaderTitle(
Column {
Text(
text = selectedListingType.toString(),
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.subtitle1,
color = MaterialTheme.colors.onSurface,
)
Text(
text = selectedSortType.toString(),
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/jerboa/ui/components/inbox/Inbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ fun InboxHeaderTitle(selectedUnreadOrAll: UnreadOrAll, unreadCount: Int? = null)
Column {
Text(
text = title,
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.subtitle1,
color = MaterialTheme.colors.onSurface,
)
Text(
text = selectedUnreadOrAll.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ fun PersonProfileHeaderTitle(
Column {
Text(
text = personName,
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.subtitle1,
color = MaterialTheme.colors.onSurface,
)
Text(
text = selectedSortType.toString(),
Expand Down
198 changes: 97 additions & 101 deletions app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package com.jerboa.ui.components.post
import android.util.Log
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.LinearProgressIndicator
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
Expand All @@ -16,17 +15,19 @@ import androidx.compose.ui.platform.LocalContext
import androidx.navigation.NavController
import com.google.accompanist.swiperefresh.SwipeRefresh
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
import com.jerboa.*
import com.jerboa.VoteType
import com.jerboa.buildCommentsTree
import com.jerboa.datatypes.SortType
import com.jerboa.db.AccountViewModel
import com.jerboa.isModerator
import com.jerboa.openLink
import com.jerboa.ui.components.comment.CommentNode
import com.jerboa.ui.components.comment.edit.CommentEditViewModel
import com.jerboa.ui.components.comment.edit.commentEditClickWrapper
import com.jerboa.ui.components.comment.reply.CommentReplyViewModel
import com.jerboa.ui.components.comment.reply.commentReplyClickWrapper
import com.jerboa.ui.components.common.SimpleTopAppBar
import com.jerboa.ui.components.common.getCurrentAccount
import com.jerboa.ui.components.common.simpleVerticalScrollbar
import com.jerboa.ui.components.community.CommunityViewModel
import com.jerboa.ui.components.community.communityClickWrapper
import com.jerboa.ui.components.person.PersonProfileViewModel
Expand All @@ -53,7 +54,6 @@ fun PostActivity(
Log.d("jerboa", "got to post activity")

val ctx = LocalContext.current
val listState = rememberLazyListState()

val account = getCurrentAccount(accountViewModel = accountViewModel)
val commentNodes = buildCommentsTree(postViewModel.comments, SortType.Hot)
Expand Down Expand Up @@ -87,107 +87,103 @@ fun PostActivity(
},
) {
postViewModel.postView.value?.also { postView ->
LazyColumn(
state = listState,
// TODO scroll bar was laggy here for some reason
modifier = Modifier.simpleVerticalScrollbar(listState)
// TODO Both LazyColumn and scrollbar was laggy here for some reason
Column(
modifier = Modifier.verticalScroll(rememberScrollState())
) {
item {
PostListing(
postView = postView,
fullBody = true,
showCommunityName = true,
onUpvoteClick = {
postViewModel.likePost(
voteType = VoteType.Upvote,
account = account,
PostListing(
postView = postView,
fullBody = true,
showCommunityName = true,
onUpvoteClick = {
postViewModel.likePost(
voteType = VoteType.Upvote,
account = account,
ctx = ctx,
)
// TODO will need to pass in postlistingsviewmodel
// for the Home page to also be updated
},
onDownvoteClick = {
postViewModel.likePost(
voteType = VoteType.Downvote,
account = account,
ctx = ctx,
)
},
onSaveClick = {
postViewModel.savePost(
account = account,
ctx = ctx
)
},
onBlockCommunityClick = {
account?.also { acct ->
postViewModel.blockCommunity(
account = acct,
ctx = ctx,
)
// TODO will need to pass in postlistingsviewmodel
// for the Home page to also be updated
},
onDownvoteClick = {
postViewModel.likePost(
voteType = VoteType.Downvote,
account = account,
}
},
onBlockCreatorClick = {
account?.also { acct ->
postViewModel.blockCreator(
creator = it,
account = acct,
ctx = ctx,
)
},
onSaveClick = {
postViewModel.savePost(
account = account,
ctx = ctx
)
},
onBlockCommunityClick = {
account?.also { acct ->
postViewModel.blockCommunity(
account = acct,
ctx = ctx,
)
}
},
onBlockCreatorClick = {
account?.also { acct ->
postViewModel.blockCreator(
creator = it,
account = acct,
ctx = ctx,
)
}
},
onReplyClick = { postView ->
commentReplyClickWrapper(
commentReplyViewModel = commentReplyViewModel,
postId = postView.post.id,
postView = postView,
navController = navController,
)
},
onPostLinkClick = { url ->
openLink(url, ctx)
},
onCommunityClick = { community ->
communityClickWrapper(
communityViewModel,
community.id,
account,
navController,
ctx
)
},
onPersonClick = { personId ->
personClickWrapper(
personProfileViewModel,
personId,
account,
navController,
ctx
)
},
onEditPostClick = { postView ->
postEditClickWrapper(
postEditViewModel,
postView,
navController,
)
},
onReportClick = { postView ->
postReportClickWrapper(
createReportViewModel,
postView.post.id,
navController,
)
},
onPostClick = {}, // Do nothing
showReply = true,
account = account,
isModerator = isModerator(postView.creator, postViewModel.moderators)
)
}
// Don't use CommentNodes here, otherwise lazy scrolling wont work
}
},
onReplyClick = { postView ->
commentReplyClickWrapper(
commentReplyViewModel = commentReplyViewModel,
postId = postView.post.id,
postView = postView,
navController = navController,
)
},
onPostLinkClick = { url ->
openLink(url, ctx)
},
onCommunityClick = { community ->
communityClickWrapper(
communityViewModel,
community.id,
account,
navController,
ctx
)
},
onPersonClick = { personId ->
personClickWrapper(
personProfileViewModel,
personId,
account,
navController,
ctx
)
},
onEditPostClick = { postView ->
postEditClickWrapper(
postEditViewModel,
postView,
navController,
)
},
onReportClick = { postView ->
postReportClickWrapper(
createReportViewModel,
postView.post.id,
navController,
)
},
onPostClick = {}, // Do nothing
showReply = true,
account = account,
isModerator = isModerator(postView.creator, postViewModel.moderators)
)
// Can't really do scrolling well here either because of tree
itemsIndexed(commentNodes) { _, node ->
commentNodes.forEach { node ->
CommentNode(
node = node,
onUpvoteClick = { commentView ->
Expand Down
Loading

0 comments on commit e590369

Please sign in to comment.