1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00
Respect system's reduced motion enabled setting
This commit is contained in:
xmflsct
2022-12-09 00:48:34 +01:00
parent 4a28d47b41
commit 44f83e44b9
3 changed files with 15 additions and 12 deletions

View File

@ -7,6 +7,7 @@ import { Blurhash } from 'react-native-blurhash'
import attachmentAspectRatio from './aspectRatio'
import AttachmentAltText from './AltText'
import { Platform } from 'expo-modules-core'
import { useAccessibility } from '@utils/accessibility/AccessibilityManager'
export interface Props {
total: number
@ -23,6 +24,8 @@ const AttachmentVideo: React.FC<Props> = ({
video,
gifv = false
}) => {
const { reduceMotionEnabled } = useAccessibility()
const videoPlayer = useRef<Video>(null)
const [videoLoading, setVideoLoading] = useState(false)
const [videoLoaded, setVideoLoaded] = useState(false)
@ -57,7 +60,7 @@ const AttachmentVideo: React.FC<Props> = ({
resizeMode={videoResizeMode}
{...(gifv
? {
shouldPlay: true,
shouldPlay: reduceMotionEnabled ? false : true,
isMuted: true,
isLooping: true,
source: { uri: video.url }
@ -70,10 +73,10 @@ const AttachmentVideo: React.FC<Props> = ({
onFullscreenUpdate={event => {
if (event.fullscreenUpdate === VideoFullscreenUpdate.PLAYER_DID_DISMISS) {
Platform.OS === 'android' && setVideoResizeMode(ResizeMode.COVER)
if (!gifv) {
videoPlayer.current?.pauseAsync()
} else {
if (gifv && !reduceMotionEnabled) {
videoPlayer.current?.playAsync()
} else {
videoPlayer.current?.pauseAsync()
}
}
}}
@ -103,7 +106,7 @@ const AttachmentVideo: React.FC<Props> = ({
video.blurhash ? (
<Blurhash blurhash={video.blurhash} style={{ width: '100%', height: '100%' }} />
) : null
) : !gifv ? (
) : !gifv || (gifv && reduceMotionEnabled) ? (
<Button
round
overlay