Skip to content

Commit

Permalink
More horizontal line fixes. (#1423)
Browse files Browse the repository at this point in the history
* More horizontal line fixes.

* Adding horizontal divider to separate post and comments in postactivity.

---------

Co-authored-by: Maarten Vercruysse <67873169+MV-GH@users.noreply.github.com>
  • Loading branch information
dessalines and MV-GH authored Mar 8, 2024
1 parent 5df3d7b commit 555abbf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ fun calculateCommentOffset(
return if (depth == 0) {
0.dp
} else {
(abs((depth.minus(1) * padding.value.toInt())).dp + padding)
(abs((depth.minus(1) * padding.value)).dp + padding)
}
}

Expand Down
15 changes: 4 additions & 11 deletions app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.material.icons.filled.Bookmark
import androidx.compose.material.icons.outlined.BookmarkBorder
import androidx.compose.material.icons.outlined.MoreVert
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
Expand Down Expand Up @@ -77,6 +76,7 @@ import com.jerboa.ui.components.common.SwipeToAction
import com.jerboa.ui.components.common.VoteGeneric
import com.jerboa.ui.components.common.rememberSwipeActionState
import com.jerboa.ui.components.community.CommunityLink
import com.jerboa.ui.theme.BORDER_WIDTH
import com.jerboa.ui.theme.LARGE_PADDING
import com.jerboa.ui.theme.MEDIUM_PADDING
import com.jerboa.ui.theme.SMALL_PADDING
Expand Down Expand Up @@ -251,7 +251,7 @@ fun LazyListScope.commentNodeItem(

val backgroundColor = MaterialTheme.colorScheme.background
val borderColor = calculateBorderColor(backgroundColor, node.depth)
val border = Border(SMALL_PADDING, borderColor)
val border = Border(BORDER_WIDTH, borderColor)

val ctx = LocalContext.current

Expand Down Expand Up @@ -308,10 +308,6 @@ fun LazyListScope.commentNodeItem(
.border(start = border)
.padding(bottom = MEDIUM_PADDING),
) {
if (node.depth == 0) {
HorizontalDivider()
}

Column(
modifier =
Modifier.padding(
Expand Down Expand Up @@ -552,7 +548,7 @@ fun LazyListScope.missingCommentNodeItem(
item(key = commentId) {
val backgroundColor = MaterialTheme.colorScheme.background
val borderColor = calculateBorderColor(backgroundColor, node.depth)
val border = Border(SMALL_PADDING, borderColor)
val border = Border(BORDER_WIDTH, borderColor)

AnimatedVisibility(
visible = !isCollapsedByParent,
Expand All @@ -566,9 +562,6 @@ fun LazyListScope.missingCommentNodeItem(
start = offset,
).border(start = border),
) {
if (node.depth == 0) {
HorizontalDivider()
}
Column(
modifier =
Modifier.padding(
Expand Down Expand Up @@ -658,7 +651,7 @@ private fun ShowMoreChildrenNode(

val backgroundColor = MaterialTheme.colorScheme.background
val borderColor = calculateBorderColor(backgroundColor, newDepth)
val border = Border(SMALL_PADDING, borderColor)
val border = Border(BORDER_WIDTH, borderColor)

AnimatedVisibility(
visible = !isCollapsedByParent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.material.icons.automirrored.outlined.Sort
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -489,6 +490,10 @@ fun PostActivity(
}
}

item(contentType = "horizontalDivider") {
HorizontalDivider()
}

when (val commentsRes = postViewModel.commentsRes) {
is ApiState.Failure ->
item(key = "error") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.HorizontalDivider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -34,7 +33,6 @@ import com.jerboa.isScrolledToEnd
import com.jerboa.rememberJerboaAppState
import com.jerboa.ui.components.common.RetryLoadingPosts
import com.jerboa.ui.components.common.simpleVerticalScrollbar
import com.jerboa.ui.theme.SMALL_PADDING
import it.vercruysse.lemmyapi.v0x19.datatypes.Community
import it.vercruysse.lemmyapi.v0x19.datatypes.Person
import it.vercruysse.lemmyapi.v0x19.datatypes.PersonId
Expand Down Expand Up @@ -150,7 +148,6 @@ fun PostListings(
}
}
}
HorizontalDivider(modifier = Modifier.padding(bottom = SMALL_PADDING))
}

if (showPostAppendRetry) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/jerboa/ui/theme/Sizes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const val SCORE_SIZE_ADD = 4
val ACTION_BAR_ICON_SIZE = 16.dp
val MARKDOWN_BAR_ICON_SIZE = 24.dp

val BORDER_WIDTH = 1.dp
val SMALLER_PADDING = 2.dp
val SMALL_PADDING = 4.dp
val MEDIUM_PADDING = 8.dp
Expand Down

0 comments on commit 555abbf

Please sign in to comment.