Adding support to youtube videos.
This commit is contained in:
@@ -2,13 +2,22 @@ import React from "react";
|
|||||||
import { View, ImageBackground } from "react-native";
|
import { View, ImageBackground } from "react-native";
|
||||||
import { Text, TextInput, Button, Divider, Checkbox } from "react-native-paper";
|
import { Text, TextInput, Button, Divider, Checkbox } from "react-native-paper";
|
||||||
import i18n from "../i18nMessages.js";
|
import i18n from "../i18nMessages.js";
|
||||||
import { useSnapshot } from 'valtio';
|
import API from "../API";
|
||||||
import GlobalState from '../contexts/GlobalState.js';
|
|
||||||
|
|
||||||
|
|
||||||
let InviteView = ()=>{
|
let InviteView = ()=>{
|
||||||
const gState = useSnapshot(GlobalState);
|
const [name, setName] = React.useState("");
|
||||||
const viewer = gState.me;
|
const [email, setEmail] = React.useState("");
|
||||||
|
const [checked, setChecked] = React.useState("");
|
||||||
|
|
||||||
|
let sendInvite = async () => {
|
||||||
|
if(name != "" && email != "") return 0;
|
||||||
|
setName('');
|
||||||
|
setEmail('');
|
||||||
|
setChecked(false);
|
||||||
|
await API.newInvitation(name, email);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{
|
<View style={{
|
||||||
padding: 10,
|
padding: 10,
|
||||||
@@ -22,16 +31,20 @@ let InviteView = ()=>{
|
|||||||
<TextInput
|
<TextInput
|
||||||
label={i18n.t("message.name")}
|
label={i18n.t("message.name")}
|
||||||
style={{backgroundColor:"rgba(0,0,0,0)"}}
|
style={{backgroundColor:"rgba(0,0,0,0)"}}
|
||||||
value={''}
|
value={name}
|
||||||
//onChangeText={text => setText(text)}
|
onChangeText={text => setName(text)}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
label={i18n.t("message.email")}
|
label={i18n.t("message.email")}
|
||||||
style={{backgroundColor:"rgba(0,0,0,0)"}}
|
style={{backgroundColor:"rgba(0,0,0,0)"}}
|
||||||
value={''}
|
value={email}
|
||||||
//onChangeText={text => setText(text)}
|
onChangeText={text => setEmail(text)}
|
||||||
|
/>
|
||||||
|
<Checkbox.Item
|
||||||
|
label={i18n.t("message.IKnowThisPerson")}
|
||||||
|
status={checked ? "checked" : "unchecked"}
|
||||||
|
onPress={()=>{setChecked(!checked)}}
|
||||||
/>
|
/>
|
||||||
<Checkbox.Item label={i18n.t("message.IKnowThisPerson")} status="checked" />
|
|
||||||
<Divider />
|
<Divider />
|
||||||
<Button mode="outlined">Invite</Button>
|
<Button mode="outlined">Invite</Button>
|
||||||
</ImageBackground>
|
</ImageBackground>
|
||||||
|
|||||||
@@ -8,13 +8,20 @@ import { WebView } from 'react-native-webview';
|
|||||||
|
|
||||||
const videoIdF = (content) => {
|
const videoIdF = (content) => {
|
||||||
let vimeoTag = content.match(/@vimeo:[0-9]+/);
|
let vimeoTag = content.match(/@vimeo:[0-9]+/);
|
||||||
let youtubeTag = content.match(/@youtube:[0-z]+/);
|
if (!vimeoTag) return [];
|
||||||
if (!vimeoTag && !youtubeTag) return [];
|
let tag = vimeoTag;
|
||||||
let tag = youtubeTag || vimeoTag || hslTag;
|
|
||||||
tag = tag[0].substring(1);
|
tag = tag[0].substring(1);
|
||||||
return tag.split(':');
|
return tag.split(':');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const youtubeIdF = (content) => {
|
||||||
|
let youtubeTag = content.match(/@youtube:[0-z]+/);
|
||||||
|
if (!youtubeTag) return '';
|
||||||
|
let tag = youtubeTag;
|
||||||
|
tag = tag[0].substring(1);
|
||||||
|
return tag.split(':')[1];
|
||||||
|
};
|
||||||
|
|
||||||
const hlsIdF = (content) => {
|
const hlsIdF = (content) => {
|
||||||
let hslTag = content.match(/@hls:.+\w/);
|
let hslTag = content.match(/@hls:.+\w/);
|
||||||
if (!hslTag) return '';
|
if (!hslTag) return '';
|
||||||
@@ -51,6 +58,7 @@ let Media = (props) => {
|
|||||||
const videosId = videoIdF(props.content);
|
const videosId = videoIdF(props.content);
|
||||||
const hlsUrl = hlsIdF(props.content);
|
const hlsUrl = hlsIdF(props.content);
|
||||||
const iframeSrc = iframeTagF(props.content) || [];
|
const iframeSrc = iframeTagF(props.content) || [];
|
||||||
|
const youtubeId = youtubeIdF(props.content);
|
||||||
const [videosFiles, setVideosFiles] = useState([]);
|
const [videosFiles, setVideosFiles] = useState([]);
|
||||||
const [poster, setPoster] = useState('');
|
const [poster, setPoster] = useState('');
|
||||||
const [loaded, setLoaded] = useState(false);
|
const [loaded, setLoaded] = useState(false);
|
||||||
@@ -97,6 +105,11 @@ let Media = (props) => {
|
|||||||
style={styles.iframe}
|
style={styles.iframe}
|
||||||
source={{ uri: iframeSrc[1] }}
|
source={{ uri: iframeSrc[1] }}
|
||||||
/> : <></>;
|
/> : <></>;
|
||||||
|
const youtubeEmb = youtubeId.length ?
|
||||||
|
<WebView
|
||||||
|
style={styles.iframe}
|
||||||
|
source={{ uri: "https://www.youtube.com/embed/" + youtubeId + "?fs=0" }}
|
||||||
|
/> : <></>;
|
||||||
const renderImages = (({ item }) => {
|
const renderImages = (({ item }) => {
|
||||||
return (<Image source={{ uri: item[1] }} style={styles.flatlistImages} />);
|
return (<Image source={{ uri: item[1] }} style={styles.flatlistImages} />);
|
||||||
});
|
});
|
||||||
@@ -125,6 +138,7 @@ let Media = (props) => {
|
|||||||
{video}
|
{video}
|
||||||
{video2}
|
{video2}
|
||||||
{iframe}
|
{iframe}
|
||||||
|
{youtubeEmb}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ let Post = (props) => {
|
|||||||
return (
|
return (
|
||||||
<Card style={styles.card}>
|
<Card style={styles.card}>
|
||||||
<Card.Content>
|
<Card.Content>
|
||||||
<Hyperlink linkDefault={ true } linkStyle={{}}>
|
<Hyperlink linkDefault={ true } linkStyle={ { color: '#2980b9'} }>
|
||||||
{!post.nonOrganicType ?
|
{!post.nonOrganicType ?
|
||||||
<View>
|
<View>
|
||||||
<Text style={styles.userName}>
|
<Text style={styles.userName}>
|
||||||
|
|||||||
Reference in New Issue
Block a user