@droppii-org/chat-mobile 0.2.68 → 0.2.70

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 (69) hide show
  1. package/lib/module/components/GroupItem/index.js +152 -0
  2. package/lib/module/components/GroupItem/index.js.map +1 -0
  3. package/lib/module/core/useChatListener.js +33 -2
  4. package/lib/module/core/useChatListener.js.map +1 -1
  5. package/lib/module/hooks/conversation/useGetConversationDetail.js +2 -2
  6. package/lib/module/hooks/conversation/useGetConversationDetail.js.map +1 -1
  7. package/lib/module/hooks/groups/useFetchPublicGroup.js +39 -0
  8. package/lib/module/hooks/groups/useFetchPublicGroup.js.map +1 -0
  9. package/lib/module/hooks/groups/useJoinGroup.js +42 -0
  10. package/lib/module/hooks/groups/useJoinGroup.js.map +1 -0
  11. package/lib/module/hooks/query-keys.js +6 -0
  12. package/lib/module/hooks/query-keys.js.map +1 -1
  13. package/lib/module/index.js +1 -1
  14. package/lib/module/index.js.map +1 -1
  15. package/lib/module/screens/SearchConversation/TabResult.js +1 -1
  16. package/lib/module/screens/SearchConversation/TabResult.js.map +1 -1
  17. package/lib/module/screens/chat-detail/ChatComposer.js +33 -4
  18. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  19. package/lib/module/screens/chat-detail/ChatDetail.js +20 -2
  20. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  21. package/lib/module/screens/chat-detail/ChatListLegend.js +16 -17
  22. package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
  23. package/lib/module/screens/chat-detail/types.js.map +1 -1
  24. package/lib/module/screens/inbox/CommunityTab.js +55 -0
  25. package/lib/module/screens/inbox/CommunityTab.js.map +1 -0
  26. package/lib/module/screens/inbox/Inbox.js +51 -40
  27. package/lib/module/screens/inbox/Inbox.js.map +1 -1
  28. package/lib/module/translation/resources/i18n.js +10 -1
  29. package/lib/module/translation/resources/i18n.js.map +1 -1
  30. package/lib/typescript/src/components/GroupItem/index.d.ts +8 -0
  31. package/lib/typescript/src/components/GroupItem/index.d.ts.map +1 -0
  32. package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
  33. package/lib/typescript/src/hooks/groups/useFetchPublicGroup.d.ts +213 -0
  34. package/lib/typescript/src/hooks/groups/useFetchPublicGroup.d.ts.map +1 -0
  35. package/lib/typescript/src/hooks/groups/useJoinGroup.d.ts +5 -0
  36. package/lib/typescript/src/hooks/groups/useJoinGroup.d.ts.map +1 -0
  37. package/lib/typescript/src/hooks/query-keys.d.ts +6 -0
  38. package/lib/typescript/src/hooks/query-keys.d.ts.map +1 -1
  39. package/lib/typescript/src/index.d.ts +1 -1
  40. package/lib/typescript/src/index.d.ts.map +1 -1
  41. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +3 -1
  42. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  43. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts +1 -1
  44. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  45. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts +1 -1
  46. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
  47. package/lib/typescript/src/screens/chat-detail/types.d.ts +2 -1
  48. package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
  49. package/lib/typescript/src/screens/inbox/CommunityTab.d.ts +6 -0
  50. package/lib/typescript/src/screens/inbox/CommunityTab.d.ts.map +1 -0
  51. package/lib/typescript/src/screens/inbox/Inbox.d.ts +2 -1
  52. package/lib/typescript/src/screens/inbox/Inbox.d.ts.map +1 -1
  53. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  54. package/package.json +1 -1
  55. package/src/components/GroupItem/index.tsx +174 -0
  56. package/src/core/useChatListener.ts +53 -1
  57. package/src/hooks/conversation/useGetConversationDetail.ts +2 -2
  58. package/src/hooks/groups/useFetchPublicGroup.ts +43 -0
  59. package/src/hooks/groups/useJoinGroup.ts +46 -0
  60. package/src/hooks/query-keys.ts +8 -0
  61. package/src/index.tsx +5 -1
  62. package/src/screens/SearchConversation/TabResult.tsx +1 -1
  63. package/src/screens/chat-detail/ChatComposer.tsx +46 -3
  64. package/src/screens/chat-detail/ChatDetail.tsx +25 -1
  65. package/src/screens/chat-detail/ChatListLegend.tsx +11 -13
  66. package/src/screens/chat-detail/types.ts +5 -1
  67. package/src/screens/inbox/CommunityTab.tsx +65 -0
  68. package/src/screens/inbox/Inbox.tsx +51 -39
  69. package/src/translation/resources/i18n.ts +9 -0
@@ -0,0 +1,65 @@
1
+ import { KContainer, KSpacingValue } from '@droppii/libs';
2
+ import { memo, useCallback } from 'react';
3
+ import { ActivityIndicator, StyleSheet } from 'react-native';
4
+ import type { SearchPublicGroupInfo } from '@droppii/openim-rn-client-sdk';
5
+ import { useFetchPublicGroup } from '../../hooks/groups/useFetchPublicGroup';
6
+ import { GroupItem } from '../../components/GroupItem';
7
+
8
+ interface CommunityTabProps {
9
+ onPressGroup?: (groupId: string) => void;
10
+ }
11
+ export const CommunityTab = memo(({ onPressGroup }: CommunityTabProps) => {
12
+ const {
13
+ dataFlatten,
14
+ isFetching,
15
+ hasNextPage,
16
+ fetchNextPage,
17
+ isFetchingNextPage,
18
+ isRefetching,
19
+ refetch,
20
+ } = useFetchPublicGroup('');
21
+
22
+ const renderItem = useCallback(
23
+ ({ item }: { item: SearchPublicGroupInfo }) => (
24
+ <GroupItem item={item} onPress={onPressGroup} />
25
+ ),
26
+ [onPressGroup]
27
+ );
28
+
29
+ const keyExtractor = useCallback(
30
+ (item: SearchPublicGroupInfo) => item.groupID,
31
+ []
32
+ );
33
+
34
+ const onEndReached = useCallback(() => {
35
+ if (hasNextPage && !isFetchingNextPage) {
36
+ fetchNextPage();
37
+ }
38
+ }, [hasNextPage, isFetchingNextPage, fetchNextPage]);
39
+
40
+ return (
41
+ <KContainer.Page flex>
42
+ {isFetching && !isFetchingNextPage && !isRefetching ? (
43
+ <KContainer.View flex center>
44
+ <ActivityIndicator />
45
+ </KContainer.View>
46
+ ) : (
47
+ <KContainer.FlatList
48
+ data={dataFlatten}
49
+ renderItem={renderItem}
50
+ keyExtractor={keyExtractor}
51
+ onEndReached={onEndReached}
52
+ refreshing={isRefetching}
53
+ onRefresh={refetch}
54
+ contentContainerStyle={styles.contentContainer}
55
+ />
56
+ )}
57
+ </KContainer.Page>
58
+ );
59
+ });
60
+
61
+ const styles = StyleSheet.create({
62
+ contentContainer: {
63
+ paddingHorizontal: KSpacingValue['0.75rem'],
64
+ },
65
+ });
@@ -1,38 +1,56 @@
1
1
  import { memo, useCallback, useState } from 'react';
2
2
  import { StyleSheet } from 'react-native';
3
3
  import { TabView } from 'react-native-tab-view';
4
- import { KContainer, KImage, KLabel, KColors } from '@droppii/libs';
4
+ import {
5
+ KContainer,
6
+ KImage,
7
+ KLabel,
8
+ KColors,
9
+ KRadiusValue,
10
+ KSpacingValue,
11
+ } from '@droppii/libs';
5
12
  import { MessagesTab } from './MessagesTab';
13
+ import { trans } from '../../translation';
14
+ import { CommunityTab } from './CommunityTab';
6
15
 
7
16
  interface InboxProps {
8
17
  onPressThread?: (item: string) => void;
9
18
  onPressSearch?: () => void;
10
19
  onPressEdit?: () => void;
11
20
  onPressContact?: () => void;
21
+ onPressGroup?: (groupId: string) => void;
12
22
  }
13
23
 
14
24
  type TabRoute = { key: string; title: string };
15
25
 
26
+ const TabRoutes: TabRoute[] = [
27
+ { key: 'messages', title: trans('messages') },
28
+ { key: 'community', title: trans('community') },
29
+ ];
30
+
16
31
  const Inbox = memo(
17
32
  ({
18
33
  onPressThread,
19
34
  onPressSearch,
20
35
  onPressEdit,
21
36
  onPressContact,
37
+ onPressGroup,
22
38
  }: InboxProps) => {
23
39
  const [index, setIndex] = useState(0);
24
- const [routes] = useState<TabRoute[]>([
25
- { key: 'messages', title: 'Tin nhắn' },
26
- ]);
40
+ const [routes] = useState<TabRoute[]>(TabRoutes);
27
41
 
28
42
  const renderScene = useCallback(
29
43
  ({ route }: { route: TabRoute }) => {
30
- if (route.key === 'messages') {
31
- return <MessagesTab onPressThread={onPressThread} />;
44
+ switch (route.key) {
45
+ case 'messages':
46
+ return <MessagesTab onPressThread={onPressThread} />;
47
+ case 'community':
48
+ return <CommunityTab onPressGroup={onPressGroup} />;
49
+ default:
50
+ return null;
32
51
  }
33
- return null;
34
52
  },
35
- [onPressThread]
53
+ [onPressThread, onPressGroup]
36
54
  );
37
55
 
38
56
  const renderTabBar = useCallback(
@@ -46,24 +64,18 @@ const Inbox = memo(
46
64
  <KContainer.Touchable
47
65
  key={route.key}
48
66
  onPress={() => setIndex(i)}
49
- paddingV="0.75rem"
50
- marginR="1rem"
51
67
  style={styles.tabItem}
52
68
  activeOpacity={0.7}
53
69
  >
54
70
  <KLabel.Text
55
71
  typo="TextNmBold"
56
72
  color={
57
- isActive
58
- ? KColors.palette.primary.w400
59
- : KColors.palette.gray.w500
73
+ isActive ? KColors.primary.normal : KColors.gray.light
60
74
  }
61
75
  >
62
76
  {route.title}
63
77
  </KLabel.Text>
64
- {isActive && (
65
- <KContainer.View style={styles.activeIndicator} />
66
- )}
78
+ {isActive && <KContainer.View style={styles.indicator} />}
67
79
  </KContainer.Touchable>
68
80
  );
69
81
  })}
@@ -77,10 +89,9 @@ const Inbox = memo(
77
89
  activeOpacity={0.7}
78
90
  >
79
91
  <KImage.VectorIcons
80
- name="magnify"
81
- provider="MaterialCommunityIcons"
92
+ name="search-o"
82
93
  size={24}
83
- color={KColors.palette.primary.w400}
94
+ color={KColors.primary.normal}
84
95
  />
85
96
  </KContainer.Touchable>
86
97
  <KContainer.Touchable
@@ -89,10 +100,9 @@ const Inbox = memo(
89
100
  activeOpacity={0.7}
90
101
  >
91
102
  <KImage.VectorIcons
92
- name="square-edit-outline"
93
- provider="MaterialCommunityIcons"
103
+ name="plus-circle-o"
94
104
  size={24}
95
- color={KColors.palette.primary.w400}
105
+ color={KColors.primary.normal}
96
106
  />
97
107
  </KContainer.Touchable>
98
108
  <KContainer.Touchable
@@ -101,10 +111,9 @@ const Inbox = memo(
101
111
  activeOpacity={0.7}
102
112
  >
103
113
  <KImage.VectorIcons
104
- name="account-group-outline"
105
- provider="MaterialCommunityIcons"
114
+ name="user-three-o"
106
115
  size={24}
107
- color={KColors.palette.primary.w400}
116
+ color={KColors.primary.normal}
108
117
  />
109
118
  </KContainer.Touchable>
110
119
  </KContainer.View>
@@ -114,13 +123,13 @@ const Inbox = memo(
114
123
  );
115
124
 
116
125
  return (
117
- <KContainer.Page flex edges={['top', 'bottom']}>
126
+ <KContainer.Page flex edges={['top']}>
118
127
  <TabView
119
128
  navigationState={{ index, routes }}
120
129
  renderScene={renderScene}
121
130
  renderTabBar={renderTabBar}
122
131
  onIndexChange={setIndex}
123
- swipeEnabled={routes.length > 1}
132
+ lazy
124
133
  />
125
134
  </KContainer.Page>
126
135
  );
@@ -133,25 +142,28 @@ export default Inbox;
133
142
 
134
143
  const styles = StyleSheet.create({
135
144
  tabBar: {
136
- borderBottomWidth: 0.5,
137
- borderBottomColor: KColors.palette.gray.w100,
138
- paddingHorizontal: 12,
145
+ borderBottomWidth: 1,
146
+ borderBottomColor: KColors.border.light,
147
+ paddingTop: 2,
139
148
  },
140
149
  tabItem: {
141
- position: 'relative',
142
- paddingTop: 2,
143
- paddingBottom: 0,
150
+ height: 40,
151
+ marginHorizontal: KSpacingValue['0.75rem'],
152
+ justifyContent: 'center',
153
+ alignItems: 'center',
144
154
  },
145
- activeIndicator: {
155
+ indicator: {
156
+ height: 3,
157
+ backgroundColor: KColors.primary.normal,
158
+ width: '100%',
159
+ borderRadius: KRadiusValue.x,
146
160
  position: 'absolute',
147
- bottom: 0,
161
+ bottom: -1,
148
162
  left: 0,
149
163
  right: 0,
150
- height: 3,
151
- borderRadius: 4,
152
- backgroundColor: KColors.palette.primary.w400,
153
164
  },
154
165
  actionGroup: {
155
- gap: 4,
166
+ gap: KSpacingValue['0.25rem'],
167
+ paddingRight: KSpacingValue['0.5rem'],
156
168
  },
157
169
  });
@@ -165,6 +165,15 @@ const i18nKey: Record<string, string> = {
165
165
  'search_message:revoked_message': 'Tin nhắn đã được thu hồi',
166
166
  'chat:no_permission': 'Bạn không có quyền này',
167
167
  'chat:no_send_permission': 'Bạn không có quyền gửi tin nhắn',
168
+ 'community': 'Cộng đồng',
169
+ 'group:member_count': '{{count}} thành viên',
170
+ 'group:access': 'Truy cập',
171
+ 'group:join': 'Tham gia',
172
+ 'group:not_in_group': 'Bạn cần tham gia nhóm để gửi tin nhắn',
173
+ 'group:cannot_send_message': 'Bạn không thể gửi tin nhắn vào nhóm này',
174
+ 'group:joined_group': 'Đã tham gia nhóm {{groupName}}',
175
+ 'group:public_group': 'Nhóm công khai',
176
+ 'group:private_group': 'Nhóm riêng tư',
168
177
  };
169
178
 
170
179
  export default {