Skip to content

Commit

Permalink
fix: controller hidden back
Browse files Browse the repository at this point in the history
  • Loading branch information
huiqiangdev committed Apr 14, 2022
1 parent 4c3c25e commit d5f97d4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/ControllerTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ export type ControllerViewProps = {
onFull?: () => void;
title?: string;
onBack?: () => void;
/**
* 是否隐藏返回按钮
*/
isHiddenBack?: boolean;
/**
* 是否隐藏全屏返回按钮
*/
isHiddenFullBack?: boolean;
};
9 changes: 6 additions & 3 deletions src/ControllerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const ControllerView = ({
onSliderValueChange,
onBack,
title,
isHiddenBack = false,
isHiddenFullBack = false,
}: ControllerViewProps) => {
const [hide, setHide] = useState(false);
const [width, setWidth] = useState(0);
Expand Down Expand Up @@ -138,10 +140,11 @@ const ControllerView = ({
setWidth(e.nativeEvent.layout.width);
};
const renderContainer = () => {
const showBack = !isFull && !isHiddenBack;
if (isLoading) {
return (
<>
{!isFull && (
{showBack && (
<View style={styles.top}>
<TouchableOpacity onPress={onBack}>
<Image
Expand All @@ -161,7 +164,7 @@ const ControllerView = ({
if (hide) {
return (
<>
{!isFull && (
{showBack && (
<View style={styles.top}>
<TouchableOpacity onPress={onBack}>
<Image
Expand All @@ -183,7 +186,7 @@ const ControllerView = ({
)}`}</Text>
</View>
)}
{isFull ? (
{isFull && !isHiddenFullBack ? (
<View style={styles.top}>
<TouchableOpacity onPress={onFull}>
<Image
Expand Down
8 changes: 8 additions & 0 deletions src/PlayTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export type VideoPlayerProps = Omit<AliVideoViewProps, 'ref'> & {
onBufferProgress?: (progress: number) => void;
onPrepare?: (duration: number) => void;
isLandscape?: boolean;
/**
* 是否隐藏返回按钮
*/
isHiddenBack?: boolean;
/**
* 是否隐藏全屏返回按钮
*/
isHiddenFullBack?: boolean;
};
export type VideoPlayerHandler = {
play: () => void;
Expand Down
4 changes: 4 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const VideoPlayer = forwardRef(
onAliError,
onAliPrepared,
onAliRenderingStart,
isHiddenBack,
isHiddenFullBack,
...rest
}: VideoPlayerProps,
ref: React.Ref<VideoPlayerHandler>
Expand Down Expand Up @@ -241,6 +243,8 @@ const VideoPlayer = forwardRef(
current={currentTime}
isFull={isFull}
onFull={onFull}
isHiddenBack={isHiddenBack}
isHiddenFullBack={isHiddenFullBack}
buffer={buffer}
isError={false}
isLoading={loading}
Expand Down

0 comments on commit d5f97d4

Please sign in to comment.