Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.14.1/overscroll revert and backdrop #220

Merged
merged 2 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 66 additions & 78 deletions androidApp/src/main/java/com/m3u/androidApp/ui/Scaffold.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ import com.m3u.material.effects.currentBackStackEntry
import com.m3u.material.ktx.tv
import com.m3u.material.model.LocalHazeState
import com.m3u.material.model.LocalSpacing
import com.m3u.material.overscroll.OverScroll
import com.m3u.material.overscroll.overScrollAlpha
import com.m3u.material.overscroll.overScrollParallaxVertical
import com.m3u.ui.Destination
import com.m3u.ui.FontFamilies
import com.m3u.ui.helper.Fob
Expand Down Expand Up @@ -139,98 +136,89 @@ internal fun MainContent(
val tv = tv()
val spacing = LocalSpacing.current
val hazeState = LocalHazeState.current
val density = LocalDensity.current

val title = Metadata.title
val subtitle = Metadata.subtitle
val actions = Metadata.actions

val backStackEntry by currentBackStackEntry()

OverScroll {
Scaffold(
topBar = {
if (!tv) {
TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(Color.Transparent),
windowInsets = windowInsets,
title = {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.defaultMinSize(minHeight = 56.dp)
Scaffold(
topBar = {
if (!tv) {
TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(Color.Transparent),
windowInsets = windowInsets,
title = {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.defaultMinSize(minHeight = 56.dp)
) {
Column(
modifier = Modifier
.padding(horizontal = spacing.medium)
.weight(1f)
) {
Column(
modifier = Modifier
.padding(horizontal = spacing.medium)
.weight(1f)
) {
Text(
text = title,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontFamily = FontFamilies.LexendExa
)
AnimatedVisibility(subtitle.text.isNotEmpty()) {
Text(
text = title,
text = subtitle,
style = MaterialTheme.typography.titleMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontFamily = FontFamilies.LexendExa
overflow = TextOverflow.Ellipsis
)
AnimatedVisibility(subtitle.text.isNotEmpty()) {
Text(
text = subtitle,
style = MaterialTheme.typography.titleMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}

Row {
actions.forEach { action ->
IconButton(
icon = action.icon,
contentDescription = action.contentDescription,
onClick = action.onClick,
enabled = action.enabled
)
}
}

Spacer(modifier = Modifier.width(spacing.medium))
}
},
navigationIcon = {
AnimatedContent(
targetState = onBackPressed,
label = "app-scaffold-icon"
) { onBackPressed ->
if (onBackPressed != null) {

Row {
actions.forEach { action ->
IconButton(
icon = backStackEntry?.navigationIcon
?: Icons.AutoMirrored.Rounded.ArrowBack,
contentDescription = null,
onClick = onBackPressed,
modifier = Modifier.wrapContentSize()
icon = action.icon,
contentDescription = action.contentDescription,
onClick = action.onClick,
enabled = action.enabled
)
}
}
},
modifier = Modifier
.hazeChild(hazeState, style = HazeStyle(blurRadius = 6.dp))
.fillMaxWidth()
.overScrollParallaxVertical(maxParallaxOffset = -40f)
.overScrollAlpha(
finalAlpha = 0.35f
)
)
}
},
contentWindowInsets = windowInsets,
containerColor = Color.Transparent
) { padding ->
Background {
Box {
StarBackground(
modifier = Modifier.overScrollAlpha()
)
content(padding)
}

Spacer(modifier = Modifier.width(spacing.medium))
}
},
navigationIcon = {
AnimatedContent(
targetState = onBackPressed,
label = "app-scaffold-icon"
) { onBackPressed ->
if (onBackPressed != null) {
IconButton(
icon = backStackEntry?.navigationIcon
?: Icons.AutoMirrored.Rounded.ArrowBack,
contentDescription = null,
onClick = onBackPressed,
modifier = Modifier.wrapContentSize()
)
}
}
},
modifier = Modifier
.hazeChild(hazeState, style = HazeStyle(blurRadius = 6.dp))
.fillMaxWidth()
)
}
},
contentWindowInsets = windowInsets,
containerColor = Color.Transparent
) { padding ->
Background {
Box {
StarBackground()
content(padding)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import coil.compose.AsyncImage
import coil.request.CachePolicy
import coil.request.ImageRequest
import com.m3u.core.architecture.preferences.hiltPreferences
import com.m3u.material.overscroll.overScrollScaleCenter
import com.m3u.material.transformation.BlurTransformation
import com.m3u.ui.helper.LocalHelper
import com.m3u.ui.helper.Metadata
Expand Down Expand Up @@ -78,7 +77,6 @@ internal fun HeadlineBackground(modifier: Modifier = Modifier) {
modifier = modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.background)
.overScrollScaleCenter()
.offset {
IntOffset(
x = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ internal fun SmartphonePlaylistScreenImpl(
val configuration = LocalConfiguration.current
val focusManager = LocalFocusManager.current

val scaffoldState = rememberBackdropScaffoldState(BackdropValue.Concealed)
val scaffoldState = rememberBackdropScaffoldState(
initialValue = BackdropValue.Concealed
)
val connection = remember {
object : NestedScrollConnection {
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
Expand Down Expand Up @@ -152,6 +154,7 @@ internal fun SmartphonePlaylistScreenImpl(

BackdropScaffold(
scaffoldState = scaffoldState,
gesturesEnabled = isAtTopState.value,
appBar = {},
frontLayerShape = RectangleShape,
peekHeight = 0.dp,
Expand Down

This file was deleted.

Loading
Loading