@sendbird/uikit-react-native-foundation 3.5.4 → 3.7.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.
Files changed (49) hide show
  1. package/lib/commonjs/assets/icon/icon-thread.png +0 -0
  2. package/lib/commonjs/assets/icon/icon-thread@2x.png +0 -0
  3. package/lib/commonjs/assets/icon/icon-thread@3x.png +0 -0
  4. package/lib/commonjs/assets/icon/index.js +1 -0
  5. package/lib/commonjs/assets/icon/index.js.map +1 -1
  6. package/lib/commonjs/components/Image/Image.fastimage.js +3 -3
  7. package/lib/commonjs/components/Image/Image.fastimage.js.map +1 -1
  8. package/lib/commonjs/components/ImageWithPlaceholder/index.js.map +1 -1
  9. package/lib/commonjs/styles/createStyleSheet.js +33 -26
  10. package/lib/commonjs/styles/createStyleSheet.js.map +1 -1
  11. package/lib/commonjs/ui/GroupChannelMessage/Message.file.voice.js +17 -2
  12. package/lib/commonjs/ui/GroupChannelMessage/Message.file.voice.js.map +1 -1
  13. package/lib/commonjs/ui/GroupChannelMessage/MessageContainer.js +20 -3
  14. package/lib/commonjs/ui/GroupChannelMessage/MessageContainer.js.map +1 -1
  15. package/lib/commonjs/ui/GroupChannelMessage/index.js.map +1 -1
  16. package/lib/module/assets/icon/icon-thread.png +0 -0
  17. package/lib/module/assets/icon/icon-thread@2x.png +0 -0
  18. package/lib/module/assets/icon/icon-thread@3x.png +0 -0
  19. package/lib/module/assets/icon/index.js +1 -0
  20. package/lib/module/assets/icon/index.js.map +1 -1
  21. package/lib/module/components/Image/Image.fastimage.js +3 -3
  22. package/lib/module/components/Image/Image.fastimage.js.map +1 -1
  23. package/lib/module/components/ImageWithPlaceholder/index.js.map +1 -1
  24. package/lib/module/styles/createStyleSheet.js +34 -26
  25. package/lib/module/styles/createStyleSheet.js.map +1 -1
  26. package/lib/module/ui/GroupChannelMessage/Message.file.voice.js +17 -2
  27. package/lib/module/ui/GroupChannelMessage/Message.file.voice.js.map +1 -1
  28. package/lib/module/ui/GroupChannelMessage/MessageContainer.js +20 -3
  29. package/lib/module/ui/GroupChannelMessage/MessageContainer.js.map +1 -1
  30. package/lib/module/ui/GroupChannelMessage/index.js.map +1 -1
  31. package/lib/typescript/src/assets/icon/index.d.ts +1 -0
  32. package/lib/typescript/src/components/Icon/index.d.ts +1 -0
  33. package/lib/typescript/src/components/ImageWithPlaceholder/index.d.ts +2 -2
  34. package/lib/typescript/src/styles/createStyleSheet.d.ts +1 -1
  35. package/lib/typescript/src/ui/Avatar/index.d.ts +1 -1
  36. package/lib/typescript/src/ui/GroupChannelMessage/Message.file.voice.d.ts +3 -0
  37. package/lib/typescript/src/ui/GroupChannelMessage/MessageContainer.d.ts +2 -2
  38. package/lib/typescript/src/ui/GroupChannelMessage/index.d.ts +12 -0
  39. package/package.json +7 -7
  40. package/src/assets/icon/icon-thread.png +0 -0
  41. package/src/assets/icon/icon-thread@2x.png +0 -0
  42. package/src/assets/icon/icon-thread@3x.png +0 -0
  43. package/src/assets/icon/index.ts +1 -0
  44. package/src/components/Image/Image.fastimage.tsx +3 -3
  45. package/src/components/ImageWithPlaceholder/index.tsx +2 -2
  46. package/src/styles/createStyleSheet.ts +42 -27
  47. package/src/ui/GroupChannelMessage/Message.file.voice.tsx +17 -1
  48. package/src/ui/GroupChannelMessage/MessageContainer.tsx +37 -27
  49. package/src/ui/GroupChannelMessage/index.ts +1 -0
@@ -1,40 +1,51 @@
1
1
  import { ImageStyle, StyleSheet, TextStyle, ViewStyle } from 'react-native';
2
+ import { AnimatableNumericValue, DimensionValue } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
2
3
 
3
4
  import { DEFAULT_SCALE_FACTOR } from './createScaleFactor';
4
5
 
5
6
  type Styles = ViewStyle | TextStyle | ImageStyle;
6
7
  type StylePreprocessor<T extends Styles = Styles> = { [key in keyof T]: (val: NonNullable<T[key]>) => typeof val };
7
8
 
8
- const SCALE_FACTOR_WITH_STR = (val: string | number) => (typeof val === 'string' ? val : DEFAULT_SCALE_FACTOR(val));
9
+ const SCALE_FACTOR_WITH_DIMENSION_VALUE = (
10
+ val: NonNullable<DimensionValue | undefined>,
11
+ ): NonNullable<DimensionValue | undefined> => {
12
+ return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;
13
+ };
14
+
15
+ const DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE = (
16
+ val: NonNullable<AnimatableNumericValue | undefined>,
17
+ ): NonNullable<AnimatableNumericValue | undefined> => {
18
+ return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;
19
+ };
9
20
 
10
21
  const preProcessor: Partial<StylePreprocessor> = {
11
22
  'fontSize': DEFAULT_SCALE_FACTOR,
12
23
  'lineHeight': DEFAULT_SCALE_FACTOR,
13
- 'borderRadius': DEFAULT_SCALE_FACTOR,
14
- 'minWidth': SCALE_FACTOR_WITH_STR,
15
- 'maxWidth': SCALE_FACTOR_WITH_STR,
16
- 'minHeight': SCALE_FACTOR_WITH_STR,
17
- 'maxHeight': SCALE_FACTOR_WITH_STR,
18
- 'height': SCALE_FACTOR_WITH_STR,
19
- 'width': SCALE_FACTOR_WITH_STR,
20
- 'padding': SCALE_FACTOR_WITH_STR,
21
- 'paddingVertical': SCALE_FACTOR_WITH_STR,
22
- 'paddingHorizontal': SCALE_FACTOR_WITH_STR,
23
- 'paddingTop': SCALE_FACTOR_WITH_STR,
24
- 'paddingBottom': SCALE_FACTOR_WITH_STR,
25
- 'paddingLeft': SCALE_FACTOR_WITH_STR,
26
- 'paddingRight': SCALE_FACTOR_WITH_STR,
27
- 'margin': SCALE_FACTOR_WITH_STR,
28
- 'marginVertical': SCALE_FACTOR_WITH_STR,
29
- 'marginHorizontal': SCALE_FACTOR_WITH_STR,
30
- 'marginTop': SCALE_FACTOR_WITH_STR,
31
- 'marginBottom': SCALE_FACTOR_WITH_STR,
32
- 'marginLeft': SCALE_FACTOR_WITH_STR,
33
- 'marginRight': SCALE_FACTOR_WITH_STR,
34
- 'left': SCALE_FACTOR_WITH_STR,
35
- 'right': SCALE_FACTOR_WITH_STR,
36
- 'top': SCALE_FACTOR_WITH_STR,
37
- 'bottom': SCALE_FACTOR_WITH_STR,
24
+ 'borderRadius': DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE,
25
+ 'minWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,
26
+ 'maxWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,
27
+ 'minHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
28
+ 'maxHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
29
+ 'height': SCALE_FACTOR_WITH_DIMENSION_VALUE,
30
+ 'width': SCALE_FACTOR_WITH_DIMENSION_VALUE,
31
+ 'padding': SCALE_FACTOR_WITH_DIMENSION_VALUE,
32
+ 'paddingVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,
33
+ 'paddingHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,
34
+ 'paddingTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,
35
+ 'paddingBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
36
+ 'paddingLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,
37
+ 'paddingRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
38
+ 'margin': SCALE_FACTOR_WITH_DIMENSION_VALUE,
39
+ 'marginVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,
40
+ 'marginHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,
41
+ 'marginTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,
42
+ 'marginBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
43
+ 'marginLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,
44
+ 'marginRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
45
+ 'left': SCALE_FACTOR_WITH_DIMENSION_VALUE,
46
+ 'right': SCALE_FACTOR_WITH_DIMENSION_VALUE,
47
+ 'top': SCALE_FACTOR_WITH_DIMENSION_VALUE,
48
+ 'bottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
38
49
  };
39
50
 
40
51
  const preProcessorKeys = Object.keys(preProcessor);
@@ -46,7 +57,10 @@ const preProcessorLen = preProcessorKeys.length;
46
57
  * @param styles
47
58
  * @returns StyleSheet
48
59
  * */
49
- const createStyleSheet = <T extends StyleSheet.NamedStyles<T>>(styles: T | StyleSheet.NamedStyles<T>): T => {
60
+ /* eslint-disable @typescript-eslint/no-explicit-any */
61
+ const createStyleSheet = <T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>>(
62
+ styles: T & StyleSheet.NamedStyles<any>,
63
+ ): T => {
50
64
  Object.values(styles).forEach((style) => {
51
65
  // @ts-ignore
52
66
  const styleKeys = Object.keys(style);
@@ -61,5 +75,6 @@ const createStyleSheet = <T extends StyleSheet.NamedStyles<T>>(styles: T | Style
61
75
 
62
76
  return StyleSheet.create<T>(styles);
63
77
  };
78
+ /* eslint-enable @typescript-eslint/no-explicit-any */
64
79
 
65
80
  export default createStyleSheet;
@@ -25,6 +25,9 @@ type Props = GroupChannelMessageProps<
25
25
  {
26
26
  durationMetaArrayKey?: string;
27
27
  onUnmount: () => void;
28
+ initialCurrentTime?: number;
29
+ onSubscribeStatus?: (channelUrl: string, messageId: number, subscriber: (currentTime: number) => void) => void;
30
+ onUnsubscribeStatus?: (channelUrl: string, messageId: number, subscriber: (currentTime: number) => void) => void;
28
31
  }
29
32
  >;
30
33
  const VoiceFileMessage = (props: Props) => {
@@ -35,6 +38,9 @@ const VoiceFileMessage = (props: Props) => {
35
38
  message,
36
39
  durationMetaArrayKey = 'KEY_VOICE_MESSAGE_DURATION',
37
40
  onUnmount,
41
+ initialCurrentTime,
42
+ onSubscribeStatus,
43
+ onUnsubscribeStatus,
38
44
  } = props;
39
45
 
40
46
  const { colors } = useUIKitTheme();
@@ -45,7 +51,7 @@ const VoiceFileMessage = (props: Props) => {
45
51
  const initialDuration = value ? parseInt(value, 10) : 0;
46
52
  return {
47
53
  status: 'paused',
48
- currentTime: 0,
54
+ currentTime: initialCurrentTime || 0,
49
55
  duration: initialDuration,
50
56
  };
51
57
  });
@@ -56,6 +62,16 @@ const VoiceFileMessage = (props: Props) => {
56
62
  };
57
63
  }, []);
58
64
 
65
+ useEffect(() => {
66
+ const updateCurrentTime = (currentTime: number) => {
67
+ setState((prev) => ({ ...prev, currentTime }));
68
+ };
69
+ onSubscribeStatus?.(props.channel.url, props.message.messageId, updateCurrentTime);
70
+ return () => {
71
+ onUnsubscribeStatus?.(props.channel.url, props.message.messageId, updateCurrentTime);
72
+ };
73
+ }, []);
74
+
59
75
  const uiColors = colors.ui.groupChannelMessage[variant];
60
76
  const remainingTime = state.duration - state.currentTime;
61
77
 
@@ -23,6 +23,7 @@ const MessageContainer = (props: Props) => {
23
23
 
24
24
  MessageContainer.Incoming = function MessageContainerIncoming({
25
25
  children,
26
+ replyInfo,
26
27
  groupedWithNext,
27
28
  groupedWithPrev,
28
29
  message,
@@ -34,43 +35,49 @@ MessageContainer.Incoming = function MessageContainerIncoming({
34
35
  const color = colors.ui.groupChannelMessage.incoming;
35
36
 
36
37
  return (
37
- <Box flexDirection={'row'} justifyContent={'flex-start'} alignItems={'flex-end'}>
38
- <Box width={26} marginRight={12}>
39
- {(message.isFileMessage() || message.isUserMessage()) && !groupedWithNext && (
40
- <Pressable onPress={onPressAvatar}>
41
- <Avatar size={26} uri={message.sender?.profileUrl} />
42
- </Pressable>
43
- )}
44
- </Box>
45
- <Box flexShrink={1}>
46
- {parentMessage}
47
- {!groupedWithPrev && !message.parentMessage && (
48
- <Box marginLeft={12} marginBottom={4}>
49
- {(message.isFileMessage() || message.isUserMessage()) && (
50
- <Text caption1 color={color.enabled.textSenderName} numberOfLines={1}>
51
- {strings?.senderName ?? message.sender.nickname}
52
- </Text>
53
- )}
54
- </Box>
55
- )}
56
-
57
- <Box flexDirection={'row'} alignItems={'flex-end'}>
58
- <Box style={styles.bubble}>{children}</Box>
59
- {!groupedWithNext && (
60
- <Box marginLeft={4}>
61
- <Text caption4 color={color.enabled.textTime}>
62
- {strings?.sentDate ?? getMessageTimeFormat(new Date(message.createdAt))}
63
- </Text>
38
+ <Box flexDirection={'column'} justifyContent={'flex-start'} alignItems={'flex-start'}>
39
+ <Box flexDirection={'row'} justifyContent={'flex-start'} alignItems={'flex-end'}>
40
+ <Box width={26} marginRight={12}>
41
+ {(message.isFileMessage() || message.isUserMessage()) && !groupedWithNext && (
42
+ <Pressable onPress={onPressAvatar}>
43
+ <Avatar size={26} uri={message.sender?.profileUrl} />
44
+ </Pressable>
45
+ )}
46
+ </Box>
47
+ <Box flexShrink={1}>
48
+ {parentMessage}
49
+ {!groupedWithPrev && !parentMessage && (
50
+ <Box marginLeft={12} marginBottom={4}>
51
+ {(message.isFileMessage() || message.isUserMessage()) && (
52
+ <Text caption1 color={color.enabled.textSenderName} numberOfLines={1}>
53
+ {strings?.senderName ?? message.sender.nickname}
54
+ </Text>
55
+ )}
64
56
  </Box>
65
57
  )}
58
+ <Box flexDirection={'row'} alignItems={'flex-end'}>
59
+ <Box style={styles.bubble}>{children}</Box>
60
+ {!groupedWithNext && (
61
+ <Box marginLeft={4}>
62
+ <Text caption4 color={color.enabled.textTime}>
63
+ {strings?.sentDate ?? getMessageTimeFormat(new Date(message.createdAt))}
64
+ </Text>
65
+ </Box>
66
+ )}
67
+ </Box>
66
68
  </Box>
67
69
  </Box>
70
+ <Box flexDirection={'row'} marginTop={4}>
71
+ <Box width={26} marginRight={12} justifyContent={'flex-start'} />
72
+ {replyInfo}
73
+ </Box>
68
74
  </Box>
69
75
  );
70
76
  };
71
77
 
72
78
  MessageContainer.Outgoing = function MessageContainerOutgoing({
73
79
  children,
80
+ replyInfo,
74
81
  message,
75
82
  groupedWithNext,
76
83
  strings,
@@ -96,6 +103,9 @@ MessageContainer.Outgoing = function MessageContainerOutgoing({
96
103
  </Box>
97
104
  <Box style={styles.bubble}>{children}</Box>
98
105
  </Box>
106
+ <Box flexDirection={'row'} justifyContent={'flex-end'} marginTop={4}>
107
+ {replyInfo}
108
+ </Box>
99
109
  </Box>
100
110
  );
101
111
  };
@@ -28,6 +28,7 @@ export type GroupChannelMessageProps<T extends SendbirdMessage, AdditionalProps
28
28
  children?: React.ReactNode;
29
29
  sendingStatus?: React.ReactNode;
30
30
  parentMessage?: React.ReactNode;
31
+ replyInfo?: React.ReactNode;
31
32
 
32
33
  groupedWithPrev: boolean;
33
34
  groupedWithNext: boolean;