mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
feat: Back gesture should hide controls in tv module
This commit is contained in:
@@ -2,14 +2,16 @@ package hu.bbara.purefin.tv.player
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.annotation.OptIn
|
import androidx.annotation.OptIn
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.animateColorAsState
|
||||||
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.slideInHorizontally
|
import androidx.compose.animation.slideInHorizontally
|
||||||
import androidx.compose.animation.slideOutHorizontally
|
import androidx.compose.animation.slideOutHorizontally
|
||||||
import androidx.compose.animation.animateColorAsState
|
import androidx.compose.foundation.Canvas
|
||||||
import androidx.compose.animation.core.animateFloatAsState
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
@@ -29,7 +31,6 @@ import androidx.compose.foundation.layout.width
|
|||||||
import androidx.compose.foundation.layout.widthIn
|
import androidx.compose.foundation.layout.widthIn
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.Canvas
|
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
@@ -119,6 +120,10 @@ fun TvPlayerScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BackHandler(enabled = controlsVisible) {
|
||||||
|
viewModel.hideControls()
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(uiState.isPlaying) {
|
LaunchedEffect(uiState.isPlaying) {
|
||||||
if (uiState.isPlaying) showQueuePanel = false
|
if (uiState.isPlaying) showQueuePanel = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,11 @@ class PlayerViewModel @Inject constructor(
|
|||||||
if (_controlsVisible.value) scheduleAutoHide()
|
if (_controlsVisible.value) scheduleAutoHide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hideControls() {
|
||||||
|
_controlsVisible.value = false
|
||||||
|
autoHideJob?.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
private fun scheduleAutoHide() {
|
private fun scheduleAutoHide() {
|
||||||
autoHideJob?.cancel()
|
autoHideJob?.cancel()
|
||||||
if (!player.isPlaying) return
|
if (!player.isPlaying) return
|
||||||
|
|||||||
Reference in New Issue
Block a user