Skip to content

Commit

Permalink
maxHeight extension
Browse files Browse the repository at this point in the history
  • Loading branch information
imashnake0 committed Feb 24, 2024
1 parent 9f89ac3 commit 3cdf191
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package com.imashnake.animite.core.extensions
import android.content.res.Configuration
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.layout.displayCutoutPadding
import androidx.compose.foundation.layout.heightIn
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

fun Modifier.landscapeCutoutPadding() = composed {
if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Expand All @@ -19,3 +22,5 @@ fun Modifier.landscapeCutoutPadding() = composed {
fun Modifier.bannerParallax(scrollState: ScrollState) = graphicsLayer {
translationY = 0.7f * scrollState.value
}

fun Modifier.maxHeight(max: Dp) = this.heightIn(0.dp, max)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
Expand All @@ -25,14 +24,14 @@ import com.boswelja.markdown.material3.m3CodeBlockStyle
import com.boswelja.markdown.material3.m3TextStyleModifiers
import com.boswelja.markdown.material3.m3TextStyles
import com.imashnake.animite.core.extensions.animiteBlockQuoteStyle
import com.imashnake.animite.core.extensions.maxHeight
import com.imashnake.animite.core.ui.LocalPaddings
import com.imashnake.animite.core.ui.NestedScrollableContent
import com.imashnake.animite.core.ui.layouts.BannerLayout
import com.imashnake.animite.profile.dev.internal.ANILIST_AUTH_DEEPLINK
import com.ramcosta.composedestinations.annotation.DeepLink
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootNavGraph
import com.imashnake.animite.core.R as coreR

@Destination(
route = "user",
Expand Down Expand Up @@ -91,12 +90,7 @@ fun ProfileScreen(
style = MaterialTheme.typography.titleLarge,
overflow = TextOverflow.Ellipsis
)
Box(
Modifier.heightIn(
dimensionResource(coreR.dimen.zero),
dimensionResource(R.dimen.user_about_height)
)
) {
Box(Modifier.maxHeight(dimensionResource(R.dimen.user_about_height))) {
NestedScrollableContent { contentModifier ->
about?.let {
MarkdownDocument(
Expand Down

0 comments on commit 3cdf191

Please sign in to comment.