Skip to content

Commit

Permalink
feat support expo wip
Browse files Browse the repository at this point in the history
  • Loading branch information
xcarpentier committed Jan 29, 2019
1 parent 8ba836a commit d9c77f2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
29 changes: 13 additions & 16 deletions src/MessageVideo.js
@@ -1,30 +1,28 @@
/* eslint global-require: 0 */

import PropTypes from 'prop-types';
import React from 'react';
import { StyleSheet, View, ViewPropTypes } from 'react-native';
import { isExpo } from './utils';

let Video;
if(isExpo()) {
const { Video as ExpoVideo } = require('expo')
Video = ExpoVideo
} else {
Video = require('react-native-video')
if (isExpo()) {
const Expo = require('expo');
const { Video: ExpoVideo } = Expo;
Video = ExpoVideo;
} else {
Video = require('react-native-video');
}


export default function MessageVideo({
containerStyle,
videoProps,
videoStyle,
currentMessage,
}) {
export default function MessageVideo({ containerStyle, videoProps, videoStyle, currentMessage }) {
return (
// eslint-disable-next-line no-use-before-define
<View style={[styles.container, containerStyle]}>

<Video
{...videoProps}
ref={(r) => { this.player = r; }}
ref={(r) => {
this.player = r;
}}
source={{ uri: currentMessage.video }}
style={videoStyle}
resizeMode="cover"
Expand All @@ -37,8 +35,7 @@ export default function MessageVideo({
}

const styles = StyleSheet.create({
container: {
},
container: {},
});

MessageVideo.defaultProps = {
Expand Down
6 changes: 5 additions & 1 deletion src/__tests__/utils.test.js
@@ -1,4 +1,4 @@
import { isSameDay, isSameUser } from '../utils';
import { isSameDay, isSameUser, isExpo } from '../utils';

it('should test if same day', () => {
const now = new Date();
Expand All @@ -9,3 +9,7 @@ it('should test if same user', () => {
const message = { user: { _id: 1 } };
expect(isSameUser(message, message)).toBe(true);
});

it('should test if isExpo', () => {
expect(isExpo()).toBe(false);
});
4 changes: 1 addition & 3 deletions src/utils.js
Expand Up @@ -20,7 +20,5 @@ export function isSameUser(currentMessage = {}, diffMessage = {}) {
}

export function isExpo() {
return global.__exponent || global.__expo;
return !!global && (!!global.__exponent || !!global.__expo);
}


0 comments on commit d9c77f2

Please sign in to comment.