feeddo-react-native 0.0.0-stage → 0.1.1

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 +180 -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 +309 -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,747 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ TouchableOpacity,
7
+ ScrollView,
8
+ ActivityIndicator,
9
+ Modal,
10
+ SafeAreaView,
11
+ KeyboardAvoidingView,
12
+ Platform,
13
+ Alert,
14
+ } from 'react-native';
15
+ import { Task } from '../../models/Task';
16
+ import { FeeddoTheme } from '../../theme/FeeddoTheme';
17
+ import { FeeddoIcon } from './FeeddoIcon';
18
+ import { ChatInputArea } from './ChatInputArea';
19
+ import { AttachmentPreview } from './AttachmentPreview';
20
+ import { FeeddoInternal } from '../../FeeddoClient';
21
+ import { MediaHelper } from '../../utils/MediaHelper';
22
+
23
+ interface TaskDetailsSheetProps {
24
+ visible: boolean;
25
+ taskId?: string;
26
+ task?: Task;
27
+ onClose: () => void;
28
+ onOpenConversation?: (conversationId: string) => void;
29
+ onTaskUpdated?: (updatedTask: Task) => void;
30
+ theme: FeeddoTheme;
31
+ }
32
+
33
+ export const TaskDetailsSheet: React.FC<TaskDetailsSheetProps> = ({
34
+ visible,
35
+ taskId,
36
+ task: initialTask,
37
+ onClose,
38
+ onOpenConversation,
39
+ onTaskUpdated,
40
+ theme,
41
+ }) => {
42
+ const [task, setTask] = useState<Task | null>(initialTask ?? null);
43
+ const [isLoading, setIsLoading] = useState<boolean>(!initialTask);
44
+ const [error, setError] = useState<string | null>(null);
45
+ const [commentText, setCommentText] = useState<string>('');
46
+ const [attachments, setAttachments] = useState<Array<Record<string, any>>>([]);
47
+ const [isSubmittingComment, setIsSubmittingComment] = useState<boolean>(false);
48
+ const [isUploadingMedia, setIsUploadingMedia] = useState<boolean>(false);
49
+ const [isVoting, setIsVoting] = useState<boolean>(false);
50
+ const [toastMessage, setToastMessage] = useState<string | null>(null);
51
+ const toastTimerRef = useRef<any>(null);
52
+
53
+ useEffect(() => {
54
+ if (!visible) {
55
+ return;
56
+ }
57
+
58
+ setError(null);
59
+ setAttachments([]);
60
+ setCommentText('');
61
+
62
+ if (initialTask) {
63
+ setTask(initialTask);
64
+ setIsLoading(false);
65
+ } else {
66
+ setTask(null);
67
+ setIsLoading(true);
68
+ }
69
+
70
+ const targetId = taskId || initialTask?.id;
71
+ if (targetId) {
72
+ loadTask(targetId, !initialTask);
73
+ }
74
+ }, [visible, taskId, initialTask?.id]);
75
+
76
+ useEffect(() => {
77
+ return () => {
78
+ if (toastTimerRef.current) clearTimeout(toastTimerRef.current);
79
+ };
80
+ }, []);
81
+
82
+ const showToast = (msg: string) => {
83
+ if (toastTimerRef.current) clearTimeout(toastTimerRef.current);
84
+ setToastMessage(msg);
85
+ toastTimerRef.current = setTimeout(() => setToastMessage(null), 2500);
86
+ };
87
+
88
+ const loadTask = async (targetId?: string, showSpinnerIfEmpty: boolean = false) => {
89
+ const id = targetId || taskId || initialTask?.id || task?.id;
90
+ if (!id) return;
91
+
92
+ try {
93
+ if (showSpinnerIfEmpty) {
94
+ setIsLoading(true);
95
+ }
96
+ setError(null);
97
+ await FeeddoInternal.instance.ensureUserInitialized();
98
+ const loaded = await FeeddoInternal.instance.apiService.getTask(
99
+ id,
100
+ FeeddoInternal.instance.userId ?? undefined
101
+ );
102
+ setTask(loaded);
103
+ onTaskUpdated?.(loaded);
104
+ } catch (e: any) {
105
+ setError(e?.message || 'Failed to load task');
106
+ } finally {
107
+ setIsLoading(false);
108
+ }
109
+ };
110
+
111
+ const handleVote = async (voteType: 'up' | 'down') => {
112
+ if (!task || isVoting) return;
113
+ setIsVoting(true);
114
+
115
+ const oldTask = task;
116
+ const oldMyVote = oldTask.myVote;
117
+ let newUpvoteCount = oldTask.upvoteCount;
118
+ let newMyVote: 'up' | 'down' | null = voteType;
119
+
120
+ if (oldMyVote === voteType) {
121
+ newMyVote = null;
122
+ if (oldMyVote === 'up') newUpvoteCount -= 1;
123
+ else if (oldMyVote === 'down') newUpvoteCount += 1;
124
+ } else {
125
+ if (voteType === 'up') {
126
+ newUpvoteCount += oldMyVote === 'down' ? 2 : 1;
127
+ } else {
128
+ newUpvoteCount -= oldMyVote === 'up' ? 2 : 1;
129
+ }
130
+ }
131
+
132
+ const optimistic: Task = {
133
+ ...oldTask,
134
+ upvoteCount: newUpvoteCount,
135
+ myVote: newMyVote,
136
+ };
137
+
138
+ setTask(optimistic);
139
+ onTaskUpdated?.(optimistic);
140
+
141
+ try {
142
+ const res = await FeeddoInternal.instance.voteTask(task.id, newMyVote ?? 'none');
143
+ if (res.upvoteCount !== undefined) {
144
+ const finalTask: Task = {
145
+ ...optimistic,
146
+ upvoteCount: res.upvoteCount,
147
+ };
148
+ setTask(finalTask);
149
+ onTaskUpdated?.(finalTask);
150
+ }
151
+ } catch (e: any) {
152
+ setTask(oldTask);
153
+ onTaskUpdated?.(oldTask);
154
+ Alert.alert('Error', `Failed to vote: ${e?.message || e}`);
155
+ } finally {
156
+ setIsVoting(false);
157
+ }
158
+ };
159
+
160
+ const handlePickAndUploadMedia = async () => {
161
+ try {
162
+ const file = await MediaHelper.pickImage();
163
+ if (!file) return;
164
+
165
+ const userId = await FeeddoInternal.instance.ensureUserInitialized();
166
+ if (!userId) {
167
+ Alert.alert('Error', 'User not identified');
168
+ return;
169
+ }
170
+
171
+ setIsUploadingMedia(true);
172
+ const media = await FeeddoInternal.instance.apiService.uploadMedia(file, userId);
173
+ setAttachments((prev) => [...prev, media]);
174
+ } catch (e: any) {
175
+ Alert.alert('Error', `Failed to upload media: ${e?.message || e}`);
176
+ } finally {
177
+ setIsUploadingMedia(false);
178
+ }
179
+ };
180
+
181
+ const handleSubmitComment = async () => {
182
+ if (!task) return;
183
+ if (commentText.trim().length === 0 && attachments.length === 0) return;
184
+
185
+ setIsSubmittingComment(true);
186
+ try {
187
+ await FeeddoInternal.instance.addTaskComment(task.id, commentText.trim(), {
188
+ attachments: attachments.length > 0 ? attachments : undefined,
189
+ });
190
+ setCommentText('');
191
+ setAttachments([]);
192
+ await loadTask(task.id, false);
193
+ showToast('Comment added!');
194
+ } catch (e: any) {
195
+ Alert.alert('Error', `Failed to add comment: ${e?.message || e}`);
196
+ } finally {
197
+ setIsSubmittingComment(false);
198
+ }
199
+ };
200
+
201
+ const formatDate = (timestamp: number): string => {
202
+ const d = new Date(timestamp);
203
+ return `${d.getDate()}/${d.getMonth() + 1}/${d.getFullYear()}`;
204
+ };
205
+
206
+ const isBug = task?.type === 'bug';
207
+ const apiKey = FeeddoInternal.isInitialized ? FeeddoInternal.instance.apiService.apiKey : undefined;
208
+
209
+ return (
210
+ <Modal
211
+ visible={visible}
212
+ transparent
213
+ animationType="slide"
214
+ onRequestClose={onClose}
215
+ >
216
+ <KeyboardAvoidingView
217
+ style={styles.backdrop}
218
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
219
+ >
220
+ <TouchableOpacity activeOpacity={1} onPress={onClose} style={styles.backdropTouch} />
221
+
222
+ <SafeAreaView
223
+ style={[
224
+ styles.sheetContainer,
225
+ { backgroundColor: theme.colors.surface },
226
+ ]}
227
+ >
228
+ {/* Drag Handle */}
229
+ <View style={styles.handleContainer}>
230
+ <View style={[styles.handleBar, { backgroundColor: theme.colors.divider }]} />
231
+ </View>
232
+
233
+ {toastMessage && (
234
+ <View style={[styles.toastBanner, { backgroundColor: theme.colors.success }]}>
235
+ <Text style={styles.toastText}>{toastMessage}</Text>
236
+ </View>
237
+ )}
238
+
239
+ {isLoading ? (
240
+ <View style={styles.centerContainer}>
241
+ <ActivityIndicator size="large" color={theme.colors.primary} />
242
+ </View>
243
+ ) : error && !task ? (
244
+ <View style={styles.centerContainer}>
245
+ <Text style={[styles.errorText, { color: theme.colors.error }]}>
246
+ Failed to load task
247
+ </Text>
248
+ <TouchableOpacity
249
+ onPress={() => loadTask(taskId || initialTask?.id, true)}
250
+ style={styles.retryButton}
251
+ >
252
+ <Text style={[styles.retryText, { color: theme.colors.primary }]}>Retry</Text>
253
+ </TouchableOpacity>
254
+ </View>
255
+ ) : !task ? (
256
+ <View style={styles.centerContainer}>
257
+ <Text style={{ color: theme.colors.textPrimary }}>Task not found</Text>
258
+ </View>
259
+ ) : (
260
+ <>
261
+ <ScrollView
262
+ style={styles.scrollContent}
263
+ contentContainerStyle={styles.scrollInner}
264
+ keyboardShouldPersistTaps="handled"
265
+ >
266
+ {/* Type & Status Header */}
267
+ <View style={styles.headerRow}>
268
+ <View style={styles.typeRow}>
269
+ <FeeddoIcon
270
+ name={isBug ? 'bug' : 'lightbulb'}
271
+ size={20}
272
+ color={isBug ? '#EF4444' : '#F59E0B'}
273
+ />
274
+ <Text
275
+ style={[
276
+ styles.typeText,
277
+ { color: theme.colors.textSecondary },
278
+ ]}
279
+ >
280
+ {task.type.toUpperCase()}
281
+ </Text>
282
+ </View>
283
+
284
+ <View
285
+ style={[
286
+ styles.statusPill,
287
+ { backgroundColor: theme.colors.background },
288
+ ]}
289
+ >
290
+ <Text
291
+ style={[
292
+ styles.statusPillText,
293
+ { color: theme.colors.textPrimary },
294
+ ]}
295
+ >
296
+ {task.status.toUpperCase()}
297
+ </Text>
298
+ </View>
299
+ </View>
300
+
301
+ {/* Title */}
302
+ <Text style={[styles.title, { color: theme.colors.textPrimary }]}>
303
+ {task.title}
304
+ </Text>
305
+
306
+ {/* Description */}
307
+ <Text style={[styles.description, { color: theme.colors.textSecondary }]}>
308
+ {task.description}
309
+ </Text>
310
+
311
+ {/* Vote Buttons */}
312
+ <View style={styles.votesRow}>
313
+ <TouchableOpacity
314
+ activeOpacity={0.7}
315
+ onPress={() => handleVote('up')}
316
+ style={[
317
+ styles.voteButton,
318
+ {
319
+ backgroundColor:
320
+ task.myVote === 'up'
321
+ ? 'rgba(59, 130, 246, 0.12)'
322
+ : theme.colors.background,
323
+ borderColor:
324
+ task.myVote === 'up'
325
+ ? 'rgba(59, 130, 246, 0.3)'
326
+ : 'transparent',
327
+ },
328
+ ]}
329
+ >
330
+ <FeeddoIcon
331
+ name="arrow_up"
332
+ size={16}
333
+ color={task.myVote === 'up' ? '#3B82F6' : theme.colors.textSecondary}
334
+ />
335
+ <Text
336
+ style={[
337
+ styles.voteButtonText,
338
+ {
339
+ color:
340
+ task.myVote === 'up'
341
+ ? '#3B82F6'
342
+ : theme.colors.textSecondary,
343
+ },
344
+ ]}
345
+ >
346
+ {task.upvoteCount}
347
+ </Text>
348
+ </TouchableOpacity>
349
+
350
+ <TouchableOpacity
351
+ activeOpacity={0.7}
352
+ onPress={() => handleVote('down')}
353
+ style={[
354
+ styles.voteButton,
355
+ {
356
+ backgroundColor:
357
+ task.myVote === 'down'
358
+ ? 'rgba(239, 68, 68, 0.12)'
359
+ : theme.colors.background,
360
+ borderColor:
361
+ task.myVote === 'down'
362
+ ? 'rgba(239, 68, 68, 0.3)'
363
+ : 'transparent',
364
+ },
365
+ ]}
366
+ >
367
+ <FeeddoIcon
368
+ name="arrow_down"
369
+ size={16}
370
+ color={task.myVote === 'down' ? '#EF4444' : theme.colors.textSecondary}
371
+ />
372
+ </TouchableOpacity>
373
+ </View>
374
+
375
+ {/* View conversation button if owner */}
376
+ {task.isOwner && Boolean(task.conversationId) && (
377
+ <TouchableOpacity
378
+ activeOpacity={0.8}
379
+ onPress={() => {
380
+ onClose();
381
+ if (task.conversationId) {
382
+ onOpenConversation?.(task.conversationId);
383
+ }
384
+ }}
385
+ style={[
386
+ styles.viewConvButton,
387
+ { backgroundColor: theme.colors.primary },
388
+ ]}
389
+ >
390
+ <FeeddoIcon
391
+ name="chat"
392
+ size={18}
393
+ color={theme.isDark ? '#000000' : '#FFFFFF'}
394
+ />
395
+ <Text
396
+ style={[
397
+ styles.viewConvText,
398
+ { color: theme.isDark ? '#000000' : '#FFFFFF' },
399
+ ]}
400
+ >
401
+ View Conversation
402
+ </Text>
403
+ </TouchableOpacity>
404
+ )}
405
+
406
+ {/* Comments Header */}
407
+ <Text style={[styles.commentsSectionTitle, { color: theme.colors.textPrimary }]}>
408
+ Comments
409
+ </Text>
410
+
411
+ {/* Comments List */}
412
+ {task.comments.length === 0 ? (
413
+ <View style={styles.emptyComments}>
414
+ <Text style={{ color: theme.colors.textSecondary }}>
415
+ No comments yet
416
+ </Text>
417
+ </View>
418
+ ) : (
419
+ task.comments.map((comment) => {
420
+ const isDev = comment.userType === 'developer';
421
+ return (
422
+ <View
423
+ key={comment.id}
424
+ style={[
425
+ styles.commentCard,
426
+ {
427
+ backgroundColor: theme.colors.background,
428
+ borderColor: theme.colors.border,
429
+ },
430
+ ]}
431
+ >
432
+ <View style={styles.commentHeader}>
433
+ <View
434
+ style={[
435
+ styles.commentAvatar,
436
+ {
437
+ backgroundColor: isDev
438
+ ? 'rgba(168, 85, 247, 0.2)'
439
+ : 'rgba(59, 130, 246, 0.2)',
440
+ },
441
+ ]}
442
+ >
443
+ <FeeddoIcon
444
+ name={isDev ? 'code' : 'person'}
445
+ size={14}
446
+ color={isDev ? '#A855F7' : '#3B82F6'}
447
+ />
448
+ </View>
449
+ <Text
450
+ style={[
451
+ styles.commentAuthor,
452
+ { color: theme.colors.textPrimary },
453
+ ]}
454
+ >
455
+ {comment.authorName || (isDev ? 'Developer' : 'User')}
456
+ </Text>
457
+ <Text
458
+ style={[
459
+ styles.commentDate,
460
+ { color: theme.colors.textSecondary },
461
+ ]}
462
+ >
463
+ {formatDate(comment.createdAt)}
464
+ </Text>
465
+ </View>
466
+ {Boolean(comment.content) && (
467
+ <Text
468
+ style={[
469
+ styles.commentContent,
470
+ { color: theme.colors.textPrimary },
471
+ ]}
472
+ >
473
+ {comment.content}
474
+ </Text>
475
+ )}
476
+ {Boolean(comment.attachments) &&
477
+ comment.attachments!.map((att, i) => (
478
+ <AttachmentPreview
479
+ key={i}
480
+ url={att.url}
481
+ contentType={att.contentType ?? att.mimeType}
482
+ fileName={att.fileName}
483
+ apiKey={apiKey}
484
+ />
485
+ ))}
486
+ </View>
487
+ );
488
+ })
489
+ )}
490
+ </ScrollView>
491
+
492
+ {/* Staged attachment previews */}
493
+ {attachments.length > 0 && (
494
+ <View
495
+ style={[
496
+ styles.stagedAttachmentsRow,
497
+ {
498
+ backgroundColor: theme.colors.background,
499
+ borderTopColor: theme.colors.divider,
500
+ },
501
+ ]}
502
+ >
503
+ {attachments.map((att, idx) => (
504
+ <View key={idx} style={styles.stagedItem}>
505
+ <View
506
+ style={[
507
+ styles.stagedThumbBox,
508
+ { borderColor: theme.colors.border },
509
+ ]}
510
+ >
511
+ <AttachmentPreview
512
+ url={att.url}
513
+ contentType={att.contentType ?? att.mimeType}
514
+ fileName={att.fileName}
515
+ apiKey={apiKey}
516
+ />
517
+ </View>
518
+ <TouchableOpacity
519
+ style={[styles.removeAttachmentBtn, { backgroundColor: theme.colors.error }]}
520
+ onPress={() =>
521
+ setAttachments((prev) => prev.filter((_, i) => i !== idx))
522
+ }
523
+ >
524
+ <FeeddoIcon name="close" size={10} color="#FFFFFF" />
525
+ </TouchableOpacity>
526
+ </View>
527
+ ))}
528
+ </View>
529
+ )}
530
+
531
+ {/* Add Comment Input */}
532
+ <ChatInputArea
533
+ value={commentText}
534
+ onChangeText={setCommentText}
535
+ onSend={handleSubmitComment}
536
+ onAttachment={handlePickAndUploadMedia}
537
+ allowEmptySend={attachments.length > 0}
538
+ isSending={isSubmittingComment || isUploadingMedia}
539
+ hintText="Add a comment..."
540
+ theme={theme}
541
+ />
542
+ </>
543
+ )}
544
+ </SafeAreaView>
545
+ </KeyboardAvoidingView>
546
+ </Modal>
547
+ );
548
+ };
549
+
550
+ const styles = StyleSheet.create({
551
+ backdrop: {
552
+ flex: 1,
553
+ backgroundColor: 'rgba(0,0,0,0.5)',
554
+ justifyContent: 'flex-end',
555
+ },
556
+ backdropTouch: {
557
+ flex: 1,
558
+ },
559
+ sheetContainer: {
560
+ height: '85%',
561
+ borderTopLeftRadius: 20,
562
+ borderTopRightRadius: 20,
563
+ overflow: 'hidden',
564
+ },
565
+ handleContainer: {
566
+ alignItems: 'center',
567
+ paddingVertical: 12,
568
+ },
569
+ handleBar: {
570
+ width: 40,
571
+ height: 4,
572
+ borderRadius: 2,
573
+ },
574
+ toastBanner: {
575
+ marginHorizontal: 20,
576
+ marginBottom: 8,
577
+ paddingHorizontal: 14,
578
+ paddingVertical: 8,
579
+ borderRadius: 8,
580
+ alignItems: 'center',
581
+ },
582
+ toastText: {
583
+ color: '#FFFFFF',
584
+ fontSize: 13,
585
+ fontWeight: '600',
586
+ },
587
+ centerContainer: {
588
+ flex: 1,
589
+ alignItems: 'center',
590
+ justifyContent: 'center',
591
+ padding: 20,
592
+ },
593
+ errorText: {
594
+ fontSize: 15,
595
+ fontWeight: '600',
596
+ },
597
+ retryButton: {
598
+ marginTop: 10,
599
+ paddingHorizontal: 16,
600
+ paddingVertical: 8,
601
+ },
602
+ retryText: {
603
+ fontSize: 15,
604
+ fontWeight: '600',
605
+ },
606
+ scrollContent: {
607
+ flex: 1,
608
+ },
609
+ scrollInner: {
610
+ padding: 20,
611
+ },
612
+ headerRow: {
613
+ flexDirection: 'row',
614
+ alignItems: 'center',
615
+ justifyContent: 'space-between',
616
+ },
617
+ typeRow: {
618
+ flexDirection: 'row',
619
+ alignItems: 'center',
620
+ },
621
+ typeText: {
622
+ fontSize: 13,
623
+ fontWeight: '700',
624
+ marginLeft: 8,
625
+ },
626
+ statusPill: {
627
+ paddingHorizontal: 8,
628
+ paddingVertical: 4,
629
+ borderRadius: 4,
630
+ },
631
+ statusPillText: {
632
+ fontSize: 12,
633
+ fontWeight: '500',
634
+ },
635
+ title: {
636
+ fontSize: 20,
637
+ fontWeight: '700',
638
+ marginTop: 16,
639
+ lineHeight: 26,
640
+ },
641
+ description: {
642
+ fontSize: 16,
643
+ marginTop: 12,
644
+ lineHeight: 24,
645
+ },
646
+ votesRow: {
647
+ flexDirection: 'row',
648
+ alignItems: 'center',
649
+ marginTop: 24,
650
+ },
651
+ voteButton: {
652
+ flexDirection: 'row',
653
+ alignItems: 'center',
654
+ paddingHorizontal: 12,
655
+ paddingVertical: 6,
656
+ borderRadius: 20,
657
+ borderWidth: 1,
658
+ marginRight: 12,
659
+ },
660
+ voteButtonText: {
661
+ fontSize: 13,
662
+ fontWeight: '600',
663
+ marginLeft: 4,
664
+ },
665
+ viewConvButton: {
666
+ flexDirection: 'row',
667
+ alignItems: 'center',
668
+ justifyContent: 'center',
669
+ paddingVertical: 12,
670
+ borderRadius: 8,
671
+ marginTop: 16,
672
+ },
673
+ viewConvText: {
674
+ fontSize: 14,
675
+ fontWeight: '600',
676
+ marginLeft: 8,
677
+ },
678
+ commentsSectionTitle: {
679
+ fontSize: 18,
680
+ fontWeight: '700',
681
+ marginTop: 32,
682
+ marginBottom: 16,
683
+ },
684
+ emptyComments: {
685
+ alignItems: 'center',
686
+ paddingVertical: 20,
687
+ },
688
+ commentCard: {
689
+ padding: 12,
690
+ borderRadius: 12,
691
+ borderWidth: 1,
692
+ marginBottom: 16,
693
+ },
694
+ commentHeader: {
695
+ flexDirection: 'row',
696
+ alignItems: 'center',
697
+ },
698
+ commentAvatar: {
699
+ width: 24,
700
+ height: 24,
701
+ borderRadius: 12,
702
+ alignItems: 'center',
703
+ justifyContent: 'center',
704
+ },
705
+ commentAuthor: {
706
+ fontSize: 13,
707
+ fontWeight: '600',
708
+ marginLeft: 8,
709
+ flex: 1,
710
+ },
711
+ commentDate: {
712
+ fontSize: 12,
713
+ },
714
+ commentContent: {
715
+ fontSize: 14,
716
+ marginTop: 8,
717
+ lineHeight: 20,
718
+ },
719
+ stagedAttachmentsRow: {
720
+ flexDirection: 'row',
721
+ flexWrap: 'wrap',
722
+ paddingHorizontal: 16,
723
+ paddingVertical: 8,
724
+ borderTopWidth: 1,
725
+ gap: 8,
726
+ },
727
+ stagedItem: {
728
+ position: 'relative',
729
+ },
730
+ stagedThumbBox: {
731
+ width: 60,
732
+ height: 60,
733
+ borderRadius: 8,
734
+ borderWidth: 1,
735
+ overflow: 'hidden',
736
+ },
737
+ removeAttachmentBtn: {
738
+ position: 'absolute',
739
+ top: -4,
740
+ right: -4,
741
+ width: 18,
742
+ height: 18,
743
+ borderRadius: 9,
744
+ alignItems: 'center',
745
+ justifyContent: 'center',
746
+ },
747
+ });