feeddo-react-native 0.0.0-stage → 0.1.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 (225) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +401 -2
  3. package/android/build.gradle +39 -0
  4. package/android/src/main/AndroidManifest.xml +1 -0
  5. package/android/src/main/java/dev/feeddo/reactnative/FeeddoReactNativeModule.java +380 -0
  6. package/android/src/main/java/dev/feeddo/reactnative/FeeddoReactNativePackage.java +25 -0
  7. package/dist/Feeddo.d.ts +131 -0
  8. package/dist/Feeddo.d.ts.map +1 -0
  9. package/dist/Feeddo.js +176 -0
  10. package/dist/Feeddo.js.map +1 -0
  11. package/dist/FeeddoClient.d.ts +151 -0
  12. package/dist/FeeddoClient.d.ts.map +1 -0
  13. package/dist/FeeddoClient.js +690 -0
  14. package/dist/FeeddoClient.js.map +1 -0
  15. package/dist/FeeddoProvider.d.ts +23 -0
  16. package/dist/FeeddoProvider.d.ts.map +1 -0
  17. package/dist/FeeddoProvider.js +76 -0
  18. package/dist/FeeddoProvider.js.map +1 -0
  19. package/dist/config/FeeddoConfig.d.ts +10 -0
  20. package/dist/config/FeeddoConfig.d.ts.map +1 -0
  21. package/dist/config/FeeddoConfig.js +10 -0
  22. package/dist/config/FeeddoConfig.js.map +1 -0
  23. package/dist/index.d.ts +36 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +38 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/models/Conversation.d.ts +27 -0
  28. package/dist/models/Conversation.d.ts.map +1 -0
  29. package/dist/models/Conversation.js +24 -0
  30. package/dist/models/Conversation.js.map +1 -0
  31. package/dist/models/EndUser.d.ts +49 -0
  32. package/dist/models/EndUser.d.ts.map +1 -0
  33. package/dist/models/EndUser.js +2 -0
  34. package/dist/models/EndUser.js.map +1 -0
  35. package/dist/models/FeeddoNotification.d.ts +15 -0
  36. package/dist/models/FeeddoNotification.d.ts.map +1 -0
  37. package/dist/models/FeeddoNotification.js +15 -0
  38. package/dist/models/FeeddoNotification.js.map +1 -0
  39. package/dist/models/HomeData.d.ts +16 -0
  40. package/dist/models/HomeData.d.ts.map +1 -0
  41. package/dist/models/HomeData.js +19 -0
  42. package/dist/models/HomeData.js.map +1 -0
  43. package/dist/models/Message.d.ts +12 -0
  44. package/dist/models/Message.d.ts.map +1 -0
  45. package/dist/models/Message.js +25 -0
  46. package/dist/models/Message.js.map +1 -0
  47. package/dist/models/PushProvider.d.ts +14 -0
  48. package/dist/models/PushProvider.d.ts.map +1 -0
  49. package/dist/models/PushProvider.js +9 -0
  50. package/dist/models/PushProvider.js.map +1 -0
  51. package/dist/models/Task.d.ts +17 -0
  52. package/dist/models/Task.d.ts.map +1 -0
  53. package/dist/models/Task.js +22 -0
  54. package/dist/models/Task.js.map +1 -0
  55. package/dist/models/TaskComment.d.ts +11 -0
  56. package/dist/models/TaskComment.d.ts.map +1 -0
  57. package/dist/models/TaskComment.js +27 -0
  58. package/dist/models/TaskComment.js.map +1 -0
  59. package/dist/models/Ticket.d.ts +13 -0
  60. package/dist/models/Ticket.d.ts.map +1 -0
  61. package/dist/models/Ticket.js +14 -0
  62. package/dist/models/Ticket.js.map +1 -0
  63. package/dist/native/FeeddoNative.d.ts +58 -0
  64. package/dist/native/FeeddoNative.d.ts.map +1 -0
  65. package/dist/native/FeeddoNative.js +22 -0
  66. package/dist/native/FeeddoNative.js.map +1 -0
  67. package/dist/push/FeeddoPushNotificationApns.d.ts +73 -0
  68. package/dist/push/FeeddoPushNotificationApns.d.ts.map +1 -0
  69. package/dist/push/FeeddoPushNotificationApns.js +301 -0
  70. package/dist/push/FeeddoPushNotificationApns.js.map +1 -0
  71. package/dist/services/ApiService.d.ts +64 -0
  72. package/dist/services/ApiService.d.ts.map +1 -0
  73. package/dist/services/ApiService.js +406 -0
  74. package/dist/services/ApiService.js.map +1 -0
  75. package/dist/services/ConversationService.d.ts +45 -0
  76. package/dist/services/ConversationService.d.ts.map +1 -0
  77. package/dist/services/ConversationService.js +259 -0
  78. package/dist/services/ConversationService.js.map +1 -0
  79. package/dist/services/WebSocketService.d.ts +26 -0
  80. package/dist/services/WebSocketService.d.ts.map +1 -0
  81. package/dist/services/WebSocketService.js +157 -0
  82. package/dist/services/WebSocketService.js.map +1 -0
  83. package/dist/theme/FeeddoTheme.d.ts +31 -0
  84. package/dist/theme/FeeddoTheme.d.ts.map +1 -0
  85. package/dist/theme/FeeddoTheme.js +60 -0
  86. package/dist/theme/FeeddoTheme.js.map +1 -0
  87. package/dist/ui/FeeddoFeedbackCard.d.ts +15 -0
  88. package/dist/ui/FeeddoFeedbackCard.d.ts.map +1 -0
  89. package/dist/ui/FeeddoFeedbackCard.js +188 -0
  90. package/dist/ui/FeeddoFeedbackCard.js.map +1 -0
  91. package/dist/ui/FeeddoModal.d.ts +20 -0
  92. package/dist/ui/FeeddoModal.d.ts.map +1 -0
  93. package/dist/ui/FeeddoModal.js +174 -0
  94. package/dist/ui/FeeddoModal.js.map +1 -0
  95. package/dist/ui/components/AttachmentPreview.d.ts +10 -0
  96. package/dist/ui/components/AttachmentPreview.d.ts.map +1 -0
  97. package/dist/ui/components/AttachmentPreview.js +143 -0
  98. package/dist/ui/components/AttachmentPreview.js.map +1 -0
  99. package/dist/ui/components/ChatInputArea.d.ts +16 -0
  100. package/dist/ui/components/ChatInputArea.d.ts.map +1 -0
  101. package/dist/ui/components/ChatInputArea.js +85 -0
  102. package/dist/ui/components/ChatInputArea.js.map +1 -0
  103. package/dist/ui/components/FeeddoIcon.d.ts +10 -0
  104. package/dist/ui/components/FeeddoIcon.d.ts.map +1 -0
  105. package/dist/ui/components/FeeddoIcon.js +690 -0
  106. package/dist/ui/components/FeeddoIcon.js.map +1 -0
  107. package/dist/ui/components/FeeddoNotificationBadge.d.ts +14 -0
  108. package/dist/ui/components/FeeddoNotificationBadge.d.ts.map +1 -0
  109. package/dist/ui/components/FeeddoNotificationBadge.js +171 -0
  110. package/dist/ui/components/FeeddoNotificationBadge.js.map +1 -0
  111. package/dist/ui/components/MessageBubble.d.ts +13 -0
  112. package/dist/ui/components/MessageBubble.d.ts.map +1 -0
  113. package/dist/ui/components/MessageBubble.js +163 -0
  114. package/dist/ui/components/MessageBubble.js.map +1 -0
  115. package/dist/ui/components/NotificationsSheet.d.ts +10 -0
  116. package/dist/ui/components/NotificationsSheet.d.ts.map +1 -0
  117. package/dist/ui/components/NotificationsSheet.js +252 -0
  118. package/dist/ui/components/NotificationsSheet.js.map +1 -0
  119. package/dist/ui/components/RatingWidget.d.ts +11 -0
  120. package/dist/ui/components/RatingWidget.d.ts.map +1 -0
  121. package/dist/ui/components/RatingWidget.js +34 -0
  122. package/dist/ui/components/RatingWidget.js.map +1 -0
  123. package/dist/ui/components/TaskCard.d.ts +12 -0
  124. package/dist/ui/components/TaskCard.d.ts.map +1 -0
  125. package/dist/ui/components/TaskCard.js +210 -0
  126. package/dist/ui/components/TaskCard.js.map +1 -0
  127. package/dist/ui/components/TaskDetailsSheet.d.ts +15 -0
  128. package/dist/ui/components/TaskDetailsSheet.d.ts.map +1 -0
  129. package/dist/ui/components/TaskDetailsSheet.js +577 -0
  130. package/dist/ui/components/TaskDetailsSheet.js.map +1 -0
  131. package/dist/ui/components/TicketCard.d.ts +11 -0
  132. package/dist/ui/components/TicketCard.d.ts.map +1 -0
  133. package/dist/ui/components/TicketCard.js +100 -0
  134. package/dist/ui/components/TicketCard.js.map +1 -0
  135. package/dist/ui/components/TicketDetailsSheet.d.ts +14 -0
  136. package/dist/ui/components/TicketDetailsSheet.d.ts.map +1 -0
  137. package/dist/ui/components/TicketDetailsSheet.js +254 -0
  138. package/dist/ui/components/TicketDetailsSheet.js.map +1 -0
  139. package/dist/ui/components/TypingIndicator.d.ts +10 -0
  140. package/dist/ui/components/TypingIndicator.d.ts.map +1 -0
  141. package/dist/ui/components/TypingIndicator.js +77 -0
  142. package/dist/ui/components/TypingIndicator.js.map +1 -0
  143. package/dist/ui/screens/FeeddoChatScreen.d.ts +13 -0
  144. package/dist/ui/screens/FeeddoChatScreen.d.ts.map +1 -0
  145. package/dist/ui/screens/FeeddoChatScreen.js +681 -0
  146. package/dist/ui/screens/FeeddoChatScreen.js.map +1 -0
  147. package/dist/ui/screens/FeeddoHomeScreen.d.ts +15 -0
  148. package/dist/ui/screens/FeeddoHomeScreen.d.ts.map +1 -0
  149. package/dist/ui/screens/FeeddoHomeScreen.js +653 -0
  150. package/dist/ui/screens/FeeddoHomeScreen.js.map +1 -0
  151. package/dist/ui/screens/FeeddoMessagesScreen.d.ts +12 -0
  152. package/dist/ui/screens/FeeddoMessagesScreen.d.ts.map +1 -0
  153. package/dist/ui/screens/FeeddoMessagesScreen.js +326 -0
  154. package/dist/ui/screens/FeeddoMessagesScreen.js.map +1 -0
  155. package/dist/ui/screens/FeeddoTasksScreen.d.ts +13 -0
  156. package/dist/ui/screens/FeeddoTasksScreen.d.ts.map +1 -0
  157. package/dist/ui/screens/FeeddoTasksScreen.js +517 -0
  158. package/dist/ui/screens/FeeddoTasksScreen.js.map +1 -0
  159. package/dist/ui/screens/FeeddoTicketsScreen.d.ts +10 -0
  160. package/dist/ui/screens/FeeddoTicketsScreen.d.ts.map +1 -0
  161. package/dist/ui/screens/FeeddoTicketsScreen.js +112 -0
  162. package/dist/ui/screens/FeeddoTicketsScreen.js.map +1 -0
  163. package/dist/utils/DeviceInfoHelper.d.ts +29 -0
  164. package/dist/utils/DeviceInfoHelper.d.ts.map +1 -0
  165. package/dist/utils/DeviceInfoHelper.js +190 -0
  166. package/dist/utils/DeviceInfoHelper.js.map +1 -0
  167. package/dist/utils/MediaHelper.d.ts +20 -0
  168. package/dist/utils/MediaHelper.d.ts.map +1 -0
  169. package/dist/utils/MediaHelper.js +92 -0
  170. package/dist/utils/MediaHelper.js.map +1 -0
  171. package/dist/utils/NotificationSupport.d.ts +22 -0
  172. package/dist/utils/NotificationSupport.d.ts.map +1 -0
  173. package/dist/utils/NotificationSupport.js +211 -0
  174. package/dist/utils/NotificationSupport.js.map +1 -0
  175. package/dist/utils/StorageHelper.d.ts +65 -0
  176. package/dist/utils/StorageHelper.d.ts.map +1 -0
  177. package/dist/utils/StorageHelper.js +273 -0
  178. package/dist/utils/StorageHelper.js.map +1 -0
  179. package/feeddo-react-native.podspec +26 -0
  180. package/ios/FeeddoReactNativeModule.h +8 -0
  181. package/ios/FeeddoReactNativeModule.m +831 -0
  182. package/package.json +56 -4
  183. package/src/Feeddo.ts +247 -0
  184. package/src/FeeddoClient.ts +895 -0
  185. package/src/FeeddoProvider.tsx +139 -0
  186. package/src/config/FeeddoConfig.ts +9 -0
  187. package/src/index.ts +67 -0
  188. package/src/models/Conversation.ts +50 -0
  189. package/src/models/EndUser.ts +65 -0
  190. package/src/models/FeeddoNotification.ts +29 -0
  191. package/src/models/HomeData.ts +33 -0
  192. package/src/models/Message.ts +36 -0
  193. package/src/models/PushProvider.ts +15 -0
  194. package/src/models/Task.ts +40 -0
  195. package/src/models/TaskComment.ts +36 -0
  196. package/src/models/Ticket.ts +25 -0
  197. package/src/native/FeeddoNative.ts +80 -0
  198. package/src/push/FeeddoPushNotificationApns.ts +362 -0
  199. package/src/services/ApiService.ts +456 -0
  200. package/src/services/ConversationService.ts +305 -0
  201. package/src/services/WebSocketService.ts +185 -0
  202. package/src/theme/FeeddoTheme.ts +85 -0
  203. package/src/ui/FeeddoFeedbackCard.tsx +245 -0
  204. package/src/ui/FeeddoModal.tsx +303 -0
  205. package/src/ui/components/AttachmentPreview.tsx +192 -0
  206. package/src/ui/components/ChatInputArea.tsx +154 -0
  207. package/src/ui/components/FeeddoIcon.tsx +903 -0
  208. package/src/ui/components/FeeddoNotificationBadge.tsx +234 -0
  209. package/src/ui/components/MessageBubble.tsx +223 -0
  210. package/src/ui/components/NotificationsSheet.tsx +324 -0
  211. package/src/ui/components/RatingWidget.tsx +64 -0
  212. package/src/ui/components/TaskCard.tsx +259 -0
  213. package/src/ui/components/TaskDetailsSheet.tsx +747 -0
  214. package/src/ui/components/TicketCard.tsx +128 -0
  215. package/src/ui/components/TicketDetailsSheet.tsx +324 -0
  216. package/src/ui/components/TypingIndicator.tsx +104 -0
  217. package/src/ui/screens/FeeddoChatScreen.tsx +877 -0
  218. package/src/ui/screens/FeeddoHomeScreen.tsx +824 -0
  219. package/src/ui/screens/FeeddoMessagesScreen.tsx +414 -0
  220. package/src/ui/screens/FeeddoTasksScreen.tsx +671 -0
  221. package/src/ui/screens/FeeddoTicketsScreen.tsx +164 -0
  222. package/src/utils/DeviceInfoHelper.ts +209 -0
  223. package/src/utils/MediaHelper.ts +105 -0
  224. package/src/utils/NotificationSupport.ts +233 -0
  225. package/src/utils/StorageHelper.ts +305 -0
@@ -0,0 +1,824 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ TouchableOpacity,
7
+ ScrollView,
8
+ Modal,
9
+ TextInput,
10
+ SafeAreaView,
11
+ Platform,
12
+ Alert,
13
+ } from 'react-native';
14
+ import { FeeddoTheme } from '../../theme/FeeddoTheme';
15
+ import { FeeddoIcon } from '../components/FeeddoIcon';
16
+ import { TaskCard } from '../components/TaskCard';
17
+ import { TicketCard } from '../components/TicketCard';
18
+ import { TaskDetailsSheet } from '../components/TaskDetailsSheet';
19
+ import { TicketDetailsSheet } from '../components/TicketDetailsSheet';
20
+ import { NotificationsSheet } from '../components/NotificationsSheet';
21
+ import { HomeData } from '../../models/HomeData';
22
+ import { Conversation } from '../../models/Conversation';
23
+ import { Task } from '../../models/Task';
24
+ import { Ticket } from '../../models/Ticket';
25
+ import { StorageHelper } from '../../utils/StorageHelper';
26
+ import { FeeddoInternal } from '../../FeeddoClient';
27
+
28
+ interface FeeddoHomeScreenProps {
29
+ theme: FeeddoTheme;
30
+ isActive?: boolean;
31
+ onClose?: () => void;
32
+ onNavigateToMessages: () => void;
33
+ onNavigateToTickets: () => void;
34
+ onNavigateToTasks: () => void;
35
+ onNavigateToChat: (conversation?: Conversation | null) => void;
36
+ }
37
+
38
+ export const FeeddoHomeScreen: React.FC<FeeddoHomeScreenProps> = ({
39
+ theme,
40
+ isActive = true,
41
+ onClose,
42
+ onNavigateToMessages,
43
+ onNavigateToTickets,
44
+ onNavigateToTasks,
45
+ onNavigateToChat,
46
+ }) => {
47
+ const [homeData, setHomeData] = useState<HomeData | null>(null);
48
+ const [showNotificationsSheet, setShowNotificationsSheet] = useState(false);
49
+ const [selectedTask, setSelectedTask] = useState<Task | null>(null);
50
+ const [selectedTicket, setSelectedTicket] = useState<Ticket | null>(null);
51
+ const [showUsernameModal, setShowUsernameModal] = useState(false);
52
+ const [userNameInput, setUserNameInput] = useState('');
53
+ const [, setRerender] = useState({});
54
+ const wasActive = useRef(isActive);
55
+
56
+ useEffect(() => {
57
+ checkUsernamePrompt();
58
+ loadHomeData();
59
+
60
+ const unsubscribeConv = FeeddoInternal.instance.conversationService.addListener(() => {
61
+ setRerender({});
62
+ });
63
+
64
+ const unsubscribeNotif = FeeddoInternal.instance.subscribeNotifications(() => {
65
+ loadHomeData();
66
+ });
67
+
68
+ return () => {
69
+ unsubscribeConv();
70
+ unsubscribeNotif();
71
+ };
72
+ }, []);
73
+
74
+ useEffect(() => {
75
+ if (isActive && !wasActive.current) {
76
+ loadHomeData();
77
+ }
78
+ wasActive.current = isActive;
79
+ }, [isActive]);
80
+
81
+ const checkUsernamePrompt = async () => {
82
+ const name = await StorageHelper.getUserName();
83
+ if (!name || name.trim().length === 0) {
84
+ setShowUsernameModal(true);
85
+ }
86
+ };
87
+
88
+ const loadHomeData = async () => {
89
+ try {
90
+ const data = await FeeddoInternal.instance.getHomeData();
91
+ if (data.recentConversation) {
92
+ FeeddoInternal.instance.conversationService.updateConversation(data.recentConversation);
93
+ }
94
+ setHomeData(data);
95
+ } catch (e) {
96
+ console.warn('Feeddo: Failed to load home data:', e);
97
+ }
98
+ };
99
+
100
+ const handleSaveUsername = async () => {
101
+ const trimmed = userNameInput.trim();
102
+ if (trimmed.length === 0) return;
103
+ setShowUsernameModal(false);
104
+ try {
105
+ await FeeddoInternal.instance.updateUser({ userName: trimmed });
106
+ } catch (e) {
107
+ console.warn('Feeddo: Failed to save username:', e);
108
+ }
109
+ };
110
+
111
+ const handleOpenConversationById = async (convId: string) => {
112
+ try {
113
+ const cached = FeeddoInternal.instance.conversationService.conversations.find(
114
+ (c) => c.id === convId
115
+ );
116
+ const conv =
117
+ cached ?? (await FeeddoInternal.instance.apiService.getConversation(convId));
118
+ onNavigateToChat(conv);
119
+ } catch (e: any) {
120
+ Alert.alert('Error', `Failed to open conversation: ${e?.message || e}`);
121
+ }
122
+ };
123
+
124
+ const formatTimeAgo = (timestamp: number): string => {
125
+ const diff = Math.floor((Date.now() - timestamp) / 1000);
126
+ if (diff < 60) return 'Just now';
127
+ if (diff < 3600) {
128
+ const mins = Math.floor(diff / 60);
129
+ return `${mins} ${mins === 1 ? 'minute' : 'minutes'} ago`;
130
+ }
131
+ if (diff < 86400) {
132
+ const hrs = Math.floor(diff / 3600);
133
+ return `${hrs} ${hrs === 1 ? 'hour' : 'hours'} ago`;
134
+ }
135
+ if (diff < 7 * 86400) {
136
+ const days = Math.floor(diff / 86400);
137
+ return `${days} ${days === 1 ? 'day' : 'days'} ago`;
138
+ }
139
+ const weeks = Math.floor(diff / (7 * 86400));
140
+ return `${weeks} ${weeks === 1 ? 'week' : 'weeks'} ago`;
141
+ };
142
+
143
+ // Find active conversation to display
144
+ const activeServiceConv = FeeddoInternal.instance.conversationService.conversations.find(
145
+ (c) => c.status !== 'resolved'
146
+ );
147
+
148
+ let displayConversation = activeServiceConv;
149
+ if (!displayConversation && homeData?.recentConversation) {
150
+ if (homeData.recentConversation.status !== 'resolved') {
151
+ displayConversation = homeData.recentConversation;
152
+ }
153
+ }
154
+
155
+ const hasRecentActivity = Boolean(
156
+ homeData?.recentTask || homeData?.recentTicket || displayConversation
157
+ );
158
+
159
+ const onPrimaryColor = theme.isDark ? '#000000' : '#FFFFFF';
160
+ const unreadMsgCount = FeeddoInternal.instance.conversationService.unreadMessageCount;
161
+
162
+ return (
163
+ <SafeAreaView style={[styles.container, { backgroundColor: theme.colors.background }]}>
164
+ <View style={styles.bodyWrapper}>
165
+ <ScrollView
166
+ style={styles.scrollArea}
167
+ contentContainerStyle={styles.scrollContent}
168
+ showsVerticalScrollIndicator={false}
169
+ >
170
+ {/* Greetings Section */}
171
+ <View style={styles.greetingSection}>
172
+ <Text style={[styles.greetingTitle, { color: theme.colors.textPrimary }]}>
173
+ Hi there 👋
174
+ </Text>
175
+ <Text style={[styles.greetingSubtitle, { color: theme.colors.textSecondary }]}>
176
+ How can we help you today?
177
+ </Text>
178
+ </View>
179
+
180
+ {/* Primary Action Card (When no recent activity) */}
181
+ {!hasRecentActivity && (
182
+ <TouchableOpacity
183
+ activeOpacity={0.85}
184
+ onPress={() => onNavigateToChat(null)}
185
+ style={[
186
+ styles.primaryActionCard,
187
+ { backgroundColor: theme.colors.primary },
188
+ ]}
189
+ >
190
+ <View
191
+ style={[
192
+ styles.primaryIconBox,
193
+ { backgroundColor: `${onPrimaryColor}26` },
194
+ ]}
195
+ >
196
+ <FeeddoIcon name="send" size={20} color={onPrimaryColor} />
197
+ </View>
198
+
199
+ <View style={styles.primaryTextContainer}>
200
+ <Text style={[styles.primaryTitle, { color: onPrimaryColor }]}>
201
+ Send us a message
202
+ </Text>
203
+ <Text style={[styles.primarySubtitle, { color: `${onPrimaryColor}CC` }]}>
204
+ We're here to help
205
+ </Text>
206
+ </View>
207
+
208
+ <FeeddoIcon name="arrow_forward" size={20} color={onPrimaryColor} />
209
+ </TouchableOpacity>
210
+ )}
211
+
212
+ {/* Quick Actions Section */}
213
+ <Text style={[styles.sectionHeading, { color: theme.colors.textPrimary }]}>
214
+ Quick Actions
215
+ </Text>
216
+
217
+ {/* Messages Card */}
218
+ <TouchableOpacity
219
+ activeOpacity={0.85}
220
+ onPress={onNavigateToMessages}
221
+ style={[
222
+ styles.menuCard,
223
+ {
224
+ backgroundColor: theme.colors.cardBackground,
225
+ borderColor: `${theme.colors.divider}4D`,
226
+ },
227
+ ]}
228
+ >
229
+ <View style={[styles.menuIconContainer, { backgroundColor: 'rgba(59, 130, 246, 0.12)' }]}>
230
+ <FeeddoIcon name="chat" size={20} color="#3B82F6" />
231
+ </View>
232
+
233
+ <View style={styles.menuTextContainer}>
234
+ <View style={styles.menuTitleRow}>
235
+ <Text style={[styles.menuTitle, { color: theme.colors.cardText }]}>
236
+ Messages
237
+ </Text>
238
+ {unreadMsgCount > 0 && (
239
+ <View style={styles.countBadge}>
240
+ <Text style={styles.countBadgeText}>
241
+ {unreadMsgCount > 99 ? '99+' : unreadMsgCount}
242
+ </Text>
243
+ </View>
244
+ )}
245
+ </View>
246
+ <Text style={[styles.menuSubtitle, { color: theme.colors.textSecondary }]}>
247
+ View your conversations
248
+ </Text>
249
+ </View>
250
+
251
+ <FeeddoIcon
252
+ name="chevron_right"
253
+ size={22}
254
+ color={`${theme.colors.textSecondary}4D`}
255
+ />
256
+ </TouchableOpacity>
257
+
258
+ {/* Community Board Card */}
259
+ <TouchableOpacity
260
+ activeOpacity={0.85}
261
+ onPress={onNavigateToTasks}
262
+ style={[
263
+ styles.menuCard,
264
+ {
265
+ backgroundColor: theme.colors.cardBackground,
266
+ borderColor: `${theme.colors.divider}4D`,
267
+ },
268
+ ]}
269
+ >
270
+ <View style={[styles.menuIconContainer, { backgroundColor: 'rgba(245, 158, 11, 0.12)' }]}>
271
+ <FeeddoIcon name="lightbulb" size={20} color="#F59E0B" />
272
+ </View>
273
+
274
+ <View style={styles.menuTextContainer}>
275
+ <Text style={[styles.menuTitle, { color: theme.colors.cardText }]}>
276
+ Community Board
277
+ </Text>
278
+ <Text style={[styles.menuSubtitle, { color: theme.colors.textSecondary }]}>
279
+ Suggest features or report bugs
280
+ </Text>
281
+ </View>
282
+
283
+ <FeeddoIcon
284
+ name="chevron_right"
285
+ size={22}
286
+ color={`${theme.colors.textSecondary}4D`}
287
+ />
288
+ </TouchableOpacity>
289
+
290
+ {/* Tickets Card */}
291
+ <TouchableOpacity
292
+ activeOpacity={0.85}
293
+ onPress={onNavigateToTickets}
294
+ style={[
295
+ styles.menuCard,
296
+ {
297
+ backgroundColor: theme.colors.cardBackground,
298
+ borderColor: `${theme.colors.divider}4D`,
299
+ },
300
+ ]}
301
+ >
302
+ <View style={[styles.menuIconContainer, { backgroundColor: 'rgba(168, 85, 247, 0.12)' }]}>
303
+ <FeeddoIcon name="ticket" size={20} color="#A855F7" />
304
+ </View>
305
+
306
+ <View style={styles.menuTextContainer}>
307
+ <Text style={[styles.menuTitle, { color: theme.colors.cardText }]}>
308
+ Tickets
309
+ </Text>
310
+ <Text style={[styles.menuSubtitle, { color: theme.colors.textSecondary }]}>
311
+ Track your support tickets
312
+ </Text>
313
+ </View>
314
+
315
+ <FeeddoIcon
316
+ name="chevron_right"
317
+ size={22}
318
+ color={`${theme.colors.textSecondary}4D`}
319
+ />
320
+ </TouchableOpacity>
321
+
322
+ {/* Recent Activity Section */}
323
+ {hasRecentActivity && (
324
+ <View style={styles.recentActivitySection}>
325
+ <Text style={[styles.sectionHeading, { color: theme.colors.textPrimary }]}>
326
+ Recent Activity
327
+ </Text>
328
+
329
+ {/* Recent Conversation */}
330
+ {Boolean(displayConversation) && (
331
+ <TouchableOpacity
332
+ activeOpacity={0.85}
333
+ onPress={() => onNavigateToChat(displayConversation)}
334
+ style={[
335
+ styles.recentConversationCard,
336
+ {
337
+ backgroundColor: theme.colors.cardBackground,
338
+ borderColor: `${theme.colors.divider}4D`,
339
+ },
340
+ ]}
341
+ >
342
+ <View style={styles.recentConvTop}>
343
+ <View style={[styles.menuIconContainer, { backgroundColor: 'rgba(59, 130, 246, 0.12)' }]}>
344
+ <FeeddoIcon name="chat" size={20} color="#3B82F6" />
345
+ </View>
346
+
347
+ <View style={styles.recentConvTitleContainer}>
348
+ <View style={styles.recentConvTitleRow}>
349
+ <Text
350
+ style={[styles.recentConvTitle, { color: theme.colors.cardText }]}
351
+ numberOfLines={1}
352
+ >
353
+ {displayConversation!.displayName ||
354
+ displayConversation!.title ||
355
+ 'Conversation'}
356
+ </Text>
357
+ {displayConversation!.unreadMessages > 0 && (
358
+ <View style={styles.countBadge}>
359
+ <Text style={styles.countBadgeText}>
360
+ {displayConversation!.unreadMessages > 99
361
+ ? '99+'
362
+ : displayConversation!.unreadMessages}
363
+ </Text>
364
+ </View>
365
+ )}
366
+ </View>
367
+ <Text style={[styles.recentConvTime, { color: theme.colors.textSecondary }]}>
368
+ {formatTimeAgo(displayConversation!.lastMessageAt)}
369
+ </Text>
370
+ </View>
371
+
372
+ <FeeddoIcon
373
+ name="chevron_right"
374
+ size={22}
375
+ color={`${theme.colors.textSecondary}4D`}
376
+ />
377
+ </View>
378
+
379
+ {Boolean(displayConversation!.lastMessagePreview) && (
380
+ <Text
381
+ style={[styles.recentConvPreview, { color: theme.colors.textSecondary }]}
382
+ numberOfLines={2}
383
+ >
384
+ {displayConversation!.lastMessagePreview}
385
+ </Text>
386
+ )}
387
+ </TouchableOpacity>
388
+ )}
389
+
390
+ {/* Recent Ticket */}
391
+ {Boolean(homeData?.recentTicket) && (
392
+ <View style={{ marginBottom: 14 }}>
393
+ <TicketCard
394
+ ticket={homeData!.recentTicket!}
395
+ theme={theme}
396
+ onTap={() => setSelectedTicket(homeData!.recentTicket!)}
397
+ />
398
+ </View>
399
+ )}
400
+
401
+ {/* Recent Task */}
402
+ {Boolean(homeData?.recentTask) && (
403
+ <View style={{ marginBottom: 14 }}>
404
+ <TaskCard
405
+ task={homeData!.recentTask!}
406
+ theme={theme}
407
+ onTap={() => setSelectedTask(homeData!.recentTask!)}
408
+ />
409
+ </View>
410
+ )}
411
+ </View>
412
+ )}
413
+
414
+ {/* Footer */}
415
+ <View style={styles.footerContainer}>
416
+ <Text style={[styles.footerText, { color: `${theme.colors.textSecondary}66` }]}>
417
+ Powered by{' '}
418
+ <Text style={{ fontWeight: '600', color: `${theme.colors.textSecondary}99` }}>
419
+ {FeeddoInternal.instance.chatBotName}
420
+ </Text>
421
+ </Text>
422
+ </View>
423
+ </ScrollView>
424
+
425
+ {/* Top-Right Floating Controls (matching Flutter Positioned buttons) */}
426
+ <View style={styles.floatingControls}>
427
+ <View style={styles.notifButtonWrapper}>
428
+ <TouchableOpacity
429
+ activeOpacity={0.8}
430
+ onPress={() => setShowNotificationsSheet(true)}
431
+ style={[
432
+ styles.iconCardButton,
433
+ {
434
+ backgroundColor: theme.colors.cardBackground,
435
+ borderColor: `${theme.colors.divider}33`,
436
+ },
437
+ ]}
438
+ >
439
+ <FeeddoIcon name="notifications" size={20} color={theme.colors.textPrimary} />
440
+ </TouchableOpacity>
441
+ {homeData && homeData.unreadNotificationCount > 0 && (
442
+ <View style={styles.notifBadge} pointerEvents="none">
443
+ <Text style={styles.notifBadgeText}>
444
+ {homeData.unreadNotificationCount > 99
445
+ ? '99+'
446
+ : homeData.unreadNotificationCount}
447
+ </Text>
448
+ </View>
449
+ )}
450
+ </View>
451
+
452
+ <TouchableOpacity
453
+ activeOpacity={0.8}
454
+ onPress={onClose}
455
+ style={[
456
+ styles.iconCardButton,
457
+ {
458
+ backgroundColor: theme.colors.cardBackground,
459
+ borderColor: `${theme.colors.divider}33`,
460
+ marginLeft: 14,
461
+ },
462
+ ]}
463
+ >
464
+ <FeeddoIcon name="close" size={20} color={theme.colors.closeButtonColor} />
465
+ </TouchableOpacity>
466
+ </View>
467
+
468
+ {/* Floating Action Button (when recent activity exists) */}
469
+ {hasRecentActivity && (
470
+ <TouchableOpacity
471
+ activeOpacity={0.85}
472
+ onPress={() => onNavigateToChat(null)}
473
+ style={[
474
+ styles.fab,
475
+ {
476
+ backgroundColor: theme.colors.primary,
477
+ shadowColor: theme.colors.primary,
478
+ },
479
+ ]}
480
+ >
481
+ <FeeddoIcon name="edit" size={22} color={onPrimaryColor} />
482
+ </TouchableOpacity>
483
+ )}
484
+ </View>
485
+
486
+ {/* Sheets / Modals */}
487
+ <NotificationsSheet
488
+ visible={showNotificationsSheet}
489
+ onClose={() => {
490
+ setShowNotificationsSheet(false);
491
+ loadHomeData();
492
+ }}
493
+ theme={theme}
494
+ />
495
+
496
+ <TaskDetailsSheet
497
+ visible={Boolean(selectedTask)}
498
+ task={selectedTask ?? undefined}
499
+ onClose={() => setSelectedTask(null)}
500
+ onOpenConversation={(convId) => {
501
+ setSelectedTask(null);
502
+ handleOpenConversationById(convId);
503
+ }}
504
+ onTaskUpdated={() => {
505
+ loadHomeData();
506
+ }}
507
+ theme={theme}
508
+ />
509
+
510
+ <TicketDetailsSheet
511
+ visible={Boolean(selectedTicket)}
512
+ ticket={selectedTicket ?? undefined}
513
+ onClose={() => setSelectedTicket(null)}
514
+ onOpenConversation={(convId) => {
515
+ setSelectedTicket(null);
516
+ handleOpenConversationById(convId);
517
+ }}
518
+ theme={theme}
519
+ />
520
+
521
+ {/* Username Modal */}
522
+ <Modal visible={showUsernameModal} transparent animationType="fade">
523
+ <View style={styles.modalBackdrop}>
524
+ <View style={[styles.modalContent, { backgroundColor: theme.colors.surface }]}>
525
+ <Text style={[styles.modalTitle, { color: theme.colors.textPrimary }]}>
526
+ Welcome!
527
+ </Text>
528
+ <Text style={[styles.modalSubtitle, { color: theme.colors.textSecondary }]}>
529
+ Please enter your name to get started
530
+ </Text>
531
+
532
+ <TextInput
533
+ value={userNameInput}
534
+ onChangeText={setUserNameInput}
535
+ placeholder="Your name"
536
+ placeholderTextColor={theme.colors.textSecondary}
537
+ style={[
538
+ styles.modalInput,
539
+ {
540
+ backgroundColor: theme.colors.background,
541
+ borderColor: theme.colors.border,
542
+ color: theme.colors.textPrimary,
543
+ },
544
+ ]}
545
+ autoFocus
546
+ onSubmitEditing={handleSaveUsername}
547
+ />
548
+
549
+ <TouchableOpacity
550
+ activeOpacity={0.8}
551
+ onPress={handleSaveUsername}
552
+ style={[styles.modalButton, { backgroundColor: theme.colors.primary }]}
553
+ >
554
+ <Text style={[styles.modalButtonText, { color: onPrimaryColor }]}>
555
+ Continue
556
+ </Text>
557
+ </TouchableOpacity>
558
+ </View>
559
+ </View>
560
+ </Modal>
561
+ </SafeAreaView>
562
+ );
563
+ };
564
+
565
+ const styles = StyleSheet.create({
566
+ container: {
567
+ flex: 1,
568
+ },
569
+ bodyWrapper: {
570
+ flex: 1,
571
+ position: 'relative',
572
+ },
573
+ floatingControls: {
574
+ position: 'absolute',
575
+ top: Platform.OS === 'android' ? 14 : 12,
576
+ right: 12,
577
+ flexDirection: 'row',
578
+ alignItems: 'center',
579
+ zIndex: 10,
580
+ },
581
+ notifButtonWrapper: {
582
+ position: 'relative',
583
+ },
584
+ iconCardButton: {
585
+ width: 44,
586
+ height: 44,
587
+ borderRadius: 12,
588
+ borderWidth: 1,
589
+ alignItems: 'center',
590
+ justifyContent: 'center',
591
+ shadowColor: '#000',
592
+ shadowOffset: { width: 0, height: 2 },
593
+ shadowOpacity: 0.08,
594
+ shadowRadius: 8,
595
+ elevation: 2,
596
+ },
597
+ notifBadge: {
598
+ position: 'absolute',
599
+ top: 2,
600
+ right: 2,
601
+ backgroundColor: '#EF4444',
602
+ borderRadius: 9,
603
+ minWidth: 18,
604
+ height: 18,
605
+ alignItems: 'center',
606
+ justifyContent: 'center',
607
+ paddingHorizontal: 4,
608
+ },
609
+ notifBadgeText: {
610
+ color: '#FFFFFF',
611
+ fontSize: 10,
612
+ fontWeight: '700',
613
+ },
614
+ scrollArea: {
615
+ flex: 1,
616
+ },
617
+ scrollContent: {
618
+ paddingHorizontal: 20,
619
+ paddingTop: Platform.OS === 'android' ? 14 : 8,
620
+ paddingBottom: 80,
621
+ },
622
+ greetingSection: {
623
+ marginTop: 32,
624
+ marginBottom: 36,
625
+ },
626
+ greetingTitle: {
627
+ fontSize: 32,
628
+ fontWeight: '800',
629
+ letterSpacing: -1.0,
630
+ },
631
+ greetingSubtitle: {
632
+ fontSize: 17,
633
+ marginTop: 12,
634
+ letterSpacing: -0.2,
635
+ },
636
+ primaryActionCard: {
637
+ flexDirection: 'row',
638
+ alignItems: 'center',
639
+ padding: 20,
640
+ borderRadius: 16,
641
+ marginBottom: 32,
642
+ },
643
+ primaryIconBox: {
644
+ width: 48,
645
+ height: 48,
646
+ borderRadius: 12,
647
+ alignItems: 'center',
648
+ justifyContent: 'center',
649
+ },
650
+ primaryTextContainer: {
651
+ flex: 1,
652
+ marginLeft: 16,
653
+ },
654
+ primaryTitle: {
655
+ fontSize: 17,
656
+ fontWeight: '700',
657
+ letterSpacing: -0.3,
658
+ },
659
+ primarySubtitle: {
660
+ fontSize: 14,
661
+ marginTop: 2,
662
+ letterSpacing: -0.1,
663
+ },
664
+ sectionHeading: {
665
+ fontSize: 20,
666
+ fontWeight: '700',
667
+ letterSpacing: -0.5,
668
+ marginBottom: 20,
669
+ },
670
+ menuCard: {
671
+ flexDirection: 'row',
672
+ alignItems: 'center',
673
+ padding: 18,
674
+ borderRadius: 16,
675
+ borderWidth: 1,
676
+ marginBottom: 14,
677
+ shadowColor: '#000',
678
+ shadowOffset: { width: 0, height: 4 },
679
+ shadowOpacity: 0.06,
680
+ shadowRadius: 12,
681
+ elevation: 2,
682
+ },
683
+ menuIconContainer: {
684
+ width: 42,
685
+ height: 42,
686
+ borderRadius: 12,
687
+ alignItems: 'center',
688
+ justifyContent: 'center',
689
+ },
690
+ menuTextContainer: {
691
+ flex: 1,
692
+ marginLeft: 16,
693
+ },
694
+ menuTitleRow: {
695
+ flexDirection: 'row',
696
+ alignItems: 'center',
697
+ },
698
+ menuTitle: {
699
+ fontSize: 16,
700
+ fontWeight: '700',
701
+ letterSpacing: -0.3,
702
+ },
703
+ menuSubtitle: {
704
+ fontSize: 14,
705
+ marginTop: 4,
706
+ letterSpacing: -0.1,
707
+ },
708
+ countBadge: {
709
+ backgroundColor: '#EF4444',
710
+ borderRadius: 10,
711
+ paddingHorizontal: 8,
712
+ paddingVertical: 3,
713
+ marginLeft: 8,
714
+ },
715
+ countBadgeText: {
716
+ color: '#FFFFFF',
717
+ fontSize: 11,
718
+ fontWeight: '700',
719
+ },
720
+ recentActivitySection: {
721
+ marginTop: 22,
722
+ },
723
+ recentConversationCard: {
724
+ padding: 18,
725
+ borderRadius: 16,
726
+ borderWidth: 1,
727
+ marginBottom: 14,
728
+ shadowColor: '#000',
729
+ shadowOffset: { width: 0, height: 4 },
730
+ shadowOpacity: 0.06,
731
+ shadowRadius: 12,
732
+ elevation: 2,
733
+ },
734
+ recentConvTop: {
735
+ flexDirection: 'row',
736
+ alignItems: 'center',
737
+ },
738
+ recentConvTitleContainer: {
739
+ flex: 1,
740
+ marginLeft: 14,
741
+ },
742
+ recentConvTitleRow: {
743
+ flexDirection: 'row',
744
+ alignItems: 'center',
745
+ },
746
+ recentConvTitle: {
747
+ fontSize: 16,
748
+ fontWeight: '700',
749
+ letterSpacing: -0.3,
750
+ flexShrink: 1,
751
+ },
752
+ recentConvTime: {
753
+ fontSize: 13,
754
+ marginTop: 4,
755
+ },
756
+ recentConvPreview: {
757
+ fontSize: 14,
758
+ marginTop: 14,
759
+ lineHeight: 20,
760
+ letterSpacing: -0.1,
761
+ },
762
+ footerContainer: {
763
+ alignItems: 'center',
764
+ marginTop: 48,
765
+ marginBottom: 24,
766
+ },
767
+ footerText: {
768
+ fontSize: 13,
769
+ letterSpacing: -0.1,
770
+ },
771
+ fab: {
772
+ position: 'absolute',
773
+ right: 20,
774
+ bottom: 24,
775
+ width: 56,
776
+ height: 56,
777
+ borderRadius: 16,
778
+ alignItems: 'center',
779
+ justifyContent: 'center',
780
+ shadowOffset: { width: 0, height: 6 },
781
+ shadowOpacity: 0.3,
782
+ shadowRadius: 16,
783
+ elevation: 6,
784
+ },
785
+ modalBackdrop: {
786
+ flex: 1,
787
+ backgroundColor: 'rgba(0,0,0,0.6)',
788
+ alignItems: 'center',
789
+ justifyContent: 'center',
790
+ padding: 24,
791
+ },
792
+ modalContent: {
793
+ width: '100%',
794
+ maxWidth: 360,
795
+ borderRadius: 16,
796
+ padding: 24,
797
+ },
798
+ modalTitle: {
799
+ fontSize: 20,
800
+ fontWeight: '800',
801
+ },
802
+ modalSubtitle: {
803
+ fontSize: 14,
804
+ marginTop: 6,
805
+ marginBottom: 18,
806
+ },
807
+ modalInput: {
808
+ borderWidth: 1,
809
+ borderRadius: 10,
810
+ paddingHorizontal: 14,
811
+ paddingVertical: 10,
812
+ fontSize: 15,
813
+ },
814
+ modalButton: {
815
+ borderRadius: 10,
816
+ paddingVertical: 12,
817
+ alignItems: 'center',
818
+ marginTop: 18,
819
+ },
820
+ modalButtonText: {
821
+ fontSize: 15,
822
+ fontWeight: '700',
823
+ },
824
+ });