@messenger-box/platform-mobile 0.0.1-alpha.219 → 0.0.1-alpha.222

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.
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- declare type MessageInputProps = {
3
- channelId?: string;
4
- handleSend: (message: string, files: any) => Promise<void>;
5
- };
6
- export declare const MessageInput: React.ForwardRefExoticComponent<MessageInputProps & React.RefAttributes<unknown>>;
7
- export {};
@@ -1,18 +0,0 @@
1
- /// <reference types="react" />
2
- import { IPost } from '@messenger-box/core';
3
- export interface AlertMessageAttachmentsInterface {
4
- title: string;
5
- isTitleHtml: boolean;
6
- icon: string;
7
- callToAction: {
8
- title: string;
9
- link: string;
10
- };
11
- }
12
- export declare function MessageItem({ message, channelId, currentUser, totalCount, onOpen, }: {
13
- message: IPost;
14
- channelId: number;
15
- currentUser: any;
16
- totalCount: number;
17
- onOpen: () => void;
18
- }): JSX.Element;
@@ -1,5 +0,0 @@
1
- interface IPlainMessageProps {
2
- message: string;
3
- }
4
- export declare const PlainMessage: ({ message }: IPlainMessageProps) => JSX.Element;
5
- export {};
@@ -1,52 +0,0 @@
1
- import * as React from 'react';
2
- import { Avatar, Box, Flex, Icon, Text, HStack } from 'native-base';
3
- import { Ionicons } from '@expo/vector-icons';
4
- import { formatDistance } from 'date-fns';
5
- import { FilesList } from './FilesList';
6
- import { IPost } from '@messenger-box/core';
7
- import { IAuthUser } from '@pubngo-stack/core';
8
- import { startCase } from 'lodash';
9
-
10
- interface ICommonMessageProps {
11
- message: IPost;
12
- currentUser: IAuthUser;
13
- }
14
-
15
- export const CommonMessage = (props: ICommonMessageProps) => {
16
- const { message, currentUser } = props;
17
- return (
18
- <Box mb="7">
19
- <HStack space={2}>
20
- <Avatar backgroundColor="grey" source={{ uri: message?.author?.picture || undefined }}>
21
- {startCase(message?.author?.username?.charAt(0))}
22
- </Avatar>
23
- <Box>
24
- <HStack width={'80%'} justifyContent={'space-between'} alignItems={'center'}>
25
- <HStack space={2}>
26
- <Text fontSize="14px" color="gray.600" fontWeight={'bold'}>
27
- {message?.author?.familyName && message?.author?.givenName
28
- ? message?.author?.givenName + ' ' + message?.author?.familyName
29
- : message?.author?.username}
30
- </Text>
31
- <Text fontSize="14px" color="gray.500" ml="10px">
32
- {formatDistance(new Date(message?.createdAt), new Date(), {
33
- includeSeconds: true,
34
- addSuffix: true,
35
- })}
36
- </Text>
37
- </HStack>
38
- {currentUser?.id !== message?.author?.id && (
39
- <Box ml="8px">
40
- <Icon as={Ionicons} name={'flag'} color="gray.600" size="sm" />
41
- </Box>
42
- )}
43
- </HStack>
44
- <Text fontSize="14px" mt="5px">
45
- {message?.message}
46
- </Text>
47
- {message.files?.totalCount ? <FilesList uploaded files={message?.files?.data} /> : null}
48
- </Box>
49
- </HStack>
50
- </Box>
51
- );
52
- };
@@ -1,41 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { Image as ReactNativeImage } from 'react-native';
3
- import { Box, HStack, Image } from 'native-base';
4
-
5
- interface FilesListProps {
6
- files: any;
7
- uploaded?: boolean;
8
- }
9
-
10
- export function FilesList({ files, uploaded = false }: FilesListProps) {
11
- return (
12
- <HStack space={2} mt={2}>
13
- <FilesList.FilesView files={files} uploaded={uploaded}/>
14
- </HStack>
15
- );
16
- }
17
-
18
- FilesList.FilesView = function MessageItemFiles({ files = [], uploaded }: { files: any[]; uploaded?: boolean }) {
19
- if (!files.length) {
20
- return null;
21
- }
22
- return (
23
- <Box>
24
- {files.map((file) => {
25
- const url = useMemo(() => (uploaded ? file.url : ReactNativeImage.resolveAssetSource(file).uri), [file, uploaded]);
26
- return (
27
- <Image
28
- alt={'image'}
29
- mr={2}
30
- height="16"
31
- width="16"
32
- source={{
33
- uri: url,
34
- scale: 0.2,
35
- }}
36
- />
37
- );
38
- })}
39
- </Box>
40
- );
41
- };
@@ -1,88 +0,0 @@
1
- import { TextField, View, Image, Pressable, HStack, VStack, Toast } from 'native-base';
2
- import { FontAwesome } from '@expo/vector-icons';
3
- import * as ImagePicker from 'expo-image-picker';
4
- import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
5
- import React, { forwardRef, useImperativeHandle, useState, useCallback } from 'react';
6
- import { FilesList } from './FilesList';
7
- import axios from 'axios';
8
-
9
- type MessageInputProps = {
10
- channelId?: string;
11
- handleSend: (message: string, files: any) => Promise<void>;
12
- };
13
-
14
- export const MessageInput = forwardRef(function MessageInput({ handleSend: handleSendProp }: MessageInputProps) {
15
- const [message, setMessage] = useState('');
16
- const [sending, setSending] = useState(false);
17
- const [files, setFiles] = useState<File[]>([]);
18
- const [showKeyboard, setShowKeyboard] = useState(false);
19
-
20
- const handleSend = useCallback(() => {
21
- setSending(true);
22
- handleSendProp(message, files)
23
- .then(() => {
24
- setMessage('');
25
- setFiles([]);
26
- })
27
- .finally(() => setSending(false));
28
- }, [files, handleSendProp, message]);
29
-
30
- const onSelectImages = async () => {
31
- // No permissions request is necessary for launching the image library
32
- await ImagePicker.requestMediaLibraryPermissionsAsync();
33
- let result = await ImagePicker.launchImageLibraryAsync({
34
- mediaTypes: ImagePicker.MediaTypeOptions.Images,
35
- allowsEditing: true,
36
- aspect: [4, 3],
37
- quality: 1,
38
- });
39
-
40
- if (!result.cancelled) {
41
- axios
42
- .get((result as any).uri, {
43
- responseType: 'blob',
44
- })
45
- .then((res: any) => {
46
- let file = res.data._data;
47
- file.uri = (result as any).uri;
48
- setFiles(files.concat(file));
49
- });
50
- }
51
- };
52
-
53
- return (
54
- <KeyboardAwareScrollView
55
- keyboardDismissMode="on-drag"
56
- keyboardShouldPersistTaps={'always'}
57
- onKeyboardWillShow={(frames) => {
58
- setShowKeyboard(true);
59
- }}
60
- onKeyboardWillHide={(frames) => {
61
- setShowKeyboard(false);
62
- }}
63
- scrollEnabled={!showKeyboard}
64
- style={{ position: 'absolute', left: 0, right: 0, bottom: showKeyboard ? 300 : 0 }}
65
- >
66
- <VStack bg={'white'} alignContent="center" p={5}>
67
- <View>
68
- <TextField
69
- placeholder="Message..."
70
- borderColor="gray.400"
71
- value={sending ? '' : message}
72
- onChange={(e) => setMessage(e.nativeEvent.text)}
73
- fontSize={14}
74
- />
75
- </View>
76
- {files.length ? (
77
- <View mb={4} flexDirection="row">
78
- <FilesList files={files} />
79
- </View>
80
- ) : null}
81
- <HStack alignContent="center" justifyContent="space-between">
82
- <FontAwesome onPress={onSelectImages} size={20} style={{ marginRight: 5 }} name="file-image-o" />
83
- <FontAwesome onPress={handleSend} size={20} name="send" />
84
- </HStack>
85
- </VStack>
86
- </KeyboardAwareScrollView>
87
- );
88
- });
@@ -1,80 +0,0 @@
1
- import React from 'react';
2
- import { Box, Button, HStack, Icon, Text, useColorModeValue } from 'native-base';
3
- import { Ionicons } from '@expo/vector-icons';
4
- import { useNavigation } from '@react-navigation/native';
5
- import { IPost, IPostTypeEnum } from '@messenger-box/core';
6
- import { PlainMessage } from './PlainMessage';
7
- import { CommonMessage } from './CommonMessage';
8
-
9
- export interface AlertMessageAttachmentsInterface {
10
- title: string;
11
- isTitleHtml: boolean;
12
- icon: string;
13
- callToAction: {
14
- title: string;
15
- link: string;
16
- };
17
- }
18
-
19
- export function MessageItem({
20
- message,
21
- channelId,
22
- currentUser,
23
- totalCount,
24
- onOpen,
25
- }: {
26
- message: IPost;
27
- channelId: number;
28
- currentUser: any;
29
- totalCount: number;
30
- onOpen: () => void;
31
- }) {
32
- if (typeof message === 'string') {
33
- return <PlainMessage message={message} />;
34
- }
35
-
36
- const { type } = message;
37
-
38
- if (!type || type === IPostTypeEnum.Simple) {
39
- return <CommonMessage message={message} currentUser={currentUser} />;
40
- }
41
-
42
- if (type === IPostTypeEnum.ALERT) {
43
- const { attachment } = message?.propsConfiguration?.contents as {
44
- attachment: AlertMessageAttachmentsInterface;
45
- };
46
- let action: string = '';
47
- let actionId: any = '';
48
- const icon = 'information-circle';
49
- if (attachment.callToAction.link.includes('my-reservation-details')) {
50
- action = 'm-reservation-detail';
51
- actionId = attachment?.callToAction?.link.split('/').pop();
52
- }
53
- const color = useColorModeValue('white', 'gray.800');
54
- const bgColor = useColorModeValue('gray.800', 'white');
55
- const navigation = useNavigation<any>();
56
-
57
- return (
58
- <Box borderWidth={1} borderRadius={20} backgroundColor={bgColor} my={2} p={3} opacity={0.7}>
59
- <HStack space={2} alignItems={'center'}>
60
- <Icon as={Ionicons} name={icon} color={'white'} />
61
- <Text color={color} width={'45%'} numberOfLines={3}>
62
- {attachment?.title}
63
- </Text>
64
- {attachment.callToAction ? (
65
- <Button
66
- variant={'outline'}
67
- size={'sm'}
68
- borderColor={color}
69
- onPress={() => navigation.navigate(action, { reservationId: actionId })}
70
- >
71
- <Text color={color}>{attachment.callToAction.title}</Text>
72
- </Button>
73
- ) : null}
74
- </HStack>
75
- </Box>
76
- );
77
- }
78
-
79
- return null;
80
- }
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import { Flex, Text } from 'native-base';
3
-
4
- interface IPlainMessageProps {
5
- message: string;
6
- }
7
-
8
- export const PlainMessage = ({ message }: IPlainMessageProps) => {
9
- return (
10
- <Flex w="full" justifyContent={'center'} mb="7">
11
- <Text fontSize="14px" fontWeight={'bold'}>
12
- {message}
13
- </Text>
14
- </Flex>
15
- );
16
- };