Skip to content

Commit dd8ddd5

Browse files
Merge pull request Expensify#75899 from gijoe0295/gijoe/72505
fix: attachment arrows are hidden when playing video
2 parents 5f74dd2 + 34e14b4 commit dd8ddd5

6 files changed

Lines changed: 27 additions & 9 deletions

File tree

src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type AttachmentCarouselPagerContextValue = {
3737
isScrollEnabled: SharedValue<boolean>;
3838

3939
/** Function to call after a tap event */
40-
onTap?: () => void;
40+
onTap?: (shouldShowArrows?: boolean) => void;
4141

4242
/** Function to call when the scale changes */
4343
onScaleChanged?: (scale: number) => void;

src/components/Attachments/AttachmentCarousel/useCarouselContextEvents.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ function useCarouselContextEvents(setShouldShowArrows?: (show?: SetStateAction<b
4949
* This callback is passed to the MultiGestureCanvas/Lightbox through the AttachmentCarouselPagerContext.
5050
* It is used to trigger touch events on the pager when the user taps on the MultiGestureCanvas/Lightbox.
5151
*/
52-
const handleTap = useCallback(() => {
53-
if (!isScrollEnabled.get()) {
54-
return;
55-
}
52+
const handleTap = useCallback(
53+
(shouldShowArrows?: boolean) => {
54+
if (!isScrollEnabled.get()) {
55+
return;
56+
}
5657

57-
onRequestToggleArrows();
58-
}, [isScrollEnabled, onRequestToggleArrows]);
58+
onRequestToggleArrows(shouldShowArrows);
59+
},
60+
[isScrollEnabled, onRequestToggleArrows],
61+
);
5962

6063
return {handleTap, handleScaleChange, scale, isScrollEnabled};
6164
}

src/components/Attachments/AttachmentView/AttachmentViewVideo/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ type AttachmentViewVideoProps = Pick<AttachmentViewProps, 'duration' | 'isHovere
1212

1313
/** The reportID related to the attachment */
1414
reportID?: string;
15+
16+
/** Callback function to call when the video is tap */
17+
onTap?: (shouldShowArrows?: boolean) => void;
1518
};
1619

17-
function AttachmentViewVideo({source, isHovered = false, shouldUseSharedVideoElement = false, duration = 0, reportID}: AttachmentViewVideoProps) {
20+
function AttachmentViewVideo({source, isHovered = false, shouldUseSharedVideoElement = false, duration = 0, reportID, onTap}: AttachmentViewVideoProps) {
1821
const {shouldUseNarrowLayout} = useResponsiveLayout();
1922
const styles = useThemeStyles();
2023

@@ -26,6 +29,7 @@ function AttachmentViewVideo({source, isHovered = false, shouldUseSharedVideoEle
2629
videoDuration={duration}
2730
style={[styles.w100, styles.h100, styles.pb5]}
2831
reportID={reportID}
32+
onTap={onTap}
2933
/>
3034
);
3135
}

src/components/Attachments/AttachmentView/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function AttachmentView({
140140
const {updateCurrentURLAndReportID, currentlyPlayingURL, playVideo} = usePlaybackContext();
141141

142142
const attachmentCarouselPagerContext = useContext(AttachmentCarouselPagerContext);
143-
const {onAttachmentError} = attachmentCarouselPagerContext ?? {};
143+
const {onAttachmentError, onTap} = attachmentCarouselPagerContext ?? {};
144144
const theme = useTheme();
145145
const {safeAreaPaddingBottomStyle} = useSafeAreaPaddings();
146146
const styles = useThemeStyles();
@@ -366,6 +366,7 @@ function AttachmentView({
366366
isHovered={isHovered}
367367
duration={duration}
368368
reportID={reportID}
369+
onTap={onTap}
369370
/>
370371
);
371372
}

src/components/VideoPlayer/BaseVideoPlayer.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function BaseVideoPlayer({
5555
isVideoHovered = false,
5656
isPreview,
5757
reportID,
58+
onTap,
5859
}: VideoPlayerProps & {reportID: string}) {
5960
const styles = useThemeStyles();
6061
const {
@@ -153,6 +154,14 @@ function BaseVideoPlayer({
153154
debouncedHideControl();
154155
}, [isPlaying, debouncedHideControl, controlStatusState, isPopoverVisible, canUseTouchScreen]);
155156

157+
useEffect(() => {
158+
if (!onTap || !controlStatusState) {
159+
return;
160+
}
161+
const shouldShowArrows = controlStatusState === CONST.VIDEO_PLAYER.CONTROLS_STATUS.SHOW || controlStatusState === CONST.VIDEO_PLAYER.CONTROLS_STATUS.VOLUME_ONLY;
162+
onTap(shouldShowArrows);
163+
}, [controlStatusState, onTap]);
164+
156165
const stopWheelPropagation = useCallback((ev: WheelEvent) => ev.stopPropagation(), []);
157166

158167
const toggleControl = useCallback(() => {

src/components/VideoPlayer/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type VideoPlayerProps = {
3131
shouldPlay?: boolean;
3232
isPreview?: boolean;
3333
reportID?: string;
34+
onTap?: (shouldShowArrows?: boolean) => void;
3435
};
3536

3637
export type {VideoPlayerProps, VideoWithOnFullScreenUpdate};

0 commit comments

Comments
 (0)