[update] New full screen switching mechanism

This commit is contained in:
acite
2025-09-23 13:21:51 +08:00
parent 49751c55d9
commit c9c3306766
3 changed files with 7 additions and 25 deletions

View File

@@ -51,6 +51,7 @@ dependencies {
implementation(libs.hilt.android) implementation(libs.hilt.android)
implementation(libs.hilt.navigation.compose) implementation(libs.hilt.navigation.compose)
implementation(libs.androidx.compose.material.core)
ksp(libs.hilt.android.compiler) ksp(libs.hilt.android.compiler)
implementation(libs.androidx.room.runtime) implementation(libs.androidx.room.runtime)

View File

@@ -112,6 +112,7 @@ import androidx.compose.ui.unit.sp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.media3.common.text.Cue import androidx.media3.common.text.Cue
import androidx.media3.common.util.UnstableApi import androidx.media3.common.util.UnstableApi
import androidx.wear.compose.materialcore.screenHeightDp
import coil3.ImageLoader import coil3.ImageLoader
import coil3.compose.AsyncImage import coil3.compose.AsyncImage
import coil3.request.ImageRequest import coil3.request.ImageRequest
@@ -686,7 +687,7 @@ fun PortalCorePlayer(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewMo
.padding(start = 12.dp) .padding(start = 12.dp)
) )
IconButton( /* IconButton(
onClick = { onClick = {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
}, },
@@ -700,7 +701,7 @@ fun PortalCorePlayer(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewMo
tint = Color.White, tint = Color.White,
modifier = Modifier.size(32.dp) modifier = Modifier.size(32.dp)
) )
} } */
} }
} }
@@ -1077,10 +1078,6 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel) {
) )
} }
BackHandler {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
ToggleFullScreen(true) ToggleFullScreen(true)
Box(Modifier.fillMaxSize()) Box(Modifier.fillMaxSize())
{ {
@@ -1341,7 +1338,6 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel) {
Row( Row(
Modifier Modifier
.align(Alignment.TopStart) .align(Alignment.TopStart)
.padding(horizontal = 42.dp)
.background( .background(
brush = Brush.verticalGradient( brush = Brush.verticalGradient(
colors = listOf( colors = listOf(
@@ -1352,28 +1348,11 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel) {
) )
) )
{ {
IconButton(
onClick = {
activity?.requestedOrientation =
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
},
modifier = Modifier
.size(36.dp)
.align(Alignment.CenterVertically)
) {
Icon(
modifier = Modifier.size(36.dp),
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = "Back",
tint = Color.White
)
}
Text( Text(
text = "${videoPlayerViewModel.video?.video?.name}", text = "${videoPlayerViewModel.video?.video?.name}",
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
modifier = Modifier modifier = Modifier
.padding(horizontal = 12.dp) .padding(horizontal = 52.dp)
.align(Alignment.CenterVertically), .align(Alignment.CenterVertically),
fontSize = 18.sp fontSize = 18.sp
) )

View File

@@ -36,6 +36,7 @@ roomRuntime = "2.8.0"
ksp = "2.1.21-2.0.2" ksp = "2.1.21-2.0.2"
hilt = "2.57.1" hilt = "2.57.1"
hilt-navigation-compose = "1.3.0" hilt-navigation-compose = "1.3.0"
composeMaterialCore = "1.5.1"
[libraries] [libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -78,6 +79,7 @@ androidx-media3-datasource-okhttp = { group = "androidx.media3", name = "media3-
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" } hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
hilt-android-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" } hilt-android-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hilt-navigation-compose" } hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hilt-navigation-compose" }
androidx-compose-material-core = { group = "androidx.wear.compose", name = "compose-material-core", version.ref = "composeMaterialCore" }
[plugins] [plugins]
android-application = { id = "com.android.application", version.ref = "agp" } android-application = { id = "com.android.application", version.ref = "agp" }