File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
feature/foryou/src/main/java/com/m3u/feature/foryou Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 11package com.m3u.feature.foryou.components
22
33import androidx.compose.animation.animateColorAsState
4+ import androidx.compose.animation.core.tween
45import androidx.compose.foundation.background
56import androidx.compose.foundation.isSystemInDarkTheme
67import androidx.compose.foundation.layout.aspectRatio
@@ -55,7 +56,8 @@ internal fun HeadlineBackground(modifier: Modifier = Modifier) {
5556 stop = colorScheme.surface,
5657 fraction = fraction
5758 ),
58- label = " headline-background-mask-color"
59+ label = " headline-background-mask-color" ,
60+ animationSpec = tween(800 )
5961 )
6062
6163 if (! preferences.noPictureMode && ! preferences.colorfulBackground) {
Original file line number Diff line number Diff line change 1+ package com.m3u.feature.foryou.internal
2+
3+ import android.content.Context
4+ import android.hardware.Sensor
5+ import android.hardware.SensorEvent
6+ import android.hardware.SensorEventListener
7+ import android.hardware.SensorManager
8+ import androidx.compose.runtime.Composable
9+ import androidx.compose.runtime.State
10+ import androidx.compose.runtime.produceState
11+ import androidx.compose.ui.geometry.Offset
12+ import androidx.compose.ui.platform.LocalContext
13+
14+ @Composable
15+ internal fun produceSensorOffset (
16+ context : Context = LocalContext .current
17+ ): State <Offset > = produceState(
18+ initialValue = Offset .Zero
19+ ) {
20+ val manager = context.getSystemService(Context .SENSOR_SERVICE ) as SensorManager
21+ val listener = object : SensorEventListener {
22+ override fun onSensorChanged (event : SensorEvent ) {
23+ val (x, y, _) = event.values
24+ value = Offset (x, y)
25+ }
26+
27+ override fun onAccuracyChanged (sensor : Sensor , accuracy : Int ) {}
28+ }
29+ val sensor = manager.getDefaultSensor(Sensor .TYPE_ROTATION_VECTOR )
30+ manager.registerListener(
31+ listener,
32+ sensor,
33+ SensorManager .SENSOR_DELAY_NORMAL
34+ )
35+ awaitDispose {
36+ manager.unregisterListener(listener)
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments