Fix AdventureBackground overflow and and drop cap to the page Title.
This commit is contained in:
parent
03671792d6
commit
7400799efd
2 changed files with 25 additions and 4 deletions
|
|
@ -81,6 +81,18 @@ fun rememberSaturationFilter(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun rememberBackgroundGradient(
|
||||
vararg gradients: Float,
|
||||
): Brush {
|
||||
val colorScheme = MaterialTheme.colorScheme
|
||||
return remember {
|
||||
Brush.verticalGradient(
|
||||
colors = gradients.map { colorScheme.surface.copy(alpha = it) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun rememberBackgroundGradient(
|
||||
from: Float = 0.5f,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.pixelized.rplexicon.ui.screens.adventure.detail
|
|||
import android.content.res.Configuration
|
||||
import android.net.Uri
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
|
|
@ -21,6 +20,7 @@ import androidx.compose.material.icons.filled.Refresh
|
|||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
|
|
@ -32,7 +32,6 @@ import androidx.compose.runtime.derivedStateOf
|
|||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.produceState
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.Saver
|
||||
import androidx.compose.runtime.saveable.mapSaver
|
||||
|
|
@ -57,6 +56,7 @@ import androidx.core.net.toUri
|
|||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.composable.images.BackgroundImage
|
||||
import com.pixelized.rplexicon.ui.composable.images.rememberBackgroundGradient
|
||||
import com.pixelized.rplexicon.ui.navigation.LocalScreenNavHost
|
||||
import com.pixelized.rplexicon.ui.screens.adventure.detail.AdventureLineUio.Style.CHAPTER
|
||||
import com.pixelized.rplexicon.ui.screens.adventure.detail.AdventureLineUio.Style.LEGEND
|
||||
|
|
@ -64,6 +64,9 @@ import com.pixelized.rplexicon.ui.screens.adventure.detail.AdventureLineUio.Styl
|
|||
import com.pixelized.rplexicon.ui.screens.adventure.detail.AdventureLineUio.Style.SUB_TITLE
|
||||
import com.pixelized.rplexicon.ui.screens.adventure.detail.AdventureLineUio.Style.TITLE
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.annotateMajWithDropCap
|
||||
import com.pixelized.rplexicon.utilitary.extentions.lexicon
|
||||
import kotlin.math.min
|
||||
|
||||
@Composable
|
||||
fun AdventureDetailScreen(
|
||||
|
|
@ -125,7 +128,7 @@ private fun AdventureDetailContent(
|
|||
available: Offset,
|
||||
source: NestedScrollSource
|
||||
): Offset {
|
||||
nestedScrollOffset.floatValue += consumed.y
|
||||
nestedScrollOffset.floatValue = min(nestedScrollOffset.floatValue + consumed.y, 0f)
|
||||
return super.onPostScroll(consumed, available, source)
|
||||
}
|
||||
}
|
||||
|
|
@ -160,6 +163,8 @@ private fun AdventureDetailContent(
|
|||
.aspectRatio(ratio = 1f)
|
||||
.alpha(alpha = backgroundAlpha.value)
|
||||
.offset { IntOffset(x = 0, y = nestedScrollOffset.floatValue.toInt() / 2) },
|
||||
colorFilter = null,
|
||||
background = rememberBackgroundGradient(0f, 0f, 0.1f, 0.7f, 1f),
|
||||
model = uri,
|
||||
)
|
||||
}
|
||||
|
|
@ -186,9 +191,13 @@ private fun AdventureDetailContent(
|
|||
)
|
||||
Text(
|
||||
modifier = Modifier.alpha(alpha = alpha.value),
|
||||
style = MaterialTheme.lexicon.typography.base.titleLarge,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
text = title.value ?: "",
|
||||
text = annotateMajWithDropCap(
|
||||
text = title.value ?: "",
|
||||
style = MaterialTheme.lexicon.typography.dropCap.titleLarge
|
||||
),
|
||||
)
|
||||
},
|
||||
actions = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue