be-components 5.1.9 → 5.2.0
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/SocialComponents/FormattedTextInput/components/TagSelector.js +55 -19
- package/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.js.map +1 -1
- package/lib/commonjs/SocialComponents/FormattedTextInput/index.js +12 -7
- package/lib/commonjs/SocialComponents/FormattedTextInput/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.js +35 -12
- package/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.js.map +1 -1
- package/lib/commonjs/SocialComponents/GroupChat/index.js +122 -47
- package/lib/commonjs/SocialComponents/GroupChat/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/InputBar/components/ActionSelector.js.map +1 -1
- package/lib/commonjs/SocialComponents/SocialOrderCard.js +8 -3
- package/lib/commonjs/SocialComponents/SocialOrderCard.js.map +1 -1
- package/lib/commonjs/SocialComponents/api/index.js +54 -0
- package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
- package/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.js +55 -20
- package/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.js.map +1 -1
- package/lib/module/SocialComponents/FormattedTextInput/index.js +12 -7
- package/lib/module/SocialComponents/FormattedTextInput/index.js.map +1 -1
- package/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.js +35 -12
- package/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.js.map +1 -1
- package/lib/module/SocialComponents/GroupChat/index.js +124 -49
- package/lib/module/SocialComponents/GroupChat/index.js.map +1 -1
- package/lib/module/SocialComponents/InputBar/components/ActionSelector.js.map +1 -1
- package/lib/module/SocialComponents/SocialOrderCard.js +8 -3
- package/lib/module/SocialComponents/SocialOrderCard.js.map +1 -1
- package/lib/module/SocialComponents/api/index.js +54 -0
- package/lib/module/SocialComponents/api/index.js.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.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.d.ts +4 -1
- package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/index.d.ts +5 -1
- package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/index.d.ts.map +1 -1
- 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/api/index.d.ts +5 -0
- package/lib/typescript/lib/commonjs/SocialComponents/api/index.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.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.d.ts +4 -1
- package/lib/typescript/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/GroupChat/index.d.ts +5 -1
- package/lib/typescript/lib/module/SocialComponents/GroupChat/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/SocialOrderCard.d.ts +2 -1
- package/lib/typescript/lib/module/SocialComponents/SocialOrderCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/api/index.d.ts +5 -0
- package/lib/typescript/lib/module/SocialComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/FormattedTextInput/components/TagSelector.d.ts +7 -1
- package/lib/typescript/src/SocialComponents/FormattedTextInput/components/TagSelector.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/GroupChat/components/GroupMessageCard.d.ts +5 -2
- package/lib/typescript/src/SocialComponents/GroupChat/components/GroupMessageCard.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/GroupChat/index.d.ts +11 -2
- package/lib/typescript/src/SocialComponents/GroupChat/index.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/InputBar/components/ActionSelector.d.ts.map +1 -1
- 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/api/index.d.ts +5 -0
- package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/SocialComponents/FormattedTextInput/components/TagSelector.tsx +48 -14
- package/src/SocialComponents/FormattedTextInput/index.tsx +9 -7
- package/src/SocialComponents/GroupChat/components/GroupMessageCard.tsx +38 -17
- package/src/SocialComponents/GroupChat/index.tsx +121 -51
- package/src/SocialComponents/InputBar/components/ActionSelector.tsx +1 -0
- package/src/SocialComponents/SocialOrderCard.tsx +6 -3
- package/src/SocialComponents/api/index.ts +40 -0
|
@@ -2,26 +2,31 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import { Button, Text, View } from "../../../Components/Themed";
|
|
3
3
|
import type { PublicPlayerProps, TextTagProps } from '../../../types';
|
|
4
4
|
import { SocialComponentApi } from '../../api';
|
|
5
|
-
import { Image } from 'react-native';
|
|
5
|
+
import { FlatList, Image } from 'react-native';
|
|
6
|
+
import SearchBox from '../../../Components/SearchBox';
|
|
7
|
+
import Pagination from '../../../Components/Pagination';
|
|
6
8
|
|
|
7
9
|
type TagSelectorProps = {
|
|
8
10
|
type: 'player',
|
|
9
11
|
width:number,
|
|
10
12
|
visible:boolean,
|
|
13
|
+
onFocusPosition?:(position:{ height:number, width:number, x:number, y:number }) => void
|
|
11
14
|
working_tag:TextTagProps,
|
|
12
15
|
onCancel: () => void,
|
|
13
16
|
onSelectTag:(tag:TextTagProps) => void
|
|
14
17
|
}
|
|
15
18
|
const MIN_TAG_WIDTH = 140
|
|
16
|
-
const TagSelector = ({ width, type, visible, working_tag, onSelectTag, onCancel } : TagSelectorProps) => {
|
|
19
|
+
const TagSelector = ({ width, type, visible, working_tag, onFocusPosition, onSelectTag, onCancel } : TagSelectorProps) => {
|
|
20
|
+
const [ player_search, setPlayerSearch ] = useState('');
|
|
17
21
|
const [ player_tag, setPlayerTag ] = useState<{
|
|
18
22
|
loading:boolean,
|
|
19
23
|
players:PublicPlayerProps[],
|
|
24
|
+
player_local_offset:number,
|
|
20
25
|
offset:number
|
|
21
26
|
}>({
|
|
22
|
-
loading: false, players:[], offset:0
|
|
27
|
+
loading: false, players:[], offset:0, player_local_offset:0
|
|
23
28
|
});
|
|
24
|
-
|
|
29
|
+
let visible_players = player_tag.players.slice(0, 8);
|
|
25
30
|
const getTagWidth = (padding:number) => {
|
|
26
31
|
//How many can fit in the screen
|
|
27
32
|
let num_possible = Math.floor(width / MIN_TAG_WIDTH);
|
|
@@ -29,7 +34,7 @@ const TagSelector = ({ width, type, visible, working_tag, onSelectTag, onCancel
|
|
|
29
34
|
let width_per_tag = (width / num_possible) - (padding * 2 * num_possible)
|
|
30
35
|
return width_per_tag
|
|
31
36
|
}
|
|
32
|
-
const tag_width = getTagWidth(
|
|
37
|
+
const tag_width = getTagWidth(4)
|
|
33
38
|
|
|
34
39
|
useEffect(() => {
|
|
35
40
|
if(!visible){ return }
|
|
@@ -66,16 +71,27 @@ const TagSelector = ({ width, type, visible, working_tag, onSelectTag, onCancel
|
|
|
66
71
|
})
|
|
67
72
|
}
|
|
68
73
|
|
|
74
|
+
const searchPlayersByValue = async(page:number) => {
|
|
75
|
+
if(!player_search){ return }
|
|
76
|
+
const plys = await SocialComponentApi.searchPlayersByValue(player_search, page);
|
|
77
|
+
setPlayerTag({
|
|
78
|
+
...player_tag,
|
|
79
|
+
loading: false,
|
|
80
|
+
players: plys,
|
|
81
|
+
offset: page
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
69
85
|
const renderPlayers = (data:{ item:PublicPlayerProps, index:number }) => {
|
|
70
86
|
return (
|
|
71
87
|
<Button key={data.item.player_id.toString()} float style={{ flexDirection:'row', alignItems:'center', margin:2, padding:3, width:tag_width, borderRadius:100 }} onPress={() => handleSelectPlayer(data.item)}>
|
|
72
88
|
<Image
|
|
73
89
|
source={{ uri: data.item.profile_pic }}
|
|
74
|
-
style={{ height:
|
|
90
|
+
style={{ height:30, width:30, borderRadius:100 }}
|
|
75
91
|
resizeMode='cover'
|
|
76
92
|
/>
|
|
77
93
|
<View transparent style={{flex:1, marginLeft:5 }}>
|
|
78
|
-
<Text style={{ maxWidth:tag_width -
|
|
94
|
+
<Text style={{ maxWidth:tag_width - 35 }} theme='description' size={10} textAlign='center'>@{data.item.username}</Text>
|
|
79
95
|
</View>
|
|
80
96
|
</Button>
|
|
81
97
|
)
|
|
@@ -84,10 +100,10 @@ const TagSelector = ({ width, type, visible, working_tag, onSelectTag, onCancel
|
|
|
84
100
|
if(!visible){ return <></> }
|
|
85
101
|
|
|
86
102
|
return (
|
|
87
|
-
<View>
|
|
103
|
+
<View transparent>
|
|
88
104
|
{type == 'player' ?
|
|
89
|
-
<View float>
|
|
90
|
-
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
105
|
+
<View float style={{ flex:1 }}>
|
|
106
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
91
107
|
<View transparent style={{ flex:1 }}>
|
|
92
108
|
<Text theme='h2'>Tag A Player!</Text>
|
|
93
109
|
</View>
|
|
@@ -99,11 +115,29 @@ const TagSelector = ({ width, type, visible, working_tag, onSelectTag, onCancel
|
|
|
99
115
|
onPress={() => onCancel()}
|
|
100
116
|
/>
|
|
101
117
|
</View>
|
|
102
|
-
<View
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
118
|
+
<View>
|
|
119
|
+
<SearchBox
|
|
120
|
+
button_style={{ padding:10 }}
|
|
121
|
+
placeholder='Search Players ...'
|
|
122
|
+
onSearch={() => searchPlayersByValue(0)}
|
|
123
|
+
onFocusPosition={onFocusPosition}
|
|
124
|
+
onChange={(text) => setPlayerSearch(text)}
|
|
125
|
+
/>
|
|
126
|
+
</View>
|
|
127
|
+
<View transparent style={{ padding:5 }}>
|
|
128
|
+
<FlatList
|
|
129
|
+
key={'player_tags'}
|
|
130
|
+
numColumns={2}
|
|
131
|
+
data={visible_players}
|
|
132
|
+
keyExtractor={(item) => item.player_id.toString()}
|
|
133
|
+
renderItem={renderPlayers}
|
|
134
|
+
/>
|
|
106
135
|
</View>
|
|
136
|
+
<Pagination
|
|
137
|
+
offset={player_tag.offset}
|
|
138
|
+
onNext={() => player_search ? searchPlayersByValue(player_tag.offset + 1) : searchPlayers(working_tag, player_tag.offset + 1)}
|
|
139
|
+
onPrevious={() => player_search ? searchPlayersByValue(player_tag.offset - 1) : searchPlayers(working_tag, player_tag.offset - 1)}
|
|
140
|
+
/>
|
|
107
141
|
</View>
|
|
108
142
|
:<></>}
|
|
109
143
|
</View>
|
|
@@ -149,18 +149,19 @@ const FormattedTextInput = ({ width, disable_scroll, submit_title, hide_border,
|
|
|
149
149
|
|
|
150
150
|
return (
|
|
151
151
|
<View transparent>
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
{tag_selector.visible && tag_selector.working_tag && tag_selector_location != 'bottom' ?
|
|
153
|
+
<View transparent style={{ padding:10 }}>
|
|
154
154
|
<TagSelector
|
|
155
155
|
working_tag={tag_selector.working_tag}
|
|
156
156
|
type={tag_selector.type}
|
|
157
|
-
width={width}
|
|
157
|
+
width={width - 20}
|
|
158
|
+
onFocusPosition={onFocusPosition}
|
|
158
159
|
visible={tag_selector.visible}
|
|
159
160
|
onCancel={() => setTagSelector({ visible: false, type: 'player' })}
|
|
160
161
|
onSelectTag={(tag) => handleUpdateTag(tag)}
|
|
161
162
|
/>
|
|
162
|
-
:<></>}
|
|
163
163
|
</View>
|
|
164
|
+
:<></>}
|
|
164
165
|
<View transparent style={{ flexDirection:'row', alignItems:'flex-end' }}>
|
|
165
166
|
{onSelectInput ?
|
|
166
167
|
<Button float style={{ padding:10, width:45, marginRight:5, borderRadius:8, justifyContent:'center', alignItems:'center' }} onPress={() => onSelectInput()}>
|
|
@@ -204,16 +205,17 @@ const FormattedTextInput = ({ width, disable_scroll, submit_title, hide_border,
|
|
|
204
205
|
:<></>}
|
|
205
206
|
</View>
|
|
206
207
|
{tag_selector.visible && tag_selector.working_tag && tag_selector_location == 'bottom' ?
|
|
207
|
-
<View transparent style={{
|
|
208
|
+
<View transparent style={{ padding:10 }}>
|
|
208
209
|
<TagSelector
|
|
209
210
|
working_tag={tag_selector.working_tag}
|
|
210
211
|
type={tag_selector.type}
|
|
211
|
-
width={width}
|
|
212
|
+
width={width - 20}
|
|
213
|
+
onFocusPosition={onFocusPosition}
|
|
212
214
|
visible={tag_selector.visible}
|
|
213
215
|
onCancel={() => setTagSelector({ visible: false, type: 'player' })}
|
|
214
216
|
onSelectTag={(tag) => handleUpdateTag(tag)}
|
|
215
217
|
/>
|
|
216
|
-
|
|
218
|
+
</View>
|
|
217
219
|
:<></>}
|
|
218
220
|
{submit_placement == 'bottom' ?
|
|
219
221
|
<Button
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text, View } from "../../../Components/Themed";
|
|
3
3
|
import { useColors } from "../../../constants/useColors";
|
|
4
|
-
import type { GroupMessageProps, MyPlayerProps, PublicPlayerProps, TextTagProps } from "../../../types";
|
|
4
|
+
import type { GroupMessageProps, MyPlayerProps, OrderProps, PublicPlayerProps, TextTagProps } from "../../../types";
|
|
5
5
|
import { FormattedText } from '../../FormattedTextInput/FormattedText';
|
|
6
6
|
import moment from 'moment-mini';
|
|
7
7
|
import { Image } from 'react-native';
|
|
8
8
|
import ImageRenderer from '../../ImageRenderer';
|
|
9
9
|
import UrlPreviewCard from '../../UrlPreviewCard';
|
|
10
|
+
import SocialOrdersList from '../../SocialOrdersList';
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
type GroupMessageCardProps = {
|
|
13
14
|
group_message:GroupMessageProps,
|
|
14
15
|
me?:MyPlayerProps,
|
|
16
|
+
orders:OrderProps[],
|
|
15
17
|
player?:PublicPlayerProps,
|
|
16
18
|
mine?:boolean,
|
|
19
|
+
onCopyOrder?:(order:OrderProps) => void,
|
|
20
|
+
onFadeOrder?:(order:OrderProps) => void,
|
|
17
21
|
width: number,
|
|
18
22
|
onSelectImage:(image:{ url:string, height?:number, width?:number }) => void,
|
|
19
23
|
onSelectTag:(tag:TextTagProps) => void
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
const GroupMessageCard = ({group_message, mine, player, width, onSelectImage, onSelectTag}:GroupMessageCardProps) => {
|
|
26
|
+
const GroupMessageCard = ({group_message, orders, mine, player, width, onSelectImage, onSelectTag, onCopyOrder, onFadeOrder}:GroupMessageCardProps) => {
|
|
23
27
|
const Colors = useColors();
|
|
24
28
|
const image = group_message.message_images ? group_message.message_images[0] : undefined
|
|
25
29
|
const url = group_message.message_urls ? group_message.message_urls[0] : undefined
|
|
30
|
+
|
|
26
31
|
return (
|
|
27
32
|
<View>
|
|
28
33
|
<View style={{ flexDirection:'row', alignItems:'flex-end' }}>
|
|
@@ -38,7 +43,7 @@ const GroupMessageCard = ({group_message, mine, player, width, onSelectImage, on
|
|
|
38
43
|
</View>
|
|
39
44
|
}
|
|
40
45
|
<View float style={{
|
|
41
|
-
width: width - 90,
|
|
46
|
+
width: mine ? width - 45 : width - 90,
|
|
42
47
|
padding:14,
|
|
43
48
|
marginLeft:10,
|
|
44
49
|
borderRadius:22,
|
|
@@ -47,20 +52,6 @@ const GroupMessageCard = ({group_message, mine, player, width, onSelectImage, on
|
|
|
47
52
|
borderBottomRightRadius: mine? 0:22,
|
|
48
53
|
backgroundColor:mine?Colors.absolutes.brand.midnight:Colors.absolutes.highlights.highlight200
|
|
49
54
|
}}>
|
|
50
|
-
{url ?
|
|
51
|
-
<UrlPreviewCard
|
|
52
|
-
url={url}
|
|
53
|
-
width={width - 120}
|
|
54
|
-
color={Colors.text.white}
|
|
55
|
-
/>
|
|
56
|
-
:<></>}
|
|
57
|
-
{image ?
|
|
58
|
-
<ImageRenderer
|
|
59
|
-
image={image}
|
|
60
|
-
width={width - 120}
|
|
61
|
-
onSelectImage={onSelectImage}
|
|
62
|
-
/>
|
|
63
|
-
:<></>}
|
|
64
55
|
{group_message.formatted_text ?
|
|
65
56
|
<FormattedText
|
|
66
57
|
text={group_message.formatted_text}
|
|
@@ -71,6 +62,36 @@ const GroupMessageCard = ({group_message, mine, player, width, onSelectImage, on
|
|
|
71
62
|
: group_message.message ?
|
|
72
63
|
<Text size={12} color={Colors.text.white}>{group_message.message}</Text>
|
|
73
64
|
:<></>}
|
|
65
|
+
{url ?
|
|
66
|
+
<View transparent style={{ marginTop:10 }}>
|
|
67
|
+
<UrlPreviewCard
|
|
68
|
+
url={url}
|
|
69
|
+
max_height={120}
|
|
70
|
+
width={width - 120}
|
|
71
|
+
color={Colors.text.white}
|
|
72
|
+
/>
|
|
73
|
+
</View>
|
|
74
|
+
:<></>}
|
|
75
|
+
{image ?
|
|
76
|
+
<ImageRenderer
|
|
77
|
+
image={image}
|
|
78
|
+
width={width - 120}
|
|
79
|
+
onSelectImage={onSelectImage}
|
|
80
|
+
/>
|
|
81
|
+
:<></>}
|
|
82
|
+
{player && orders && orders.length > 0 ?
|
|
83
|
+
<View float style={{ padding:4, marginTop:10 }}>
|
|
84
|
+
<SocialOrdersList
|
|
85
|
+
orders={orders}
|
|
86
|
+
onCopyOrder={onCopyOrder}
|
|
87
|
+
onFadeOrder={onFadeOrder}
|
|
88
|
+
maxWidth={width - 120}
|
|
89
|
+
players={[player]}
|
|
90
|
+
direction='horizontal'
|
|
91
|
+
|
|
92
|
+
/>
|
|
93
|
+
</View>
|
|
94
|
+
:<></>}
|
|
74
95
|
</View>
|
|
75
96
|
{!mine ?
|
|
76
97
|
<View transparent />
|
|
@@ -1,62 +1,71 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import moment from "moment-mini";
|
|
3
|
-
import { useEffect,
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { ActivityIndicator, FlatList, Image } from "react-native"
|
|
5
5
|
import { useColors } from "../../constants/useColors";
|
|
6
|
-
import type { GroupMessageProps, GroupPlayerProps, GroupProps, MyPlayerProps, PublicPlayerProps, TextTagProps } from "../../types";
|
|
6
|
+
import type { GroupMessageProps, GroupPlayerProps, GroupProps, MyPlayerProps, OrderProps, PublicPlayerProps, TextTagProps } from "../../types";
|
|
7
7
|
import { SocialComponentApi, SocialComponentHelpers } from "../api";
|
|
8
|
-
import { Text, View } from "../../Components/Themed";
|
|
8
|
+
import { Button, Text, View } from "../../Components/Themed";
|
|
9
9
|
import GroupMessageCard from './components/GroupMessageCard';
|
|
10
10
|
import InputBar from '../InputBar';
|
|
11
11
|
import FormattedTextInput from '../FormattedTextInput';
|
|
12
12
|
import SocketManager from '../../Socket';
|
|
13
|
+
import SocialOrdersList from '../SocialOrdersList';
|
|
13
14
|
|
|
14
15
|
type GroupChatProps = {
|
|
15
16
|
group_id?:string,
|
|
16
17
|
my_id?:string,
|
|
17
18
|
player_id?:string,
|
|
18
19
|
access_token?:string,
|
|
20
|
+
onClose?:() => void,
|
|
19
21
|
width:number,
|
|
22
|
+
onCopyOrder?:(order:OrderProps) => void,
|
|
23
|
+
onFadeOrder?:(order:OrderProps) => void
|
|
24
|
+
insets?:{ top:number, bottom:number, left:number, right:number }
|
|
20
25
|
distinct_id:string,
|
|
21
26
|
onSelectTag: (tag:TextTagProps) => void,
|
|
22
27
|
onSelectImage:(image: { url:string, height?:number, width?:number }) => void,
|
|
23
28
|
onFocusPosition?:(position:{ height:number, width:number, x:number, y:number }) => void
|
|
24
29
|
}
|
|
25
|
-
|
|
26
|
-
const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_id, onFocusPosition, onSelectImage, onSelectTag }:GroupChatProps) => {
|
|
30
|
+
const sections = ['orders','input_bar','input']
|
|
31
|
+
const GroupChat = ({ my_id, player_id, width, group_id, access_token, insets, distinct_id, onCopyOrder, onFadeOrder, onClose, onFocusPosition, onSelectImage, onSelectTag }:GroupChatProps) => {
|
|
27
32
|
const Colors = useColors();
|
|
28
33
|
const [ chat_size, setChatSize ] = useState({ height:0, width:0 });
|
|
29
34
|
const [ show_input_bar, setShowInputBar ] = useState(false);
|
|
30
35
|
const [ needs_reload, setNeedsReload ] = useState(false);
|
|
31
36
|
const [ message_loading, setMessageLoading ] = useState(false);
|
|
32
37
|
const [ socket_message, setSocketMessage ] = useState<GroupMessageProps|undefined>(undefined);
|
|
38
|
+
const [ draft_orders, setDraftOrders ] = useState<OrderProps[]>([]);
|
|
33
39
|
const [ my_data, setMyData ] = useState<{
|
|
34
40
|
me?: MyPlayerProps
|
|
35
41
|
}>({});
|
|
36
42
|
const { me } = my_data;
|
|
37
43
|
const [ screen_data, setData ] = useState<{
|
|
38
44
|
loading:boolean,
|
|
39
|
-
players:PublicPlayerProps[],
|
|
40
45
|
group?:GroupProps,
|
|
41
46
|
group_players:GroupPlayerProps[]
|
|
42
|
-
}>({
|
|
47
|
+
}>({
|
|
43
48
|
loading:false,
|
|
44
|
-
players:[],
|
|
45
49
|
group_players: []
|
|
46
50
|
})
|
|
47
|
-
const { loading,
|
|
51
|
+
const { loading, group } = screen_data;
|
|
48
52
|
|
|
49
53
|
const [ message_data, setMessageData ] = useState<{
|
|
50
54
|
messages_loading:boolean,
|
|
51
|
-
messages: GroupMessageProps[]
|
|
55
|
+
messages: GroupMessageProps[],
|
|
56
|
+
players:PublicPlayerProps[],
|
|
57
|
+
|
|
58
|
+
orders:OrderProps[]
|
|
52
59
|
}>({
|
|
53
60
|
messages_loading: false,
|
|
54
|
-
messages:[]
|
|
61
|
+
messages:[],
|
|
62
|
+
players:[],
|
|
63
|
+
orders:[]
|
|
55
64
|
});
|
|
56
|
-
const { messages } = message_data
|
|
65
|
+
const { messages, players, orders } = message_data
|
|
57
66
|
const chat_ref = useRef(null);
|
|
58
67
|
|
|
59
|
-
const unique_dates =
|
|
68
|
+
const unique_dates = [ ...new Set(messages.map(m => moment(m.create_datetime).format('MMM DD YYYY')))]
|
|
60
69
|
|
|
61
70
|
useEffect(() => {
|
|
62
71
|
SocialComponentApi.setEnvironment();
|
|
@@ -81,12 +90,19 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
81
90
|
}
|
|
82
91
|
|
|
83
92
|
useEffect(() => {
|
|
84
|
-
if(!socket_message){ return }
|
|
93
|
+
if(!socket_message){ return }
|
|
94
|
+
getNewData(socket_message)
|
|
95
|
+
},[socket_message]);
|
|
96
|
+
|
|
97
|
+
const getNewData = async(message:GroupMessageProps) => {
|
|
98
|
+
const new_resp = await SocialComponentHelpers.addDataToMessages([message]);
|
|
85
99
|
setMessageData({
|
|
86
100
|
...message_data,
|
|
87
|
-
messages: messages.filter(m => m.group_message_id !=
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
messages: messages.filter(m => m.group_message_id != message.group_message_id).concat(new_resp.group_messages),
|
|
102
|
+
players: players.filter(p => !new_resp.players.find(np => np.player_id == p.player_id)).concat(new_resp.players),
|
|
103
|
+
orders: orders.filter(p => !new_resp.orders.find(np => np.order_id == p.order_id)).concat(new_resp.orders),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
90
106
|
|
|
91
107
|
const chat_player = group?.type == 'direct' ? players.find(p => p.player_id == player_id) : undefined
|
|
92
108
|
|
|
@@ -96,16 +112,10 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
96
112
|
setMessageData({ ...message_data, messages_loading:true });
|
|
97
113
|
const group_response = await SocialComponentApi.getChat(id);
|
|
98
114
|
if(!group_response){ return setData({ ...screen_data, loading:false }) }
|
|
99
|
-
|
|
100
|
-
if(player_id){ player_ids.push(player_id) }
|
|
101
|
-
if(my_id){ player_ids.push(my_id) }
|
|
102
|
-
const players = await SocialComponentApi.getPlayersByIds(player_ids);
|
|
103
|
-
|
|
104
|
-
let group_messages_with_tags = await SocialComponentHelpers.addTagsToMessages(group_response.group_messages);
|
|
115
|
+
const gm_data = await SocialComponentHelpers.addDataToMessages(group_response.group_messages);
|
|
105
116
|
|
|
106
117
|
setData({
|
|
107
118
|
...screen_data,
|
|
108
|
-
players: players,
|
|
109
119
|
group: group_response.group,
|
|
110
120
|
group_players: group_response.group_players,
|
|
111
121
|
loading: false
|
|
@@ -113,7 +123,9 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
113
123
|
setMessageData({
|
|
114
124
|
...message_data,
|
|
115
125
|
messages_loading:false,
|
|
116
|
-
|
|
126
|
+
players: gm_data.players,
|
|
127
|
+
messages: gm_data.group_messages,
|
|
128
|
+
orders: gm_data.orders
|
|
117
129
|
});
|
|
118
130
|
}
|
|
119
131
|
|
|
@@ -122,13 +134,9 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
122
134
|
setMessageData({ ...message_data, messages_loading:true });
|
|
123
135
|
const group_response = await SocialComponentApi.getGroupById(id);
|
|
124
136
|
if(!group_response){ return setData({ ...screen_data, loading:false }) }
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
let group_messages_with_tags = await SocialComponentHelpers.addTagsToMessages(group_response.group_messages);
|
|
128
|
-
|
|
137
|
+
const gm_data = await SocialComponentHelpers.addDataToMessages(group_response.group_messages);
|
|
129
138
|
setData({
|
|
130
139
|
...screen_data,
|
|
131
|
-
players: players,
|
|
132
140
|
group: group_response.group,
|
|
133
141
|
group_players: group_response.group_players,
|
|
134
142
|
loading: false
|
|
@@ -136,7 +144,9 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
136
144
|
setMessageData({
|
|
137
145
|
...message_data,
|
|
138
146
|
messages_loading:false,
|
|
139
|
-
|
|
147
|
+
players: gm_data.players,
|
|
148
|
+
messages: gm_data.group_messages,
|
|
149
|
+
orders: gm_data.orders
|
|
140
150
|
});
|
|
141
151
|
}
|
|
142
152
|
|
|
@@ -181,6 +191,7 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
181
191
|
tags: tags.map(t => { return { ...t, data:undefined } }), //Drop the data!
|
|
182
192
|
group_id: group.group_id,
|
|
183
193
|
message_urls: message_urls,
|
|
194
|
+
message_orders:draft_orders.map(o => o.order_id),
|
|
184
195
|
message: data.text
|
|
185
196
|
});
|
|
186
197
|
if(!gm){
|
|
@@ -197,6 +208,7 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
197
208
|
const renderMessages = (data:{item:GroupMessageProps, index:number}) => {
|
|
198
209
|
const player = players.find(p => p.player_id == data.item.player_id)
|
|
199
210
|
const mine = player?.player_id == me?.player_id ? true: false
|
|
211
|
+
let post_orders = data.item.message_orders ? orders.filter(o => data.item.message_orders?.includes(o.order_id)) : []
|
|
200
212
|
return (
|
|
201
213
|
<View style={{ margin:5 }}>
|
|
202
214
|
<GroupMessageCard
|
|
@@ -204,10 +216,14 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
204
216
|
me={me}
|
|
205
217
|
width={chat_size.width}
|
|
206
218
|
mine={mine}
|
|
219
|
+
onCopyOrder={onCopyOrder}
|
|
220
|
+
onFadeOrder={onFadeOrder}
|
|
221
|
+
orders={post_orders}
|
|
207
222
|
onSelectImage={onSelectImage}
|
|
208
223
|
group_message={data.item}
|
|
209
224
|
onSelectTag={onSelectTag}
|
|
210
225
|
/>
|
|
226
|
+
|
|
211
227
|
</View>
|
|
212
228
|
)
|
|
213
229
|
}
|
|
@@ -230,13 +246,60 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
230
246
|
)
|
|
231
247
|
}
|
|
232
248
|
|
|
249
|
+
|
|
250
|
+
const renderSections = (data: { item:string, index:number }) => {
|
|
251
|
+
switch(data.item){
|
|
252
|
+
case 'orders':
|
|
253
|
+
if(draft_orders.length == 0){ return <></> }
|
|
254
|
+
return (
|
|
255
|
+
<View >
|
|
256
|
+
<SocialOrdersList
|
|
257
|
+
players={players}
|
|
258
|
+
orders={draft_orders}
|
|
259
|
+
onUntagOrder={(order) => setDraftOrders(draft_orders.filter(o => o.order_id != order.order_id))}
|
|
260
|
+
direction='horizontal'
|
|
261
|
+
/>
|
|
262
|
+
</View>
|
|
263
|
+
)
|
|
264
|
+
case 'input_bar':
|
|
265
|
+
if(!show_input_bar){ return <></> }
|
|
266
|
+
return (
|
|
267
|
+
<View type='header' style={{ padding:5 }}>
|
|
268
|
+
<InputBar
|
|
269
|
+
actions={['image','action']}
|
|
270
|
+
width={width}
|
|
271
|
+
insets={insets}
|
|
272
|
+
onTagOrder={(order) => {
|
|
273
|
+
setDraftOrders(draft_orders.filter(o => o.order_id != order.order_id).concat(order))
|
|
274
|
+
}}
|
|
275
|
+
onImageUpload={(image) => handleSendImage(image)}
|
|
276
|
+
/>
|
|
277
|
+
</View>
|
|
278
|
+
)
|
|
279
|
+
case 'input':
|
|
280
|
+
return (
|
|
281
|
+
<View type='footer' style={{ padding:5, paddingBottom:(insets?.bottom ?? 0) + 5 }}>
|
|
282
|
+
<FormattedTextInput
|
|
283
|
+
submit_placement='inline'
|
|
284
|
+
icon_submit
|
|
285
|
+
width={chat_size.width}
|
|
286
|
+
onSelectInput={() => setShowInputBar(!show_input_bar)}
|
|
287
|
+
onSubmit={(data, tags) => handleSendMessage(data, tags)}
|
|
288
|
+
onFocusPosition={onFocusPosition}
|
|
289
|
+
/>
|
|
290
|
+
</View>
|
|
291
|
+
)
|
|
292
|
+
default: return <></>
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
233
296
|
return (
|
|
234
297
|
<View style={{ flex:1 }} onLayout={(ev) => {
|
|
235
298
|
const { height, width } = ev.nativeEvent.layout;
|
|
236
299
|
setChatSize({ height, width });
|
|
237
300
|
}}>
|
|
238
301
|
{group?.type == 'direct' && chat_player ?
|
|
239
|
-
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
302
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, paddingTop:(insets?.top ?? 0) + 10 }}>
|
|
240
303
|
<View transparent>
|
|
241
304
|
<Image
|
|
242
305
|
source={{ uri: chat_player.profile_pic }}
|
|
@@ -248,9 +311,18 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
248
311
|
<Text theme="h1">@{chat_player.username}</Text>
|
|
249
312
|
<Text style={{ marginTop:3 }} theme="description">Joined {moment(chat_player.create_datetime).fromNow()}</Text>
|
|
250
313
|
</View>
|
|
314
|
+
{onClose ?
|
|
315
|
+
<Button
|
|
316
|
+
type="close"
|
|
317
|
+
title="X"
|
|
318
|
+
float
|
|
319
|
+
style={{ padding:0, borderRadius:100, justifyContent:'center', alignItems:'center', height:30, width:30 }}
|
|
320
|
+
onPress={() => onClose()}
|
|
321
|
+
/>
|
|
322
|
+
:<></>}
|
|
251
323
|
</View>
|
|
252
324
|
:group ?
|
|
253
|
-
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
325
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, paddingTop:(insets?.top ?? 0) + 10 }}>
|
|
254
326
|
<View transparent>
|
|
255
327
|
<Image
|
|
256
328
|
source={{ uri: group.group_image?.url }}
|
|
@@ -262,6 +334,15 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
262
334
|
<Text theme="h1">{group.name}</Text>
|
|
263
335
|
<Text style={{ marginTop:3 }} theme="description">{moment(group.last_update_datetime).format('YYYY MM DD')}</Text>
|
|
264
336
|
</View>
|
|
337
|
+
{onClose ?
|
|
338
|
+
<Button
|
|
339
|
+
type="close"
|
|
340
|
+
title="X"
|
|
341
|
+
float
|
|
342
|
+
style={{ padding:0, borderRadius:100, justifyContent:'center', alignItems:'center', height:30, width:30 }}
|
|
343
|
+
onPress={() => onClose()}
|
|
344
|
+
/>
|
|
345
|
+
:<></>}
|
|
265
346
|
</View>
|
|
266
347
|
:<></>}
|
|
267
348
|
<View style={{ flex:1 }}>
|
|
@@ -274,25 +355,14 @@ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_i
|
|
|
274
355
|
key={`chat_${group_id}dates`}
|
|
275
356
|
keyExtractor={(item) => item}
|
|
276
357
|
/>
|
|
277
|
-
|
|
278
|
-
</View>
|
|
279
|
-
{show_input_bar ?
|
|
280
|
-
<View type='header' style={{ padding:5 }}>
|
|
281
|
-
<InputBar
|
|
282
|
-
actions={['image']}
|
|
283
|
-
width={200}
|
|
284
|
-
onImageUpload={(image) => handleSendImage(image)}
|
|
285
|
-
/>
|
|
286
358
|
</View>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
onSubmit={(data, tags) => handleSendMessage(data, tags)}
|
|
295
|
-
onFocusPosition={onFocusPosition}
|
|
359
|
+
<View>
|
|
360
|
+
<FlatList
|
|
361
|
+
data={sections}
|
|
362
|
+
key={'chat_sections'}
|
|
363
|
+
scrollEnabled={false}
|
|
364
|
+
keyExtractor={item => item}
|
|
365
|
+
renderItem={renderSections}
|
|
296
366
|
/>
|
|
297
367
|
</View>
|
|
298
368
|
{group ?
|
|
@@ -78,6 +78,7 @@ const ActionSelector = ({ visible, insets, onClose, onTagOrder }:ActionSelectPro
|
|
|
78
78
|
<View transparent style={{ margin:5, borderWidth:tagged?2:0, borderColor:Colors.text.success}}>
|
|
79
79
|
<SocialOrderCard
|
|
80
80
|
order={data.item}
|
|
81
|
+
|
|
81
82
|
league={league}
|
|
82
83
|
onTagOrder={(order) => {
|
|
83
84
|
if(tagged){
|
|
@@ -16,13 +16,14 @@ type SocialOrderCardProps = {
|
|
|
16
16
|
order:OrderProps,
|
|
17
17
|
athlete?:AthleteProps,
|
|
18
18
|
maxWidth?:number,
|
|
19
|
+
hide_contest?:boolean,
|
|
19
20
|
team?:TeamProps,
|
|
20
21
|
league?:LeagueProps,
|
|
21
22
|
onTagOrder?:(order:OrderProps) => void,
|
|
22
23
|
onCopyOrder?:(order:OrderProps) => void,
|
|
23
24
|
onFadeOrder?:(order:OrderProps) => void
|
|
24
25
|
}
|
|
25
|
-
const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete, order, contest_title, contest_time, onTagOrder, onCopyOrder, onFadeOrder }:SocialOrderCardProps) => {
|
|
26
|
+
const SocialOrderCard = ({ player, show_player, hide_contest, maxWidth, league, team, athlete, order, contest_title, contest_time, onTagOrder, onCopyOrder, onFadeOrder }:SocialOrderCardProps) => {
|
|
26
27
|
const Colors = useColors();
|
|
27
28
|
const [ fade_loading, setFadeLoading ] = useState(false);
|
|
28
29
|
const { result_label, color } = SocialOrderHelpers.getResultDetails(order)
|
|
@@ -65,9 +66,10 @@ const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete,
|
|
|
65
66
|
<Text size={14} color={color} weight='bold'>{result_label}</Text>
|
|
66
67
|
</View>
|
|
67
68
|
:<></>}
|
|
69
|
+
{!hide_contest ?
|
|
68
70
|
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
69
71
|
<View transparent style={{ flex:1, marginRight:10 }}>
|
|
70
|
-
<Text theme='description'>{contest_title}</Text>
|
|
72
|
+
<Text theme='description' style={{ flex:1 }}>{contest_title}</Text>
|
|
71
73
|
<Text style={{ marginTop:3 }} size={12} theme='light' weight='regular'>{contest_time}</Text>
|
|
72
74
|
</View>
|
|
73
75
|
{league ?
|
|
@@ -82,7 +84,8 @@ const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete,
|
|
|
82
84
|
</View>
|
|
83
85
|
}
|
|
84
86
|
</View>
|
|
85
|
-
|
|
87
|
+
:<></>}
|
|
88
|
+
<View type='body' transparent style={{ padding:10 }}>
|
|
86
89
|
<View transparent type='row' style={{ padding:5 }}>
|
|
87
90
|
{team ?
|
|
88
91
|
<Image
|