Tweak UI
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package it.vfsfitvnm.vimusic.ui.components.themed
|
package it.vfsfitvnm.vimusic.ui.components.themed
|
||||||
|
|
||||||
|
import android.content.res.Configuration
|
||||||
import androidx.compose.animation.animateColor
|
import androidx.compose.animation.animateColor
|
||||||
import androidx.compose.animation.core.animateFloat
|
import androidx.compose.animation.core.animateFloat
|
||||||
import androidx.compose.animation.core.updateTransition
|
import androidx.compose.animation.core.updateTransition
|
||||||
@@ -29,8 +30,10 @@ import androidx.compose.ui.draw.rotate
|
|||||||
import androidx.compose.ui.graphics.ColorFilter
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.ui.layout.layout
|
import androidx.compose.ui.layout.layout
|
||||||
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
|
||||||
import it.vfsfitvnm.vimusic.ui.styling.Dimensions
|
import it.vfsfitvnm.vimusic.ui.styling.Dimensions
|
||||||
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
|
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
|
||||||
import it.vfsfitvnm.vimusic.utils.semiBold
|
import it.vfsfitvnm.vimusic.utils.semiBold
|
||||||
@@ -45,22 +48,33 @@ fun NavigationRail(
|
|||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val (colorPalette, typography) = LocalAppearance.current
|
val (colorPalette, typography) = LocalAppearance.current
|
||||||
|
val configuration = LocalConfiguration.current
|
||||||
|
|
||||||
|
val isLandscape = configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
|
.padding(LocalPlayerAwarePaddingValues.current)
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
contentAlignment = Alignment.TopCenter,
|
contentAlignment = Alignment.TopCenter,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(width = Dimensions.navigationRailWidth, height = Dimensions.headerHeight)
|
.size(
|
||||||
|
width = if (isLandscape) Dimensions.navigationRailWidthLandscape else Dimensions.navigationRailWidth,
|
||||||
|
height = Dimensions.headerHeight
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(topIconButtonId),
|
painter = painterResource(topIconButtonId),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
colorFilter = ColorFilter.tint(colorPalette.textSecondary),
|
colorFilter = ColorFilter.tint(colorPalette.textSecondary),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.offset(x = Dimensions.navigationRailIconOffset, y = 48.dp)
|
.offset(
|
||||||
|
x = if (isLandscape) 0.dp else Dimensions.navigationRailIconOffset,
|
||||||
|
y = 48.dp
|
||||||
|
)
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.clickable(onClick = onTopIconButtonClick)
|
.clickable(onClick = onTopIconButtonClick)
|
||||||
.padding(all = 12.dp)
|
.padding(all = 12.dp)
|
||||||
@@ -68,10 +82,7 @@ fun NavigationRail(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
modifier = modifier
|
|
||||||
.verticalScroll(rememberScrollState())
|
|
||||||
) {
|
|
||||||
val transition = updateTransition(targetState = tabIndex, label = null)
|
val transition = updateTransition(targetState = tabIndex, label = null)
|
||||||
|
|
||||||
content { index, text, icon ->
|
content { index, text, icon ->
|
||||||
@@ -83,52 +94,73 @@ fun NavigationRail(
|
|||||||
if (it == index) colorPalette.text else colorPalette.textDisabled
|
if (it == index) colorPalette.text else colorPalette.textDisabled
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
val iconContent: @Composable () -> Unit = {
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
modifier = Modifier
|
|
||||||
.clip(RoundedCornerShape(24.dp))
|
|
||||||
.clickable(
|
|
||||||
indication = rememberRipple(bounded = true),
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
|
||||||
onClick = { onTabIndexChanged(index) }
|
|
||||||
)
|
|
||||||
.padding(horizontal = 8.dp)
|
|
||||||
) {
|
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(icon),
|
painter = painterResource(icon),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.vertical()
|
.vertical(enabled = !isLandscape)
|
||||||
.graphicsLayer {
|
.graphicsLayer {
|
||||||
alpha = dothAlpha
|
alpha = dothAlpha
|
||||||
translationX = (1f - dothAlpha) * -48.dp.toPx()
|
translationX = (1f - dothAlpha) * -48.dp.toPx()
|
||||||
rotationZ = -90f
|
rotationZ = if (isLandscape) 0f else -90f
|
||||||
}
|
}
|
||||||
.size(Dimensions.navigationRailIconOffset * 2)
|
.size(Dimensions.navigationRailIconOffset * 2)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val textContent: @Composable () -> Unit = {
|
||||||
BasicText(
|
BasicText(
|
||||||
text = text,
|
text = text,
|
||||||
style = typography.xs.semiBold.copy(color = textColor),
|
style = typography.xs.semiBold.copy(color = textColor),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.vertical()
|
.vertical(enabled = !isLandscape)
|
||||||
.rotate(-90f)
|
.rotate(if (isLandscape) 0f else -90f)
|
||||||
.padding(horizontal = 16.dp)
|
.padding(horizontal = 16.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val contentModifier = Modifier
|
||||||
|
.clip(RoundedCornerShape(24.dp))
|
||||||
|
.clickable(
|
||||||
|
indication = rememberRipple(bounded = true),
|
||||||
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
|
onClick = { onTabIndexChanged(index) }
|
||||||
|
)
|
||||||
|
|
||||||
|
if (isLandscape) {
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
modifier = contentModifier
|
||||||
|
.padding(vertical = 8.dp)
|
||||||
|
) {
|
||||||
|
iconContent()
|
||||||
|
textContent()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = contentModifier
|
||||||
|
.padding(horizontal = 8.dp)
|
||||||
|
) {
|
||||||
|
iconContent()
|
||||||
|
textContent()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Modifier.vertical() =
|
private fun Modifier.vertical(enabled: Boolean = true) =
|
||||||
layout { measurable, constraints ->
|
if (enabled)
|
||||||
val placeable = measurable.measure(constraints)
|
layout { measurable, constraints ->
|
||||||
layout(placeable.height, placeable.width) {
|
val placeable = measurable.measure(constraints)
|
||||||
placeable.place(
|
layout(placeable.height, placeable.width) {
|
||||||
x = -(placeable.width / 2 - placeable.height / 2),
|
placeable.place(
|
||||||
y = -(placeable.height / 2 - placeable.width / 2)
|
x = -(placeable.width / 2 - placeable.height / 2),
|
||||||
)
|
y = -(placeable.height / 2 - placeable.width / 2)
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
} else this
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ fun Scaffold(
|
|||||||
onTopIconButtonClick = onTopIconButtonClick,
|
onTopIconButtonClick = onTopIconButtonClick,
|
||||||
tabIndex = tabIndex,
|
tabIndex = tabIndex,
|
||||||
onTabIndexChanged = onTabChanged,
|
onTabIndexChanged = onTabChanged,
|
||||||
modifier = Modifier
|
|
||||||
.padding(LocalPlayerAwarePaddingValues.current),
|
|
||||||
content = tabColumnContent
|
content = tabColumnContent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -62,10 +62,12 @@ fun LocalSongSearch(
|
|||||||
stateSaver = DetailedSongListSaver,
|
stateSaver = DetailedSongListSaver,
|
||||||
key1 = textFieldValue.text
|
key1 = textFieldValue.text
|
||||||
) {
|
) {
|
||||||
Database
|
if (textFieldValue.text.length > 1) {
|
||||||
.search("%${textFieldValue.text}%")
|
Database
|
||||||
.flowOn(Dispatchers.IO)
|
.search("%${textFieldValue.text}%")
|
||||||
.collect { value = it }
|
.flowOn(Dispatchers.IO)
|
||||||
|
.collect { value = it }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val thumbnailSize = Dimensions.thumbnails.song.px
|
val thumbnailSize = Dimensions.thumbnails.song.px
|
||||||
|
|||||||
@@ -111,11 +111,6 @@ fun OnlineSearch(
|
|||||||
FocusRequester()
|
FocusRequester()
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
delay(300)
|
|
||||||
focusRequester.requestFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
contentPadding = LocalPlayerAwarePaddingValues.current,
|
contentPadding = LocalPlayerAwarePaddingValues.current,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -334,4 +329,9 @@ fun OnlineSearch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
delay(300)
|
||||||
|
focusRequester.requestFocus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ object Dimensions {
|
|||||||
val itemsVerticalPadding = 8.dp
|
val itemsVerticalPadding = 8.dp
|
||||||
|
|
||||||
val navigationRailWidth = 64.dp
|
val navigationRailWidth = 64.dp
|
||||||
|
val navigationRailWidthLandscape = 128.dp
|
||||||
val navigationRailIconOffset = 6.dp
|
val navigationRailIconOffset = 6.dp
|
||||||
val headerHeight = 128.dp
|
val headerHeight = 128.dp
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user