Skip to content

Commit 3221263

Browse files
feat: add pin video to top pref
1 parent e5f1196 commit 3221263

11 files changed

Lines changed: 45 additions & 5 deletions

File tree

library/src/commonMain/kotlin/project/pipepipe/app/ui/screens/settings/PlayerSettingScreen.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ fun PlayerSettingScreen(
200200
summary = stringResource(MR.strings.start_main_player_fullscreen_summary),
201201
defaultValue = false
202202
),
203+
PreferenceItem.SwitchPref(
204+
key = "pin_video_to_top_key",
205+
title = stringResource(MR.strings.pin_video_to_top_title),
206+
summary = stringResource(MR.strings.pin_video_to_top_summary),
207+
defaultValue = true
208+
),
203209
PreferenceItem.ListPref(
204210
key = "autoplay_key",
205211
title = stringResource(MR.strings.autoplay_title),

library/src/commonMain/kotlin/project/pipepipe/app/ui/screens/videodetail/VideoDetailScreen.kt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import project.pipepipe.app.database.DatabaseOperations
4646
import project.pipepipe.app.helper.NetworkStateHelper
4747
import project.pipepipe.app.platform.ScreenOrientation
4848
import project.pipepipe.app.ui.component.*
49-
import project.pipepipe.app.ui.component.player.PlayerGestureSettings
5049
import project.pipepipe.app.ui.component.player.VideoPlayer
5150
import project.pipepipe.app.uistate.VideoDetailPageState
5251
import kotlin.math.min
@@ -249,6 +248,23 @@ fun VideoDetailScreen(modifier: Modifier, navController: NavHostController) {
249248
}
250249
}
251250

251+
// Monitor comments inner scroll enabled state
252+
var commentsInnerScrollEnabled by remember {
253+
mutableStateOf(SharedContext.settingsManager.getBoolean("pin_video_to_top_key", true))
254+
}
255+
256+
DisposableEffect(Unit) {
257+
val listener = SharedContext.settingsManager.addBooleanListener(
258+
"pin_video_to_top_key",
259+
true
260+
) { newValue ->
261+
commentsInnerScrollEnabled = newValue
262+
}
263+
onDispose {
264+
listener?.deactivate()
265+
}
266+
}
267+
252268
var configuredTabs by remember {
253269
mutableStateOf(SharedContext.settingsManager.getStringSet("video_tabs_key", setOf("comments", "related", "sponsorblock", "description")))
254270
}
@@ -453,14 +469,14 @@ fun VideoDetailScreen(modifier: Modifier, navController: NavHostController) {
453469
}
454470
} else if (controller != null) {
455471
// Normal state: show full video detail UI
456-
val isPortrait = screenOrientation == ScreenOrientation.PORTRAIT
472+
val shouldPlayerSticky = screenOrientation == ScreenOrientation.PORTRAIT && commentsInnerScrollEnabled
457473

458474
// Player composable content
459475
val playerContent: @Composable () -> Unit = {
460476
Box(
461477
modifier = Modifier
462478
.then(
463-
if (isPortrait) Modifier.aspectRatio(16f / 9f)
479+
if (shouldPlayerSticky) Modifier.aspectRatio(16f / 9f)
464480
else Modifier
465481
.height(200.dp)
466482
)
@@ -498,7 +514,7 @@ fun VideoDetailScreen(modifier: Modifier, navController: NavHostController) {
498514
}
499515
}
500516

501-
if (isPortrait) {
517+
if (shouldPlayerSticky) {
502518
// Portrait mode: Player is sticky (outside LazyColumn)
503519
playerContent()
504520
}
@@ -508,7 +524,7 @@ fun VideoDetailScreen(modifier: Modifier, navController: NavHostController) {
508524
.weight(1f),
509525
state = listState
510526
) {
511-
if (!isPortrait) {
527+
if (!shouldPlayerSticky) {
512528
// Landscape mode: Player participates in scrolling (inside LazyColumn)
513529
item { playerContent() }
514530
}

library/src/commonMain/moko-resources/base/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@
543543
<string name="playback_skip_silence_summary">Automatically skip silent parts during playback</string>
544544
<string name="start_main_player_fullscreen_title">Start in fullscreen</string>
545545
<string name="start_main_player_fullscreen_summary">Start playback in fullscreen directly</string>
546+
<string name="pin_video_to_top_title">Pin video to top</string>
547+
<string name="pin_video_to_top_summary">Keep the video player pinned to the top when scrolling. Only applies in portrait mode.</string>
546548
<string name="advanced_formats_title">Enable advanced formats</string>
547549
<string name="advanced_formats_summary">If your device has support, enabling advanced formats can reduce data
548550
consumption and provide higher resolutions. You may not be able to watch high resolution videos without enabling

library/src/commonMain/moko-resources/de/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,4 +586,6 @@
586586
<string name="clear_all">Alles löschen</string>
587587
<string name="clear_all_logs_message">Möchten Sie wirklich alle Fehlerprotokolle löschen?</string>
588588
<string name="clear_all_logs_title">Alle Protokolle löschen</string>
589+
<string name="pin_video_to_top_summary">Den Videoplayer beim Scrollen oben anheften. Gilt nur im Hochformat.</string>
590+
<string name="pin_video_to_top_title">Video oben anheften</string>
589591
</resources>

library/src/commonMain/moko-resources/es/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,4 +586,6 @@
586586
<string name="clear_all">Borrar todo</string>
587587
<string name="clear_all_logs_message">¿Estás seguro de que quieres borrar todos los registros de errores?</string>
588588
<string name="clear_all_logs_title">Borrar todos los registros</string>
589+
<string name="pin_video_to_top_summary">Mantener el reproductor de video anclado en la parte superior al desplazarse. Solo se aplica en modo vertical.</string>
590+
<string name="pin_video_to_top_title">Anclar video en la parte superior</string>
589591
</resources>

library/src/commonMain/moko-resources/fr/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,4 +586,6 @@
586586
<string name="clear_all">Tout effacer</string>
587587
<string name="clear_all_logs_message">Êtes-vous sûr de vouloir effacer tous les journaux d\'erreurs ?</string>
588588
<string name="clear_all_logs_title">Effacer tous les journaux</string>
589+
<string name="pin_video_to_top_summary">Garder le lecteur vidéo épinglé en haut lors du défilement. S\'applique uniquement en mode portrait.</string>
590+
<string name="pin_video_to_top_title">Épingler la vidéo en haut</string>
589591
</resources>

library/src/commonMain/moko-resources/it/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,4 +586,6 @@
586586
<string name="clear_all">Cancella tutto</string>
587587
<string name="clear_all_logs_message">Sei sicuro di voler cancellare tutti i log di errore?</string>
588588
<string name="clear_all_logs_title">Cancella tutti i log</string>
589+
<string name="pin_video_to_top_summary">Mantieni il riproduttore video bloccato in alto durante lo scorrimento. Si applica solo in modalità verticale.</string>
590+
<string name="pin_video_to_top_title">Blocca video in alto</string>
589591
</resources>

library/src/commonMain/moko-resources/ja/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,4 +586,6 @@
586586
<string name="clear_all">すべてクリア</string>
587587
<string name="clear_all_logs_message">すべてのエラーログをクリアしてもよろしいですか?</string>
588588
<string name="clear_all_logs_title">すべてのログをクリア</string>
589+
<string name="pin_video_to_top_summary">スクロール時に動画プレーヤーを上部に固定します。ポートレートモードでのみ適用されます。</string>
590+
<string name="pin_video_to_top_title">動画を上部に固定</string>
589591
</resources>

library/src/commonMain/moko-resources/vi/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,4 +586,6 @@
586586
<string name="clear_all">Xóa tất cả</string>
587587
<string name="clear_all_logs_message">Bạn có chắc chắn muốn xóa tất cả nhật ký lỗi không?</string>
588588
<string name="clear_all_logs_title">Xóa tất cả nhật ký</string>
589+
<string name="pin_video_to_top_summary">Giữ trình phát video được ghim ở trên cùng khi cuộn. Chỉ áp dụng ở chế độ dọc.</string>
590+
<string name="pin_video_to_top_title">Ghim video lên đầu</string>
589591
</resources>

library/src/commonMain/moko-resources/zh-CN/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,4 +586,6 @@
586586
<string name="clear_all">清除所有</string>
587587
<string name="clear_all_logs_message">您确定要清除所有错误日志吗?</string>
588588
<string name="clear_all_logs_title">清除所有日志</string>
589+
<string name="pin_video_to_top_summary">滚动时将视频播放器固定在顶部。仅适用于竖屏模式。</string>
590+
<string name="pin_video_to_top_title">将视频置顶</string>
589591
</resources>

0 commit comments

Comments
 (0)