mirror of
https://github.com/zhigang1992/react-native-gifted-chat.git
synced 2026-01-12 22:50:22 +08:00
feat support expo wip
This commit is contained in:
@@ -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"
|
||||
@@ -37,8 +35,7 @@ export default function MessageVideo({
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
},
|
||||
container: {},
|
||||
});
|
||||
|
||||
MessageVideo.defaultProps = {
|
||||
|
||||
@@ -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();
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -20,7 +20,5 @@ export function isSameUser(currentMessage = {}, diffMessage = {}) {
|
||||
}
|
||||
|
||||
export function isExpo() {
|
||||
return global.__exponent || global.__expo;
|
||||
return !!global && (!!global.__exponent || !!global.__expo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user