Skip to content

Commit

Permalink
[expo-av] Add support for passing custom styles to Video poster
Browse files Browse the repository at this point in the history
Fixes expo#4165
  • Loading branch information
sjchmiela committed May 9, 2019
1 parent f95a73e commit b3549b9
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
9 changes: 5 additions & 4 deletions build/Video.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class Video extends React.Component<VideoProps, VideoState> imple
static propTypes: {
hitSlop?: PropTypes.Validator<import("react-native").Insets | undefined> | undefined;
onLayout?: PropTypes.Validator<((event: import("react-native").LayoutChangeEvent) => void) | undefined> | undefined;
pointerEvents?: PropTypes.Validator<"box-none" | "none" | "box-only" | "auto" | undefined> | undefined;
pointerEvents?: PropTypes.Validator<"none" | "box-none" | "box-only" | "auto" | undefined> | undefined;
removeClippedSubviews?: PropTypes.Validator<boolean | undefined> | undefined;
style?: PropTypes.Validator<import("react-native").StyleProp<import("react-native").ViewStyle>> | undefined;
testID?: PropTypes.Validator<string | undefined> | undefined;
Expand Down Expand Up @@ -64,14 +64,14 @@ export default class Video extends React.Component<VideoProps, VideoState> imple
onTouchEndCapture?: PropTypes.Validator<((event: import("react-native").GestureResponderEvent) => void) | undefined> | undefined;
accessible?: PropTypes.Validator<boolean | undefined> | undefined;
accessibilityLabel?: PropTypes.Validator<string | undefined> | undefined;
accessibilityRole?: PropTypes.Validator<"button" | "header" | "link" | "summary" | "image" | "text" | "none" | "search" | "keyboardkey" | "adjustable" | "imagebutton" | undefined> | undefined;
accessibilityRole?: PropTypes.Validator<"none" | "button" | "header" | "link" | "summary" | "image" | "text" | "search" | "keyboardkey" | "adjustable" | "imagebutton" | undefined> | undefined;
accessibilityStates?: PropTypes.Validator<import("react-native").AccessibilityState[] | undefined> | undefined;
accessibilityHint?: PropTypes.Validator<string | undefined> | undefined;
accessibilityComponentType?: PropTypes.Validator<"button" | "none" | "radiobutton_checked" | "radiobutton_unchecked" | undefined> | undefined;
accessibilityComponentType?: PropTypes.Validator<"none" | "button" | "radiobutton_checked" | "radiobutton_unchecked" | undefined> | undefined;
accessibilityLiveRegion?: PropTypes.Validator<"none" | "polite" | "assertive" | undefined> | undefined;
importantForAccessibility?: PropTypes.Validator<"auto" | "yes" | "no" | "no-hide-descendants" | undefined> | undefined;
accessibilityElementsHidden?: PropTypes.Validator<boolean | undefined> | undefined;
accessibilityTraits?: PropTypes.Validator<"button" | "header" | "link" | "summary" | "image" | "text" | "none" | "search" | "adjustable" | "selected" | "disabled" | "plays" | "key" | "frequentUpdates" | "startsMedia" | "allowsDirectInteraction" | "pageTurn" | import("react-native").AccessibilityTrait[] | undefined> | undefined;
accessibilityTraits?: PropTypes.Validator<"key" | "none" | "button" | "header" | "link" | "summary" | "image" | "text" | "search" | "adjustable" | "selected" | "disabled" | "plays" | "frequentUpdates" | "startsMedia" | "allowsDirectInteraction" | "pageTurn" | import("react-native").AccessibilityTrait[] | undefined> | undefined;
onAccessibilityTap?: PropTypes.Validator<(() => void) | undefined> | undefined;
onMagicTap?: PropTypes.Validator<(() => void) | undefined> | undefined;
accessibilityIgnoresInvertColors?: PropTypes.Validator<boolean | undefined> | undefined;
Expand All @@ -82,6 +82,7 @@ export default class Video extends React.Component<VideoProps, VideoState> imple
posterSource: PropTypes.Requireable<number | PropTypes.InferProps<{
uri: PropTypes.Requireable<string>;
}>>;
posterStyle: PropTypes.Validator<import("react-native").StyleProp<import("react-native").ViewStyle>> | undefined;
onPlaybackStatusUpdate: PropTypes.Requireable<(...args: any[]) => any>;
onLoadStart: PropTypes.Requireable<(...args: any[]) => any>;
onLoad: PropTypes.Requireable<(...args: any[]) => any>;
Expand Down
3 changes: 2 additions & 1 deletion build/Video.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/Video.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion build/Video.types.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { View } from 'react-native';
import { View, StyleProp, ViewStyle } from 'react-native';
import { PlaybackNativeSource, PlaybackSource, PlaybackStatus, PlaybackStatusToSet } from './AV';
export declare type NaturalSize = {
width: number;
Expand All @@ -24,6 +24,7 @@ export declare type VideoProps = {
posterSource?: {
uri: string;
} | number;
posterStyle?: StyleProp<ViewStyle>;
onPlaybackStatusUpdate?: (status: PlaybackStatus) => void;
onLoadStart?: () => void;
onLoad?: (status: PlaybackStatus) => void;
Expand Down
2 changes: 1 addition & 1 deletion build/Video.types.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default class Video extends React.Component<VideoProps, VideoState> imple
}), // remote URI like { uri: 'http://foo/bar.mp4' }
PropTypes.number, // asset module like require('./foo/bar.mp4')
]),
posterStyle: ViewPropTypes.style,

// Callbacks
onPlaybackStatusUpdate: PropTypes.func,
Expand Down Expand Up @@ -364,7 +365,7 @@ export default class Video extends React.Component<VideoProps, VideoState> imple
_renderPoster = () =>
this.props.usePoster && this.state.showPoster ? (
// @ts-ignore: the react-native type declarations are overly restrictive
<Image style={_STYLES.poster} source={this.props.posterSource!} />
<Image style={[_STYLES.poster, this.props.posterStyle]} source={this.props.posterSource!} />
) : null;

render() {
Expand Down
3 changes: 2 additions & 1 deletion src/Video.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { View } from 'react-native';
import { View, StyleProp, ViewStyle } from 'react-native';

import { PlaybackNativeSource, PlaybackSource, PlaybackStatus, PlaybackStatusToSet } from './AV';
export type NaturalSize = {
Expand Down Expand Up @@ -28,6 +28,7 @@ export type VideoProps = {
// Source stuff
source?: PlaybackSource; // { uri: 'http://foo/bar.mp4' }, Asset, or require('./foo/bar.mp4')
posterSource?: { uri: string } | number; // { uri: 'http://foo/bar.mp4' } or require('./foo/bar.mp4')
posterStyle?: StyleProp<ViewStyle>;

// Callbacks
onPlaybackStatusUpdate?: (status: PlaybackStatus) => void;
Expand Down

0 comments on commit b3549b9

Please sign in to comment.