Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复安卓播放页点击 topbar 所在的区域无法显示控制器 #981

Merged
merged 7 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemGestures
import androidx.compose.foundation.layout.systemGesturesPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsTopHeight
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.VolumeUp
import androidx.compose.material.icons.rounded.BrightnessHigh
Expand Down Expand Up @@ -83,6 +88,7 @@ import me.him188.ani.app.ui.foundation.effects.ComposeKey
import me.him188.ani.app.ui.foundation.effects.onKey
import me.him188.ani.app.ui.foundation.effects.onPointerEventMultiplatform
import me.him188.ani.app.ui.foundation.ifThen
import me.him188.ani.app.ui.foundation.layout.isSystemInFullscreen
import me.him188.ani.app.ui.foundation.theme.aniDarkColorTheme
import me.him188.ani.app.utils.fixToString
import me.him188.ani.app.videoplayer.ui.VideoControllerState
Expand Down Expand Up @@ -461,7 +467,6 @@ fun VideoGestureHost(
Box(
modifier
.focusRequester(keyboardFocus)
.padding(top = 60.dp)
.ifThen(family.swipeToSeek) {
swipeToSeek(seekerState, Orientation.Horizontal)
}
Expand Down Expand Up @@ -674,18 +679,9 @@ fun VideoGestureHost(
}
}

Box(
modifier
.testTag("VideoGestureHost")
.ifThen(needWorkaroundForFocusManager) {
onFocusEvent {
if (it.hasFocus) {
focusManager.clearFocus()
}
}
}
.padding(top = 60.dp)
.combinedClickable(
@Composable
fun Modifier.combineClickableWithFamilyGesture() = this then
combinedClickable(
remember { MutableInteractionSource() },
indication = null,
onClick = remember(family) {
Expand All @@ -710,6 +706,17 @@ fun VideoGestureHost(
}
},
)
Box(
modifier
.testTag("VideoGestureHost")
.ifThen(needWorkaroundForFocusManager) {
onFocusEvent {
if (it.hasFocus) {
focusManager.clearFocus()
}
}
}
.combineClickableWithFamilyGesture()
.ifThen(family.swipeToSeek && enableSwipeToSeek) {
val swipeToSeekRequester = rememberAlwaysOnRequester(controllerState, "swipeToSeek")
swipeToSeek(
Expand Down Expand Up @@ -766,6 +773,7 @@ fun VideoGestureHost(
) {
Row(
Modifier.matchParentSize()
.systemGesturesPadding()
.ifThen(family.longPressForFastSkip) {
longPressFastSkip(fastSkipState, SkipDirection.FORWARD)
},
Expand Down Expand Up @@ -815,6 +823,15 @@ fun VideoGestureHost(
)
}
}

// 状态栏区域响应点击手势
Box(
Modifier.fillMaxWidth()
.ifThen(isSystemInFullscreen()) {
windowInsetsTopHeight(WindowInsets.systemGestures)
}
.combineClickableWithFamilyGesture(),
)
}
}
}
Loading