Skip to content

Instantly share code, notes, and snippets.

{
"asset":{
"generator":"Khronos glTF Blender I/O v3.5.30",
"version":"2.0"
},
"extensionsUsed":[
"KHR_lights_punctual"
],
"extensionsRequired":[
"KHR_lights_punctual"
package com.victor.tutorial
import android.animation.ValueAnimator
import android.opengl.Matrix
import android.view.Choreographer
import android.view.SurfaceView
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import com.google.android.filament.MaterialInstance
@Composable
fun VideoView(
onVideoLoaded: () -> Unit,
onVideoEnded: () -> Unit,
) {
val context = LocalContext.current
val lifecycle = LocalLifecycleOwner.current.lifecycle
val exoPlayer = ExoPlayer.Builder(context)
.build()
@Composable
fun Camera(
onNoCameraAvailable: (Exception) -> Unit,
) {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
val preview = Preview.Builder().build()
val previewView = remember { PreviewView(context) }
val cameraSelector = CameraSelector.Builder()
Marquee {
Row {
Text(text = "This is my 1st text")
Icon(Icons.Default.KeyboardArrowRight, contentDescription = "")
Text(text = "This is my 2nd text")
Box(modifier = Modifier.size(16.dp).background(Color.Black))
Text(text = "This is my 3rd text")
}
}
@Composable
fun Marquee(
modifier: Modifier = Modifier,
gradientEdgeColor: Color = Color.White,
content: @Composable (Modifier) -> Unit
)
layout(
width = constraints.maxWidth,
height = mainText.height
) {
mainText.place(offset, 0)
secondPlaceableWithOffset?.let {
it.first.place(it.second, 0)
}
gradient?.place(0, 0)
}
if (mainText.width <= constraints.maxWidth) {
..
} else {
// horizontal spacing between the main and second text components
val spacing = constraints.maxWidth * 2 / 3
textLayoutInfoState.value = TextLayoutInfo(
textWidth = mainText.width + spacing,
containerWidth = constraints.maxWidth
)
if (mainText.width <= constraints.maxWidth) {
mainText = subcompose(MarqueeLayers.SecondaryText) {
createText(Modifier.fillMaxWidth())
}.first().measure(constraints)
textLayoutInfoState.value = null
}
var gradient: Placeable? = null
var secondPlaceableWithOffset: Pair<Placeable, Int>? = null