Skip to content

Commit 5173e25

Browse files
committed
feat: Enhance media information handling and UI components
- Refactored MediaInfoOps to improve media information extraction and reporting. - Introduced structured report generation for media info, including detailed metadata. - Added new badges for media info overview, enhancing user experience with visual indicators. - Implemented PlaybackMediaInfoSheet for displaying media info in a user-friendly format. - Created PlayerTitlePill component for better integration of media title and playlist info in the UI. - Updated string resources for improved localization support across multiple languages.
1 parent d2b8fe6 commit 5173e25

29 files changed

Lines changed: 1201 additions & 696 deletions

‎app/src/main/java/app/gyrolet/mpvrx/ui/liquidglass/AdaptiveControlsButton.kt‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,7 @@ fun AdaptiveControlsContainer(
181181
if (liquidGlassEnabled) {
182182
// Below the default level the whole glass layer fades instead (glassLayerAlpha).
183183
val base = surfaceColor.takeUnless { it == Color.Unspecified } ?: PlayerLiquidTokens.surfaceColor
184-
base.copy(
185-
alpha =
186-
PlayerButtonAlpha.background(
187-
base.alpha,
188-
maxOf(backgroundLevel, PlayerButtonAlpha.DEFAULT_BACKGROUND_LEVEL),
189-
),
190-
)
184+
base.copy(alpha = PlayerButtonAlpha.glassTint(base.alpha, backgroundLevel))
191185
} else {
192186
surfaceColor.takeUnless { it == Color.Unspecified }?.asPlayerButtonBackground()
193187
?: playerButtonContainerColor()
@@ -205,8 +199,7 @@ fun AdaptiveControlsContainer(
205199
if (horizontalPadding != null && horizontalPadding > 0.dp) Capsule() else CircleShape,
206200
)
207201
// Above the default level the glass tint thickens toward opaque; below it the whole glass fades.
208-
val glassLayerAlpha =
209-
(backgroundLevel / PlayerButtonAlpha.DEFAULT_BACKGROUND_LEVEL).coerceIn(0f, 1f)
202+
val glassLayerAlpha = PlayerButtonAlpha.glassLayer(backgroundLevel)
210203
val controlModifier =
211204
modifier
212205
// LiquidButton already clips its glass to the capsule. Clipping again here, over the larger

‎app/src/main/java/app/gyrolet/mpvrx/ui/liquidglass/LiquidButton.kt‎

Lines changed: 81 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ fun LiquidButton(
7777
shape: Shape = Capsule(),
7878
content: @Composable RowScope.() -> Unit,
7979
) {
80-
val glassSettings = rememberLiquidGlassSettings()
8180
val reducedMotion = AppMotion.shouldReduceMotion()
8281
val animatePress = enabled && !reducedMotion
8382
val interactionSource = remember { MutableInteractionSource() }
@@ -86,9 +85,6 @@ fun LiquidButton(
8685
remember(animationScope) {
8786
InteractiveHighlight(animationScope = animationScope)
8887
}
89-
val rememberedHighlight = remember(glassSettings) { glassSettings.highlight(Highlight.Default) }
90-
val rememberedShadow = remember { Shadow(radius = 6.dp) }
91-
val rememberedInnerShadow = remember { InnerShadow(radius = 2.dp, color = Color.White.copy(alpha = 0.18f)) }
9288
// Read animated state in the layer phase, not composition. The same controller survives
9389
// SDR/HDR renderer changes, so pressing/dragging a button never changes its interaction model.
9490
//
@@ -120,67 +116,13 @@ fun LiquidButton(
120116
translationY = verticalRoom * tanh(0.12f * offset.y / maxOffset)
121117
}
122118
}
123-
val glassModifier =
124-
if (backdrop != null) {
125-
Modifier.drawBackdrop(
126-
backdrop = backdrop,
127-
shape = { shape },
128-
effects = {
129-
liquidGlassEffects(
130-
glassSettings,
131-
8.dp.toPx(),
132-
14.dp.toPx(),
133-
24.dp.toPx(),
134-
vibrant = true,
135-
refractionEnabled = !reducedMotion,
136-
)
137-
},
138-
highlight = { rememberedHighlight },
139-
shadow = { rememberedShadow },
140-
innerShadow = { rememberedInnerShadow },
141-
layerBlock = if (animatePress) pressTransform else null,
142-
onDrawSurface = {
143-
// Keep the tint inside the animated outline, including during active-state morphs.
144-
val outline = shape.createOutline(size, layoutDirection, this)
145-
if (tint.isSpecified) {
146-
drawOutline(outline, tint, blendMode = BlendMode.Hue)
147-
drawOutline(outline, glassSettings.surfaceColor(tint.copy(alpha = 0.75f)))
148-
}
149-
if (surfaceColor.isSpecified) {
150-
drawOutline(outline, glassSettings.surfaceColor(surfaceColor))
151-
}
152-
},
153-
)
154-
} else {
155-
val baseColor = when {
156-
surfaceColor.isSpecified -> surfaceColor
157-
tint.isSpecified -> tint
158-
else -> MaterialTheme.colorScheme.surfaceContainerHigh
159-
}
160-
// Thickens toward opaque above the default background level; fading below it is backgroundAlpha's job.
161-
val fillLevel = maxOf(LocalPlayerButtonsOpacity.current, PlayerButtonAlpha.DEFAULT_BACKGROUND_LEVEL)
162-
val fill = Brush.verticalGradient(
163-
0f to baseColor.copy(alpha = PlayerButtonAlpha.background(0.68f, fillLevel)),
164-
0.45f to baseColor.copy(alpha = PlayerButtonAlpha.background(0.42f, fillLevel)),
165-
1f to baseColor.copy(alpha = PlayerButtonAlpha.background(0.58f, fillLevel)),
166-
)
167-
val rim = Brush.linearGradient(
168-
listOf(
169-
Color.White.copy(alpha = (0.43f * glassSettings.highlightStrength).coerceIn(0f, 1f)),
170-
Color.White.copy(alpha = (0.10f * glassSettings.highlightStrength).coerceIn(0f, 1f)),
171-
baseColor.copy(alpha = (0.30f * glassSettings.highlightStrength).coerceIn(0f, 1f)),
172-
),
173-
)
174-
Modifier
175-
.graphicsLayer(pressTransform)
176-
.outsideShadow(shape, radius = 6.dp)
177-
.clip(shape)
178-
.background(fill, shape)
179-
.then(
180-
if (glassSettings.highlightWidth > 0f) Modifier.border(1.dp * glassSettings.highlightWidth, rim, shape)
181-
else Modifier,
182-
)
183-
}
119+
val glassModifier = Modifier.liquidControlBackground(
120+
backdrop = backdrop,
121+
shape = shape,
122+
surfaceColor = surfaceColor,
123+
tint = tint,
124+
transform = pressTransform.takeIf { animatePress },
125+
)
184126

185127
val interactionModifier =
186128
Modifier
@@ -239,5 +181,79 @@ fun LiquidButton(
239181
content = content,
240182
)
241183
}
184+
185+
/** The button's optical surface without any size, focus, or pointer behavior. */
186+
@Composable
187+
internal fun Modifier.liquidControlBackground(
188+
backdrop: Backdrop?,
189+
shape: Shape,
190+
surfaceColor: Color,
191+
tint: Color = Color.Unspecified,
192+
transform: (GraphicsLayerScope.() -> Unit)? = null,
193+
): Modifier {
194+
val settings = rememberLiquidGlassSettings()
195+
if (backdrop != null) {
196+
val reducedMotion = AppMotion.shouldReduceMotion()
197+
val highlight = remember(settings) { settings.highlight(Highlight.Default) }
198+
val shadow = remember { Shadow(radius = 6.dp) }
199+
val innerShadow = remember { InnerShadow(radius = 2.dp, color = Color.White.copy(alpha = 0.18f)) }
200+
return drawBackdrop(
201+
backdrop = backdrop,
202+
shape = { shape },
203+
effects = {
204+
liquidGlassEffects(
205+
settings,
206+
8.dp.toPx(),
207+
14.dp.toPx(),
208+
24.dp.toPx(),
209+
vibrant = true,
210+
refractionEnabled = !reducedMotion,
211+
)
212+
},
213+
highlight = { highlight },
214+
shadow = { shadow },
215+
innerShadow = { innerShadow },
216+
layerBlock = transform,
217+
onDrawSurface = {
218+
val outline = shape.createOutline(size, layoutDirection, this)
219+
if (tint.isSpecified) {
220+
drawOutline(outline, tint, blendMode = BlendMode.Hue)
221+
drawOutline(outline, settings.surfaceColor(tint.copy(alpha = 0.75f)))
222+
}
223+
if (surfaceColor.isSpecified) {
224+
drawOutline(outline, settings.surfaceColor(surfaceColor))
225+
}
226+
},
227+
)
228+
}
229+
230+
// A native video surface cannot be sampled; keep the same frosted fallback as the buttons.
231+
val baseColor = when {
232+
surfaceColor.isSpecified -> surfaceColor
233+
tint.isSpecified -> tint
234+
else -> MaterialTheme.colorScheme.surfaceContainerHigh
235+
}
236+
val level = LocalPlayerButtonsOpacity.current
237+
val fill = Brush.verticalGradient(
238+
0f to baseColor.copy(alpha = PlayerButtonAlpha.glassTint(0.68f, level)),
239+
0.45f to baseColor.copy(alpha = PlayerButtonAlpha.glassTint(0.42f, level)),
240+
1f to baseColor.copy(alpha = PlayerButtonAlpha.glassTint(0.58f, level)),
241+
)
242+
val rim = Brush.linearGradient(
243+
listOf(
244+
Color.White.copy(alpha = (0.43f * settings.highlightStrength).coerceIn(0f, 1f)),
245+
Color.White.copy(alpha = (0.10f * settings.highlightStrength).coerceIn(0f, 1f)),
246+
baseColor.copy(alpha = (0.30f * settings.highlightStrength).coerceIn(0f, 1f)),
247+
),
248+
)
249+
return (if (transform == null) this else graphicsLayer(transform))
250+
.outsideShadow(shape, radius = 6.dp)
251+
.clip(shape)
252+
.background(fill, shape)
253+
.then(
254+
if (settings.highlightWidth > 0f) Modifier.border(1.dp * settings.highlightWidth, rim, shape)
255+
else Modifier,
256+
)
257+
}
242258
}
243259
}

0 commit comments

Comments
 (0)