be-components 5.1.8 → 5.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/Components/Icons.js +28 -1
- package/lib/commonjs/Components/Icons.js.map +1 -1
- package/lib/commonjs/Components/Themed.js +13 -1
- package/lib/commonjs/Components/Themed.js.map +1 -1
- package/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.js +47 -24
- package/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.js.map +1 -1
- package/lib/commonjs/SocialComponents/FormattedTextInput/index.js +41 -8
- package/lib/commonjs/SocialComponents/FormattedTextInput/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/GifSelector/NativeSelector.js +14 -0
- package/lib/commonjs/SocialComponents/GifSelector/NativeSelector.js.map +1 -0
- package/lib/commonjs/SocialComponents/GifSelector/WebSelector.js +123 -0
- package/lib/commonjs/SocialComponents/GifSelector/WebSelector.js.map +1 -0
- package/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.js +89 -0
- package/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.js.map +1 -0
- package/lib/commonjs/SocialComponents/GroupChat/index.js +426 -0
- package/lib/commonjs/SocialComponents/GroupChat/index.js.map +1 -0
- package/lib/commonjs/SocialComponents/ImageRenderer.js +55 -0
- package/lib/commonjs/SocialComponents/ImageRenderer.js.map +1 -0
- package/lib/commonjs/SocialComponents/InputBar/components/ActionSelector.js +219 -0
- package/lib/commonjs/SocialComponents/InputBar/components/ActionSelector.js.map +1 -0
- package/lib/commonjs/SocialComponents/InputBar/index.js +59 -5
- package/lib/commonjs/SocialComponents/InputBar/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/PostCard/components/ArticleCard.js +2 -0
- package/lib/commonjs/SocialComponents/PostCard/components/ArticleCard.js.map +1 -0
- package/lib/commonjs/SocialComponents/PostCard/components/ImageList.js +37 -25
- package/lib/commonjs/SocialComponents/PostCard/components/ImageList.js.map +1 -1
- package/lib/commonjs/SocialComponents/PostCard/index.js +148 -70
- package/lib/commonjs/SocialComponents/PostCard/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/Poster/index.js +325 -0
- package/lib/commonjs/SocialComponents/Poster/index.js.map +1 -0
- package/lib/commonjs/SocialComponents/SocialOrderCard.js +8 -3
- package/lib/commonjs/SocialComponents/SocialOrderCard.js.map +1 -1
- package/lib/commonjs/SocialComponents/SocialOrdersList.js +20 -2
- package/lib/commonjs/SocialComponents/SocialOrdersList.js.map +1 -1
- package/lib/commonjs/SocialComponents/UrlPreviewCard.js +115 -0
- package/lib/commonjs/SocialComponents/UrlPreviewCard.js.map +1 -0
- package/lib/commonjs/SocialComponents/api/index.js +383 -0
- package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/index.js +14 -0
- package/lib/commonjs/SocialComponents/index.js.map +1 -1
- package/lib/module/Components/Icons.js +28 -1
- package/lib/module/Components/Icons.js.map +1 -1
- package/lib/module/Components/Themed.js +13 -1
- package/lib/module/Components/Themed.js.map +1 -1
- package/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.js +48 -25
- package/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.js.map +1 -1
- package/lib/module/SocialComponents/FormattedTextInput/index.js +41 -8
- package/lib/module/SocialComponents/FormattedTextInput/index.js.map +1 -1
- package/lib/module/SocialComponents/GifSelector/NativeSelector.js +7 -0
- package/lib/module/SocialComponents/GifSelector/NativeSelector.js.map +1 -0
- package/lib/module/SocialComponents/GifSelector/WebSelector.js +125 -0
- package/lib/module/SocialComponents/GifSelector/WebSelector.js.map +1 -0
- package/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.js +82 -0
- package/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.js.map +1 -0
- package/lib/module/SocialComponents/GroupChat/index.js +418 -0
- package/lib/module/SocialComponents/GroupChat/index.js.map +1 -0
- package/lib/module/SocialComponents/ImageRenderer.js +48 -0
- package/lib/module/SocialComponents/ImageRenderer.js.map +1 -0
- package/lib/module/SocialComponents/InputBar/components/ActionSelector.js +210 -0
- package/lib/module/SocialComponents/InputBar/components/ActionSelector.js.map +1 -0
- package/lib/module/SocialComponents/InputBar/index.js +58 -6
- package/lib/module/SocialComponents/InputBar/index.js.map +1 -1
- package/lib/module/SocialComponents/PostCard/components/ArticleCard.js +2 -0
- package/lib/module/SocialComponents/PostCard/components/ArticleCard.js.map +1 -0
- package/lib/module/SocialComponents/PostCard/components/ImageList.js +37 -25
- package/lib/module/SocialComponents/PostCard/components/ImageList.js.map +1 -1
- package/lib/module/SocialComponents/PostCard/index.js +148 -70
- package/lib/module/SocialComponents/PostCard/index.js.map +1 -1
- package/lib/module/SocialComponents/Poster/index.js +316 -0
- package/lib/module/SocialComponents/Poster/index.js.map +1 -0
- package/lib/module/SocialComponents/SocialOrderCard.js +8 -3
- package/lib/module/SocialComponents/SocialOrderCard.js.map +1 -1
- package/lib/module/SocialComponents/SocialOrdersList.js +21 -3
- package/lib/module/SocialComponents/SocialOrdersList.js.map +1 -1
- package/lib/module/SocialComponents/UrlPreviewCard.js +106 -0
- package/lib/module/SocialComponents/UrlPreviewCard.js.map +1 -0
- package/lib/module/SocialComponents/api/index.js +383 -0
- package/lib/module/SocialComponents/api/index.js.map +1 -1
- package/lib/module/SocialComponents/index.js +3 -1
- package/lib/module/SocialComponents/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/Components/Icons.d.ts +5 -0
- package/lib/typescript/lib/commonjs/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Components/Themed.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.d.ts +2 -1
- package/lib/typescript/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/FormattedTextInput/index.d.ts +6 -1
- package/lib/typescript/lib/commonjs/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/GifSelector/NativeSelector.d.ts +4 -0
- package/lib/typescript/lib/commonjs/SocialComponents/GifSelector/NativeSelector.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/GifSelector/WebSelector.d.ts +4 -0
- package/lib/typescript/lib/commonjs/SocialComponents/GifSelector/WebSelector.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.d.ts +11 -0
- package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/index.d.ts +14 -0
- package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/ImageRenderer.d.ts +11 -0
- package/lib/typescript/lib/commonjs/SocialComponents/ImageRenderer.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/InputBar/components/ActionSelector.d.ts +9 -0
- package/lib/typescript/lib/commonjs/SocialComponents/InputBar/components/ActionSelector.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/InputBar/index.d.ts +3 -1
- package/lib/typescript/lib/commonjs/SocialComponents/InputBar/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/PostCard/components/ArticleCard.d.ts +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/PostCard/components/ArticleCard.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/PostCard/components/ImageList.d.ts +1 -2
- package/lib/typescript/lib/commonjs/SocialComponents/PostCard/components/ImageList.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/PostCard/index.d.ts +4 -1
- package/lib/typescript/lib/commonjs/SocialComponents/PostCard/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/Poster/index.d.ts +9 -0
- package/lib/typescript/lib/commonjs/SocialComponents/Poster/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/SocialOrderCard.d.ts +2 -1
- package/lib/typescript/lib/commonjs/SocialComponents/SocialOrderCard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/SocialOrdersList.d.ts +2 -1
- package/lib/typescript/lib/commonjs/SocialComponents/SocialOrdersList.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/UrlPreviewCard.d.ts +9 -0
- package/lib/typescript/lib/commonjs/SocialComponents/UrlPreviewCard.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/api/index.d.ts +89 -0
- package/lib/typescript/lib/commonjs/SocialComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/index.d.ts +2 -0
- package/lib/typescript/lib/module/Components/Icons.d.ts +5 -0
- package/lib/typescript/lib/module/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/lib/module/Components/Themed.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.d.ts +3 -2
- package/lib/typescript/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/FormattedTextInput/index.d.ts +6 -1
- package/lib/typescript/lib/module/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/GifSelector/NativeSelector.d.ts +4 -0
- package/lib/typescript/lib/module/SocialComponents/GifSelector/NativeSelector.d.ts.map +1 -0
- package/lib/typescript/lib/module/SocialComponents/GifSelector/WebSelector.d.ts +13 -0
- package/lib/typescript/lib/module/SocialComponents/GifSelector/WebSelector.d.ts.map +1 -0
- package/lib/typescript/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.d.ts +11 -0
- package/lib/typescript/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.d.ts.map +1 -0
- package/lib/typescript/lib/module/SocialComponents/GroupChat/index.d.ts +14 -0
- package/lib/typescript/lib/module/SocialComponents/GroupChat/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/SocialComponents/ImageRenderer.d.ts +11 -0
- package/lib/typescript/lib/module/SocialComponents/ImageRenderer.d.ts.map +1 -0
- package/lib/typescript/lib/module/SocialComponents/InputBar/components/ActionSelector.d.ts +10 -0
- package/lib/typescript/lib/module/SocialComponents/InputBar/components/ActionSelector.d.ts.map +1 -0
- package/lib/typescript/lib/module/SocialComponents/InputBar/index.d.ts +3 -1
- package/lib/typescript/lib/module/SocialComponents/InputBar/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/PostCard/components/ArticleCard.d.ts +1 -0
- package/lib/typescript/lib/module/SocialComponents/PostCard/components/ArticleCard.d.ts.map +1 -0
- package/lib/typescript/lib/module/SocialComponents/PostCard/components/ImageList.d.ts +1 -2
- package/lib/typescript/lib/module/SocialComponents/PostCard/components/ImageList.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/PostCard/index.d.ts +4 -1
- package/lib/typescript/lib/module/SocialComponents/PostCard/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/Poster/index.d.ts +11 -0
- package/lib/typescript/lib/module/SocialComponents/Poster/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/SocialComponents/SocialOrderCard.d.ts +3 -2
- package/lib/typescript/lib/module/SocialComponents/SocialOrderCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/SocialOrdersList.d.ts +2 -1
- package/lib/typescript/lib/module/SocialComponents/SocialOrdersList.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/UrlPreviewCard.d.ts +9 -0
- package/lib/typescript/lib/module/SocialComponents/UrlPreviewCard.d.ts.map +1 -0
- package/lib/typescript/lib/module/SocialComponents/api/index.d.ts +89 -0
- package/lib/typescript/lib/module/SocialComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/index.d.ts +3 -1
- package/lib/typescript/lib/module/SocialComponents/index.d.ts.map +1 -1
- package/lib/typescript/src/Components/Icons.d.ts +1 -0
- package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/src/Components/Themed.d.ts +1 -0
- package/lib/typescript/src/Components/Themed.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/FormattedTextInput/components/TagSelector.d.ts +2 -1
- package/lib/typescript/src/SocialComponents/FormattedTextInput/components/TagSelector.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/FormattedTextInput/index.d.ts +6 -1
- package/lib/typescript/src/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/GifSelector/NativeSelector.d.ts +4 -0
- package/lib/typescript/src/SocialComponents/GifSelector/NativeSelector.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/GifSelector/WebSelector.d.ts +11 -0
- package/lib/typescript/src/SocialComponents/GifSelector/WebSelector.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/GroupChat/components/GroupMessageCard.d.ts +18 -0
- package/lib/typescript/src/SocialComponents/GroupChat/components/GroupMessageCard.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/GroupChat/index.d.ts +25 -0
- package/lib/typescript/src/SocialComponents/GroupChat/index.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/ImageRenderer.d.ts +21 -0
- package/lib/typescript/src/SocialComponents/ImageRenderer.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/InputBar/components/ActionSelector.d.ts +16 -0
- package/lib/typescript/src/SocialComponents/InputBar/components/ActionSelector.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/InputBar/index.d.ts +10 -1
- package/lib/typescript/src/SocialComponents/InputBar/index.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/PostCard/components/ArticleCard.d.ts +1 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/ArticleCard.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/ImageList.d.ts +1 -1
- package/lib/typescript/src/SocialComponents/PostCard/components/ImageList.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/PostCard/index.d.ts +4 -2
- package/lib/typescript/src/SocialComponents/PostCard/index.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/Poster/index.d.ts +16 -0
- package/lib/typescript/src/SocialComponents/Poster/index.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/SocialOrderCard.d.ts +2 -1
- package/lib/typescript/src/SocialComponents/SocialOrderCard.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/SocialOrdersList.d.ts +2 -1
- package/lib/typescript/src/SocialComponents/SocialOrdersList.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/UrlPreviewCard.d.ts +10 -0
- package/lib/typescript/src/SocialComponents/UrlPreviewCard.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/api/index.d.ts +37 -1
- package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/index.d.ts +3 -1
- package/lib/typescript/src/SocialComponents/index.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/Components/Icons.tsx +18 -1
- package/src/Components/Themed.tsx +11 -1
- package/src/SocialComponents/FormattedTextInput/components/TagSelector.tsx +24 -17
- package/src/SocialComponents/FormattedTextInput/index.tsx +32 -7
- package/src/SocialComponents/GifSelector/NativeSelector.tsx +13 -0
- package/src/SocialComponents/GifSelector/WebSelector.tsx +91 -0
- package/src/SocialComponents/GroupChat/components/GroupMessageCard.tsx +84 -0
- package/src/SocialComponents/GroupChat/index.tsx +333 -0
- package/src/SocialComponents/ImageRenderer.tsx +42 -0
- package/src/SocialComponents/InputBar/components/ActionSelector.tsx +164 -0
- package/src/SocialComponents/InputBar/index.tsx +40 -6
- package/src/SocialComponents/PostCard/components/ArticleCard.tsx +2 -0
- package/src/SocialComponents/PostCard/components/ImageList.tsx +28 -21
- package/src/SocialComponents/PostCard/index.tsx +122 -56
- package/src/SocialComponents/Poster/index.tsx +264 -0
- package/src/SocialComponents/SocialOrderCard.tsx +4 -6
- package/src/SocialComponents/SocialOrdersList.tsx +14 -8
- package/src/SocialComponents/UrlPreviewCard.tsx +75 -0
- package/src/SocialComponents/api/index.ts +345 -3
- package/src/SocialComponents/index.tsx +4 -0
- package/src/types.d.ts +58 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Button, Text, TextInput, View } from "../../Components/Themed"
|
|
3
|
+
import FormattedTextInput from '../FormattedTextInput';
|
|
4
|
+
import InputBar from '../InputBar';
|
|
5
|
+
import type { OrderProps, PostProps, PublicPlayerProps, TextTagProps } from '../../types';
|
|
6
|
+
import { SocialComponentApi, SocialComponentHelpers } from '../api';
|
|
7
|
+
import ImageList from '../PostCard/components/ImageList';
|
|
8
|
+
import { useColors } from '../../constants/useColors';
|
|
9
|
+
import { Icons } from '../../Components';
|
|
10
|
+
import { FlatList } from 'react-native';
|
|
11
|
+
import SocialOrdersList from '../SocialOrdersList';
|
|
12
|
+
|
|
13
|
+
type PosterProps = {
|
|
14
|
+
width:number,
|
|
15
|
+
post_id?:string,
|
|
16
|
+
insets?:{ top:number, left:number, right:number, bottom:number },
|
|
17
|
+
onCreatePost:(post:PostProps) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const sections = ['input_bar','title','post','orders','images']
|
|
21
|
+
const Poster = ({ width, post_id, insets, onCreatePost }: PosterProps) => {
|
|
22
|
+
const Colors = useColors();
|
|
23
|
+
const [ submit_caller, setSubmitCaller ] = useState<string|undefined>(undefined);
|
|
24
|
+
const [ post_data, setPostData ] = useState<{
|
|
25
|
+
draft_post?:PostProps,
|
|
26
|
+
players:PublicPlayerProps[],
|
|
27
|
+
post?:PostProps,
|
|
28
|
+
orders:OrderProps[],
|
|
29
|
+
action_loading:boolean
|
|
30
|
+
}>({
|
|
31
|
+
action_loading: false,
|
|
32
|
+
players:[],
|
|
33
|
+
orders:[]
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const { post, draft_post, action_loading, orders } = post_data;
|
|
37
|
+
const valid = SocialComponentHelpers.isPostValid(draft_post);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
SocialComponentApi.setEnvironment();
|
|
41
|
+
setUpPost(post_id);
|
|
42
|
+
},[post_id]);
|
|
43
|
+
|
|
44
|
+
const setUpPost = async(post_id?:string) => {
|
|
45
|
+
let existing_post:PostProps | undefined
|
|
46
|
+
let ords:OrderProps[] = []
|
|
47
|
+
let playrs:PublicPlayerProps[] = []
|
|
48
|
+
if(post_id){
|
|
49
|
+
existing_post = await SocialComponentApi.getPostById(post_id);
|
|
50
|
+
if(existing_post){
|
|
51
|
+
const set_up_data = await SocialComponentHelpers.getPostsData([existing_post]);
|
|
52
|
+
ords = set_up_data.orders
|
|
53
|
+
playrs = set_up_data.players
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
} //Not set up to handle this yet!
|
|
57
|
+
setPostData({
|
|
58
|
+
...post_data,
|
|
59
|
+
orders: ords,
|
|
60
|
+
players: playrs,
|
|
61
|
+
draft_post: existing_post ?? SocialComponentHelpers.getEmptyPost(),
|
|
62
|
+
post: existing_post
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const handlePublishPost = async(data:{ text:string, formatted_text:string }, tags:TextTagProps[]) => {
|
|
67
|
+
if(!draft_post || action_loading || !valid){ return }
|
|
68
|
+
setPostData({
|
|
69
|
+
...post_data,
|
|
70
|
+
action_loading:true
|
|
71
|
+
});
|
|
72
|
+
//Drop data on tags
|
|
73
|
+
tags = tags.map(t => { return { ...t, data: undefined } });
|
|
74
|
+
let saved_post:PostProps | undefined = undefined
|
|
75
|
+
|
|
76
|
+
//Lets check for urls
|
|
77
|
+
const url = SocialComponentHelpers.getUrlsFromString(data.text.toLowerCase());
|
|
78
|
+
console.log(url)
|
|
79
|
+
let memo_urls:string[] = []
|
|
80
|
+
if(url){ memo_urls.push(url) }
|
|
81
|
+
|
|
82
|
+
if(draft_post.memo_post_id){
|
|
83
|
+
saved_post = await SocialComponentApi.updatePost({ ...draft_post, memo_urls, tags: tags, body: data.text, formatted_text: data.formatted_text });
|
|
84
|
+
} else {
|
|
85
|
+
saved_post = await SocialComponentApi.createPost({ ...draft_post, memo_urls, tags: tags, body: data.text, formatted_text: data.formatted_text });
|
|
86
|
+
}
|
|
87
|
+
setPostData({
|
|
88
|
+
...post_data,
|
|
89
|
+
action_loading:false
|
|
90
|
+
});
|
|
91
|
+
if(!saved_post){ return }
|
|
92
|
+
onCreatePost(saved_post);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const renderSections = (data:{ item:string, index:number }) => {
|
|
96
|
+
switch(data.item){
|
|
97
|
+
case 'input_bar':
|
|
98
|
+
return (
|
|
99
|
+
<View style={{ borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
100
|
+
<InputBar
|
|
101
|
+
actions={['image','action']}
|
|
102
|
+
insets={insets}
|
|
103
|
+
width={width}
|
|
104
|
+
onTagOrder={(order) => {
|
|
105
|
+
if(!draft_post){ return }
|
|
106
|
+
let exists = draft_post.memo_orders.find(o => o == order.order_id);
|
|
107
|
+
if(exists){
|
|
108
|
+
setPostData({
|
|
109
|
+
...post_data,
|
|
110
|
+
orders: orders.filter(o => o.order_id != order.order_id),
|
|
111
|
+
draft_post: {
|
|
112
|
+
...draft_post,
|
|
113
|
+
memo_orders: draft_post.memo_orders.filter(o => o != order.order_id)
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
} else {
|
|
117
|
+
//Lets check if its already included!
|
|
118
|
+
setPostData({
|
|
119
|
+
...post_data,
|
|
120
|
+
orders: orders.filter(o => o.order_id != order.order_id).concat(order),
|
|
121
|
+
draft_post: {
|
|
122
|
+
...draft_post,
|
|
123
|
+
memo_orders: draft_post.memo_orders.filter(o => o != order.order_id).concat(order.order_id)
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}}
|
|
128
|
+
onImageUpload={(image) => {
|
|
129
|
+
if(!draft_post){ return }
|
|
130
|
+
setPostData({
|
|
131
|
+
...post_data,
|
|
132
|
+
draft_post: {
|
|
133
|
+
...draft_post,
|
|
134
|
+
memo_images: draft_post.memo_images.concat(image)
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
</View>
|
|
140
|
+
)
|
|
141
|
+
case 'title':
|
|
142
|
+
if(!draft_post){ return <></> }
|
|
143
|
+
return (
|
|
144
|
+
<View nativeID='title'>
|
|
145
|
+
<TextInput
|
|
146
|
+
style={{ borderWidth:0, fontSize:14 }}
|
|
147
|
+
placeholder='Title'
|
|
148
|
+
value={draft_post.title}
|
|
149
|
+
weight='bold'
|
|
150
|
+
onChangeText={(text) => {
|
|
151
|
+
if(!draft_post){ return }
|
|
152
|
+
setPostData({
|
|
153
|
+
...post_data,
|
|
154
|
+
draft_post: {
|
|
155
|
+
...draft_post,
|
|
156
|
+
title: text
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
})
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
</View>
|
|
163
|
+
)
|
|
164
|
+
case 'post':
|
|
165
|
+
if(!draft_post){ return <></> }
|
|
166
|
+
return (
|
|
167
|
+
<View nativeID='post_body'>
|
|
168
|
+
<FormattedTextInput
|
|
169
|
+
hide_border
|
|
170
|
+
width={width}
|
|
171
|
+
disable_scroll
|
|
172
|
+
tag_selector_location='bottom'
|
|
173
|
+
submit_caller={submit_caller}
|
|
174
|
+
init_data={{ text: post?.body ?? '', formatted_text: post?.formatted_text ?? '', tags: post?.tags ?? [] }}
|
|
175
|
+
placeholder='Start typing here ...'
|
|
176
|
+
onSubmit={(data, tags) => handlePublishPost(data, tags)}
|
|
177
|
+
onChangeText={(data) => {
|
|
178
|
+
if(!draft_post){ return }
|
|
179
|
+
setPostData({
|
|
180
|
+
...post_data,
|
|
181
|
+
draft_post: {
|
|
182
|
+
...draft_post,
|
|
183
|
+
body: data.text,
|
|
184
|
+
formatted_text: data.formatted_text
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
})
|
|
188
|
+
}}
|
|
189
|
+
/>
|
|
190
|
+
</View>
|
|
191
|
+
)
|
|
192
|
+
case 'orders':
|
|
193
|
+
if(!draft_post){ return <></> }
|
|
194
|
+
if(!draft_post.memo_orders){ return <></> }
|
|
195
|
+
return (
|
|
196
|
+
<View style={{ padding:10 }}>
|
|
197
|
+
<SocialOrdersList
|
|
198
|
+
orders={orders.filter(o => draft_post.memo_orders.includes(o.order_id))}
|
|
199
|
+
players={[]}
|
|
200
|
+
onUntagOrder={(order) => {
|
|
201
|
+
if(!draft_post){ return }
|
|
202
|
+
setPostData({
|
|
203
|
+
...post_data,
|
|
204
|
+
orders: orders.filter(o => o.order_id != order.order_id),
|
|
205
|
+
draft_post: {
|
|
206
|
+
...draft_post,
|
|
207
|
+
memo_orders: draft_post.memo_orders.filter(o => o != order.order_id)
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
}}
|
|
211
|
+
maxWidth={width}
|
|
212
|
+
direction='horizontal'
|
|
213
|
+
/>
|
|
214
|
+
</View>
|
|
215
|
+
)
|
|
216
|
+
case 'images':
|
|
217
|
+
if(!draft_post){ return <></> }
|
|
218
|
+
if(!draft_post.memo_images){ return <></> }
|
|
219
|
+
return (
|
|
220
|
+
<View>
|
|
221
|
+
<ImageList
|
|
222
|
+
images={draft_post.memo_images}
|
|
223
|
+
width={width-10}
|
|
224
|
+
post_id=''
|
|
225
|
+
/>
|
|
226
|
+
</View>
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
default: return <></>
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
if(!draft_post){ return <></> }
|
|
235
|
+
|
|
236
|
+
return (
|
|
237
|
+
<View style={{ flex:1 }}>
|
|
238
|
+
<View nativeID='actions' type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, paddingTop:(insets?.top ?? 0) + 10 }}>
|
|
239
|
+
<Button transparent style={{ flexDirection:'row', alignItems:'center' }}>
|
|
240
|
+
<Icons.CloseIcon size={10} color={Colors.text.h1} />
|
|
241
|
+
<Text theme='description' style={{ marginLeft:10 }}>Close</Text>
|
|
242
|
+
</Button>
|
|
243
|
+
<View transparent style={{ flex:1 }} />
|
|
244
|
+
<Button
|
|
245
|
+
title='Publish'
|
|
246
|
+
type='success'
|
|
247
|
+
disabled={!valid}
|
|
248
|
+
loading={action_loading}
|
|
249
|
+
style={{ padding:10, opacity: valid && !action_loading ? 1 : 0.5 }}
|
|
250
|
+
onPress={() => setSubmitCaller(Math.random().toString())}
|
|
251
|
+
/>
|
|
252
|
+
</View>
|
|
253
|
+
<FlatList
|
|
254
|
+
data={sections}
|
|
255
|
+
key={`poster_sections`}
|
|
256
|
+
renderItem={renderSections}
|
|
257
|
+
keyExtractor={item => item}
|
|
258
|
+
/>
|
|
259
|
+
|
|
260
|
+
</View>
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export default Poster
|
|
@@ -18,14 +18,14 @@ type SocialOrderCardProps = {
|
|
|
18
18
|
maxWidth?:number,
|
|
19
19
|
team?:TeamProps,
|
|
20
20
|
league?:LeagueProps,
|
|
21
|
+
onTagOrder?:(order:OrderProps) => void,
|
|
21
22
|
onCopyOrder?:(order:OrderProps) => void,
|
|
22
23
|
onFadeOrder?:(order:OrderProps) => void
|
|
23
24
|
}
|
|
24
|
-
const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete, order, contest_title, contest_time, onCopyOrder, onFadeOrder }:SocialOrderCardProps) => {
|
|
25
|
+
const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete, order, contest_title, contest_time, onTagOrder, onCopyOrder, onFadeOrder }:SocialOrderCardProps) => {
|
|
25
26
|
const Colors = useColors();
|
|
26
27
|
const [ fade_loading, setFadeLoading ] = useState(false);
|
|
27
28
|
const { result_label, color } = SocialOrderHelpers.getResultDetails(order)
|
|
28
|
-
|
|
29
29
|
const handleFadeOrder = async() => {
|
|
30
30
|
if(!onFadeOrder){ return }
|
|
31
31
|
if(fade_loading){ return }
|
|
@@ -49,9 +49,8 @@ const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete,
|
|
|
49
49
|
})
|
|
50
50
|
setFadeLoading(false);
|
|
51
51
|
}
|
|
52
|
-
|
|
53
52
|
return (
|
|
54
|
-
<
|
|
53
|
+
<Button disabled={!onTagOrder} float style={{ minWidth:275, maxWidth, padding:0, flex:1 }} onPress={() => onTagOrder ? onTagOrder(order) : console.log('')}>
|
|
55
54
|
{show_player && player ?
|
|
56
55
|
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
57
56
|
<Image
|
|
@@ -67,7 +66,6 @@ const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete,
|
|
|
67
66
|
</View>
|
|
68
67
|
:<></>}
|
|
69
68
|
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
70
|
-
|
|
71
69
|
<View transparent style={{ flex:1, marginRight:10 }}>
|
|
72
70
|
<Text theme='description'>{contest_title}</Text>
|
|
73
71
|
<Text style={{ marginTop:3 }} size={12} theme='light' weight='regular'>{contest_time}</Text>
|
|
@@ -147,7 +145,7 @@ const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete,
|
|
|
147
145
|
:<></>}
|
|
148
146
|
</View>
|
|
149
147
|
:<></>}
|
|
150
|
-
</
|
|
148
|
+
</Button>
|
|
151
149
|
)
|
|
152
150
|
}
|
|
153
151
|
|
|
@@ -3,7 +3,7 @@ import { FlatList } from 'react-native';
|
|
|
3
3
|
import type { AthleteProps, EventProps, LeagueProps, MatchProps, OrderProps, PublicPlayerProps, TeamProps, TournamentProps } from '../types';
|
|
4
4
|
import SocialOrderCard from './SocialOrderCard';
|
|
5
5
|
import { SocialComponentApi, SocialOrderHelpers } from './api';
|
|
6
|
-
import { View } from '../Components/Themed';
|
|
6
|
+
import { Button, View } from '../Components/Themed';
|
|
7
7
|
|
|
8
8
|
type SocialOrdersListProps = {
|
|
9
9
|
players:PublicPlayerProps[],
|
|
@@ -11,10 +11,11 @@ type SocialOrdersListProps = {
|
|
|
11
11
|
orders:OrderProps[],
|
|
12
12
|
maxWidth?:number,
|
|
13
13
|
direction: 'vertical'|'horizontal',
|
|
14
|
+
onUntagOrder?:(order:OrderProps) => void,
|
|
14
15
|
onCopyOrder?:(order:OrderProps) => void,
|
|
15
16
|
onFadeOrder?:(order:OrderProps) => void
|
|
16
17
|
}
|
|
17
|
-
const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, onCopyOrder, onFadeOrder }:SocialOrdersListProps) => {
|
|
18
|
+
const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, onUntagOrder, onCopyOrder, onFadeOrder }:SocialOrdersListProps) => {
|
|
18
19
|
const [list_data, setListData] = useState<{
|
|
19
20
|
loading:boolean,
|
|
20
21
|
leagues:LeagueProps[],
|
|
@@ -33,13 +34,11 @@ const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, o
|
|
|
33
34
|
teams:[]
|
|
34
35
|
});
|
|
35
36
|
const { leagues, events, tournaments, matches, athletes, teams } = list_data;
|
|
36
|
-
|
|
37
37
|
useEffect(() => {
|
|
38
38
|
SocialComponentApi.setEnvironment()
|
|
39
39
|
getDataFromServer();
|
|
40
40
|
},[orders.length])
|
|
41
41
|
|
|
42
|
-
|
|
43
42
|
const getDataFromServer = async() => {
|
|
44
43
|
setListData({ ...list_data, loading:true });
|
|
45
44
|
//Get event_ids
|
|
@@ -61,7 +60,6 @@ const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, o
|
|
|
61
60
|
athletes: a,
|
|
62
61
|
teams: tm
|
|
63
62
|
})
|
|
64
|
-
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
|
|
@@ -69,7 +67,7 @@ const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, o
|
|
|
69
67
|
let { title, time, league, team, athlete } = SocialOrderHelpers.getContestDetails(data.item, events, tournaments, matches, athletes, teams, leagues);
|
|
70
68
|
let player = players.find(p => p.player_id == data.item.player_id)
|
|
71
69
|
return (
|
|
72
|
-
<View style={{ margin:5 }}>
|
|
70
|
+
<View transparent style={{ margin:5 }}>
|
|
73
71
|
<SocialOrderCard
|
|
74
72
|
show_player={show_player}
|
|
75
73
|
player={player}
|
|
@@ -83,12 +81,20 @@ const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, o
|
|
|
83
81
|
onFadeOrder={onFadeOrder}
|
|
84
82
|
onCopyOrder={onCopyOrder}
|
|
85
83
|
/>
|
|
84
|
+
{onUntagOrder ?
|
|
85
|
+
<Button
|
|
86
|
+
float
|
|
87
|
+
type='error'
|
|
88
|
+
style={{ padding:0, justifyContent:'center', alignItems:'center', height:30, width:30, borderRadius:100, position:'absolute', top:5, left:5 }}
|
|
89
|
+
title='X'
|
|
90
|
+
onPress={() => onUntagOrder(data.item)}
|
|
91
|
+
/>
|
|
92
|
+
:<></>}
|
|
86
93
|
</View>
|
|
87
94
|
)
|
|
88
95
|
}
|
|
89
|
-
|
|
90
96
|
return (
|
|
91
|
-
<View style={{
|
|
97
|
+
<View style={{ flex:1 }}>
|
|
92
98
|
<FlatList
|
|
93
99
|
data={orders}
|
|
94
100
|
renderItem={renderOrders}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Button, Text, View } from "../Components/Themed"
|
|
3
|
+
import type { URLMetadataProps } from '../types';
|
|
4
|
+
import { SocialComponentApi } from './api';
|
|
5
|
+
import { ActivityIndicator, Linking } from 'react-native';
|
|
6
|
+
import { useColors } from '../constants/useColors';
|
|
7
|
+
import ImageRenderer from './ImageRenderer';
|
|
8
|
+
|
|
9
|
+
type UrlPreviewCardProps = {
|
|
10
|
+
url:string,
|
|
11
|
+
width:number,
|
|
12
|
+
max_height?:number
|
|
13
|
+
color?:string
|
|
14
|
+
}
|
|
15
|
+
const UrlPreviewCard = ({ url, color, width, max_height }:UrlPreviewCardProps) => {
|
|
16
|
+
const Colors = useColors();
|
|
17
|
+
const [ data, setData ] = useState<{
|
|
18
|
+
loading:boolean,
|
|
19
|
+
url_metadata?: URLMetadataProps
|
|
20
|
+
}>({
|
|
21
|
+
loading: false
|
|
22
|
+
});
|
|
23
|
+
const { loading, url_metadata } = data;
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if(!url){ return }
|
|
27
|
+
getMetadata(url)
|
|
28
|
+
},[url])
|
|
29
|
+
|
|
30
|
+
const getMetadata = async(url:string) => {
|
|
31
|
+
setData({ ...data, loading:true })
|
|
32
|
+
const metadata = await SocialComponentApi.getUrlMetadata(url);
|
|
33
|
+
setData({
|
|
34
|
+
...data,
|
|
35
|
+
loading: false,
|
|
36
|
+
url_metadata: metadata
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Button float transparent style={{ padding:0, width, marginBottom:10 }} onPress={() => Linking.openURL(url)}>
|
|
43
|
+
{loading ?
|
|
44
|
+
<ActivityIndicator
|
|
45
|
+
style={{ padding:20, alignSelf:'center' }}
|
|
46
|
+
size={'large'}
|
|
47
|
+
color={color ?? Colors.text.h1}
|
|
48
|
+
/>
|
|
49
|
+
:<></>}
|
|
50
|
+
{url_metadata?.ogTitle ?
|
|
51
|
+
<View transparent nativeID='CARD' style={{ borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
52
|
+
{url_metadata.ogImage?.url ?
|
|
53
|
+
<ImageRenderer
|
|
54
|
+
image={{ url: url_metadata.ogImage.url, width: parseFloat(url_metadata.ogImage.width), height: parseFloat(url_metadata.ogImage.height) }}
|
|
55
|
+
width={width - 1}
|
|
56
|
+
allow_aspect_change
|
|
57
|
+
max_height={max_height}
|
|
58
|
+
style={{ borderTopRightRadius:8, borderTopLeftRadius:8 }}
|
|
59
|
+
/>
|
|
60
|
+
:<></>}
|
|
61
|
+
<View type='footer' style={{ padding:10, borderBottomRightRadius: 8, borderBottomLeftRadius:8 }}>
|
|
62
|
+
<Text theme='h2' style={{ paddingBottom:2, borderBottomWidth:1, borderColor:Colors.borders.light }}>{url_metadata?.ogTitle}</Text>
|
|
63
|
+
<Text theme='description' style={{ marginTop:4 }}>{url_metadata?.ogDescription}</Text>
|
|
64
|
+
</View>
|
|
65
|
+
</View>
|
|
66
|
+
:
|
|
67
|
+
<View type='header' nativeID='CARD' style={{ borderRadius:8, padding:10 }}>
|
|
68
|
+
<Text theme='action'>{url}</Text>
|
|
69
|
+
</View>
|
|
70
|
+
}
|
|
71
|
+
</Button>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default UrlPreviewCard
|