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.
- package/LICENSE +21 -0
- package/README.md +401 -2
- package/android/build.gradle +39 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/dev/feeddo/reactnative/FeeddoReactNativeModule.java +380 -0
- package/android/src/main/java/dev/feeddo/reactnative/FeeddoReactNativePackage.java +25 -0
- package/dist/Feeddo.d.ts +131 -0
- package/dist/Feeddo.d.ts.map +1 -0
- package/dist/Feeddo.js +176 -0
- package/dist/Feeddo.js.map +1 -0
- package/dist/FeeddoClient.d.ts +151 -0
- package/dist/FeeddoClient.d.ts.map +1 -0
- package/dist/FeeddoClient.js +690 -0
- package/dist/FeeddoClient.js.map +1 -0
- package/dist/FeeddoProvider.d.ts +23 -0
- package/dist/FeeddoProvider.d.ts.map +1 -0
- package/dist/FeeddoProvider.js +76 -0
- package/dist/FeeddoProvider.js.map +1 -0
- package/dist/config/FeeddoConfig.d.ts +10 -0
- package/dist/config/FeeddoConfig.d.ts.map +1 -0
- package/dist/config/FeeddoConfig.js +10 -0
- package/dist/config/FeeddoConfig.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/models/Conversation.d.ts +27 -0
- package/dist/models/Conversation.d.ts.map +1 -0
- package/dist/models/Conversation.js +24 -0
- package/dist/models/Conversation.js.map +1 -0
- package/dist/models/EndUser.d.ts +49 -0
- package/dist/models/EndUser.d.ts.map +1 -0
- package/dist/models/EndUser.js +2 -0
- package/dist/models/EndUser.js.map +1 -0
- package/dist/models/FeeddoNotification.d.ts +15 -0
- package/dist/models/FeeddoNotification.d.ts.map +1 -0
- package/dist/models/FeeddoNotification.js +15 -0
- package/dist/models/FeeddoNotification.js.map +1 -0
- package/dist/models/HomeData.d.ts +16 -0
- package/dist/models/HomeData.d.ts.map +1 -0
- package/dist/models/HomeData.js +19 -0
- package/dist/models/HomeData.js.map +1 -0
- package/dist/models/Message.d.ts +12 -0
- package/dist/models/Message.d.ts.map +1 -0
- package/dist/models/Message.js +25 -0
- package/dist/models/Message.js.map +1 -0
- package/dist/models/PushProvider.d.ts +14 -0
- package/dist/models/PushProvider.d.ts.map +1 -0
- package/dist/models/PushProvider.js +9 -0
- package/dist/models/PushProvider.js.map +1 -0
- package/dist/models/Task.d.ts +17 -0
- package/dist/models/Task.d.ts.map +1 -0
- package/dist/models/Task.js +22 -0
- package/dist/models/Task.js.map +1 -0
- package/dist/models/TaskComment.d.ts +11 -0
- package/dist/models/TaskComment.d.ts.map +1 -0
- package/dist/models/TaskComment.js +27 -0
- package/dist/models/TaskComment.js.map +1 -0
- package/dist/models/Ticket.d.ts +13 -0
- package/dist/models/Ticket.d.ts.map +1 -0
- package/dist/models/Ticket.js +14 -0
- package/dist/models/Ticket.js.map +1 -0
- package/dist/native/FeeddoNative.d.ts +58 -0
- package/dist/native/FeeddoNative.d.ts.map +1 -0
- package/dist/native/FeeddoNative.js +22 -0
- package/dist/native/FeeddoNative.js.map +1 -0
- package/dist/push/FeeddoPushNotificationApns.d.ts +73 -0
- package/dist/push/FeeddoPushNotificationApns.d.ts.map +1 -0
- package/dist/push/FeeddoPushNotificationApns.js +301 -0
- package/dist/push/FeeddoPushNotificationApns.js.map +1 -0
- package/dist/services/ApiService.d.ts +64 -0
- package/dist/services/ApiService.d.ts.map +1 -0
- package/dist/services/ApiService.js +406 -0
- package/dist/services/ApiService.js.map +1 -0
- package/dist/services/ConversationService.d.ts +45 -0
- package/dist/services/ConversationService.d.ts.map +1 -0
- package/dist/services/ConversationService.js +259 -0
- package/dist/services/ConversationService.js.map +1 -0
- package/dist/services/WebSocketService.d.ts +26 -0
- package/dist/services/WebSocketService.d.ts.map +1 -0
- package/dist/services/WebSocketService.js +157 -0
- package/dist/services/WebSocketService.js.map +1 -0
- package/dist/theme/FeeddoTheme.d.ts +31 -0
- package/dist/theme/FeeddoTheme.d.ts.map +1 -0
- package/dist/theme/FeeddoTheme.js +60 -0
- package/dist/theme/FeeddoTheme.js.map +1 -0
- package/dist/ui/FeeddoFeedbackCard.d.ts +15 -0
- package/dist/ui/FeeddoFeedbackCard.d.ts.map +1 -0
- package/dist/ui/FeeddoFeedbackCard.js +188 -0
- package/dist/ui/FeeddoFeedbackCard.js.map +1 -0
- package/dist/ui/FeeddoModal.d.ts +20 -0
- package/dist/ui/FeeddoModal.d.ts.map +1 -0
- package/dist/ui/FeeddoModal.js +174 -0
- package/dist/ui/FeeddoModal.js.map +1 -0
- package/dist/ui/components/AttachmentPreview.d.ts +10 -0
- package/dist/ui/components/AttachmentPreview.d.ts.map +1 -0
- package/dist/ui/components/AttachmentPreview.js +143 -0
- package/dist/ui/components/AttachmentPreview.js.map +1 -0
- package/dist/ui/components/ChatInputArea.d.ts +16 -0
- package/dist/ui/components/ChatInputArea.d.ts.map +1 -0
- package/dist/ui/components/ChatInputArea.js +85 -0
- package/dist/ui/components/ChatInputArea.js.map +1 -0
- package/dist/ui/components/FeeddoIcon.d.ts +10 -0
- package/dist/ui/components/FeeddoIcon.d.ts.map +1 -0
- package/dist/ui/components/FeeddoIcon.js +690 -0
- package/dist/ui/components/FeeddoIcon.js.map +1 -0
- package/dist/ui/components/FeeddoNotificationBadge.d.ts +14 -0
- package/dist/ui/components/FeeddoNotificationBadge.d.ts.map +1 -0
- package/dist/ui/components/FeeddoNotificationBadge.js +171 -0
- package/dist/ui/components/FeeddoNotificationBadge.js.map +1 -0
- package/dist/ui/components/MessageBubble.d.ts +13 -0
- package/dist/ui/components/MessageBubble.d.ts.map +1 -0
- package/dist/ui/components/MessageBubble.js +163 -0
- package/dist/ui/components/MessageBubble.js.map +1 -0
- package/dist/ui/components/NotificationsSheet.d.ts +10 -0
- package/dist/ui/components/NotificationsSheet.d.ts.map +1 -0
- package/dist/ui/components/NotificationsSheet.js +252 -0
- package/dist/ui/components/NotificationsSheet.js.map +1 -0
- package/dist/ui/components/RatingWidget.d.ts +11 -0
- package/dist/ui/components/RatingWidget.d.ts.map +1 -0
- package/dist/ui/components/RatingWidget.js +34 -0
- package/dist/ui/components/RatingWidget.js.map +1 -0
- package/dist/ui/components/TaskCard.d.ts +12 -0
- package/dist/ui/components/TaskCard.d.ts.map +1 -0
- package/dist/ui/components/TaskCard.js +210 -0
- package/dist/ui/components/TaskCard.js.map +1 -0
- package/dist/ui/components/TaskDetailsSheet.d.ts +15 -0
- package/dist/ui/components/TaskDetailsSheet.d.ts.map +1 -0
- package/dist/ui/components/TaskDetailsSheet.js +577 -0
- package/dist/ui/components/TaskDetailsSheet.js.map +1 -0
- package/dist/ui/components/TicketCard.d.ts +11 -0
- package/dist/ui/components/TicketCard.d.ts.map +1 -0
- package/dist/ui/components/TicketCard.js +100 -0
- package/dist/ui/components/TicketCard.js.map +1 -0
- package/dist/ui/components/TicketDetailsSheet.d.ts +14 -0
- package/dist/ui/components/TicketDetailsSheet.d.ts.map +1 -0
- package/dist/ui/components/TicketDetailsSheet.js +254 -0
- package/dist/ui/components/TicketDetailsSheet.js.map +1 -0
- package/dist/ui/components/TypingIndicator.d.ts +10 -0
- package/dist/ui/components/TypingIndicator.d.ts.map +1 -0
- package/dist/ui/components/TypingIndicator.js +77 -0
- package/dist/ui/components/TypingIndicator.js.map +1 -0
- package/dist/ui/screens/FeeddoChatScreen.d.ts +13 -0
- package/dist/ui/screens/FeeddoChatScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoChatScreen.js +681 -0
- package/dist/ui/screens/FeeddoChatScreen.js.map +1 -0
- package/dist/ui/screens/FeeddoHomeScreen.d.ts +15 -0
- package/dist/ui/screens/FeeddoHomeScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoHomeScreen.js +653 -0
- package/dist/ui/screens/FeeddoHomeScreen.js.map +1 -0
- package/dist/ui/screens/FeeddoMessagesScreen.d.ts +12 -0
- package/dist/ui/screens/FeeddoMessagesScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoMessagesScreen.js +326 -0
- package/dist/ui/screens/FeeddoMessagesScreen.js.map +1 -0
- package/dist/ui/screens/FeeddoTasksScreen.d.ts +13 -0
- package/dist/ui/screens/FeeddoTasksScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoTasksScreen.js +517 -0
- package/dist/ui/screens/FeeddoTasksScreen.js.map +1 -0
- package/dist/ui/screens/FeeddoTicketsScreen.d.ts +10 -0
- package/dist/ui/screens/FeeddoTicketsScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoTicketsScreen.js +112 -0
- package/dist/ui/screens/FeeddoTicketsScreen.js.map +1 -0
- package/dist/utils/DeviceInfoHelper.d.ts +29 -0
- package/dist/utils/DeviceInfoHelper.d.ts.map +1 -0
- package/dist/utils/DeviceInfoHelper.js +190 -0
- package/dist/utils/DeviceInfoHelper.js.map +1 -0
- package/dist/utils/MediaHelper.d.ts +20 -0
- package/dist/utils/MediaHelper.d.ts.map +1 -0
- package/dist/utils/MediaHelper.js +92 -0
- package/dist/utils/MediaHelper.js.map +1 -0
- package/dist/utils/NotificationSupport.d.ts +22 -0
- package/dist/utils/NotificationSupport.d.ts.map +1 -0
- package/dist/utils/NotificationSupport.js +211 -0
- package/dist/utils/NotificationSupport.js.map +1 -0
- package/dist/utils/StorageHelper.d.ts +65 -0
- package/dist/utils/StorageHelper.d.ts.map +1 -0
- package/dist/utils/StorageHelper.js +273 -0
- package/dist/utils/StorageHelper.js.map +1 -0
- package/feeddo-react-native.podspec +26 -0
- package/ios/FeeddoReactNativeModule.h +8 -0
- package/ios/FeeddoReactNativeModule.m +831 -0
- package/package.json +56 -4
- package/src/Feeddo.ts +247 -0
- package/src/FeeddoClient.ts +895 -0
- package/src/FeeddoProvider.tsx +139 -0
- package/src/config/FeeddoConfig.ts +9 -0
- package/src/index.ts +67 -0
- package/src/models/Conversation.ts +50 -0
- package/src/models/EndUser.ts +65 -0
- package/src/models/FeeddoNotification.ts +29 -0
- package/src/models/HomeData.ts +33 -0
- package/src/models/Message.ts +36 -0
- package/src/models/PushProvider.ts +15 -0
- package/src/models/Task.ts +40 -0
- package/src/models/TaskComment.ts +36 -0
- package/src/models/Ticket.ts +25 -0
- package/src/native/FeeddoNative.ts +80 -0
- package/src/push/FeeddoPushNotificationApns.ts +362 -0
- package/src/services/ApiService.ts +456 -0
- package/src/services/ConversationService.ts +305 -0
- package/src/services/WebSocketService.ts +185 -0
- package/src/theme/FeeddoTheme.ts +85 -0
- package/src/ui/FeeddoFeedbackCard.tsx +245 -0
- package/src/ui/FeeddoModal.tsx +303 -0
- package/src/ui/components/AttachmentPreview.tsx +192 -0
- package/src/ui/components/ChatInputArea.tsx +154 -0
- package/src/ui/components/FeeddoIcon.tsx +903 -0
- package/src/ui/components/FeeddoNotificationBadge.tsx +234 -0
- package/src/ui/components/MessageBubble.tsx +223 -0
- package/src/ui/components/NotificationsSheet.tsx +324 -0
- package/src/ui/components/RatingWidget.tsx +64 -0
- package/src/ui/components/TaskCard.tsx +259 -0
- package/src/ui/components/TaskDetailsSheet.tsx +747 -0
- package/src/ui/components/TicketCard.tsx +128 -0
- package/src/ui/components/TicketDetailsSheet.tsx +324 -0
- package/src/ui/components/TypingIndicator.tsx +104 -0
- package/src/ui/screens/FeeddoChatScreen.tsx +877 -0
- package/src/ui/screens/FeeddoHomeScreen.tsx +824 -0
- package/src/ui/screens/FeeddoMessagesScreen.tsx +414 -0
- package/src/ui/screens/FeeddoTasksScreen.tsx +671 -0
- package/src/ui/screens/FeeddoTicketsScreen.tsx +164 -0
- package/src/utils/DeviceInfoHelper.ts +209 -0
- package/src/utils/MediaHelper.ts +105 -0
- package/src/utils/NotificationSupport.ts +233 -0
- package/src/utils/StorageHelper.ts +305 -0
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
FlatList,
|
|
8
|
+
ActivityIndicator,
|
|
9
|
+
Modal,
|
|
10
|
+
Switch,
|
|
11
|
+
SafeAreaView,
|
|
12
|
+
RefreshControl,
|
|
13
|
+
Alert,
|
|
14
|
+
} from 'react-native';
|
|
15
|
+
import { Task } from '../../models/Task';
|
|
16
|
+
import { FeeddoTheme } from '../../theme/FeeddoTheme';
|
|
17
|
+
import { FeeddoIcon } from '../components/FeeddoIcon';
|
|
18
|
+
import { TaskCard } from '../components/TaskCard';
|
|
19
|
+
import { TaskDetailsSheet } from '../components/TaskDetailsSheet';
|
|
20
|
+
import { FeeddoInternal } from '../../FeeddoClient';
|
|
21
|
+
|
|
22
|
+
const PAGE_LIMIT = 10;
|
|
23
|
+
|
|
24
|
+
interface FeeddoTasksScreenProps {
|
|
25
|
+
theme: FeeddoTheme;
|
|
26
|
+
isActive?: boolean;
|
|
27
|
+
initialTaskId?: string;
|
|
28
|
+
onBack: () => void;
|
|
29
|
+
onOpenNewPost: () => void;
|
|
30
|
+
onOpenConversation?: (conversationId: string) => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const FeeddoTasksScreen: React.FC<FeeddoTasksScreenProps> = ({
|
|
34
|
+
theme,
|
|
35
|
+
isActive = true,
|
|
36
|
+
initialTaskId,
|
|
37
|
+
onBack,
|
|
38
|
+
onOpenNewPost,
|
|
39
|
+
onOpenConversation,
|
|
40
|
+
}) => {
|
|
41
|
+
const [tasks, setTasks] = useState<Task[]>([]);
|
|
42
|
+
const [activeTab, setActiveTab] = useState<'all' | 'feature' | 'bug'>('all');
|
|
43
|
+
const [isLoading, setIsLoading] = useState<boolean>(true);
|
|
44
|
+
const [isLoadingMore, setIsLoadingMore] = useState<boolean>(false);
|
|
45
|
+
const [isRefreshing, setIsRefreshing] = useState<boolean>(false);
|
|
46
|
+
const [error, setError] = useState<string | null>(null);
|
|
47
|
+
|
|
48
|
+
const [selectedTask, setSelectedTask] = useState<Task | null>(null);
|
|
49
|
+
const [deepLinkTaskId, setDeepLinkTaskId] = useState<string | undefined>(initialTaskId);
|
|
50
|
+
|
|
51
|
+
// Filters (applied vs draft in bottom sheet, matching Flutter)
|
|
52
|
+
const [showFilterModal, setShowFilterModal] = useState<boolean>(false);
|
|
53
|
+
const [sortBy, setSortBy] = useState<'upvotes' | 'time'>('upvotes');
|
|
54
|
+
const [showCreatedByMeOnly, setShowCreatedByMeOnly] = useState<boolean>(false);
|
|
55
|
+
const [draftSortBy, setDraftSortBy] = useState<'upvotes' | 'time'>('upvotes');
|
|
56
|
+
const [draftCreatedByMeOnly, setDraftCreatedByMeOnly] = useState<boolean>(false);
|
|
57
|
+
|
|
58
|
+
// Pagination & concurrency guards
|
|
59
|
+
const pageRef = useRef<number>(1);
|
|
60
|
+
const hasMoreRef = useRef<boolean>(true);
|
|
61
|
+
const [hasMore, setHasMore] = useState<boolean>(true);
|
|
62
|
+
const votingTaskIdsRef = useRef<Set<string>>(new Set());
|
|
63
|
+
const wasActive = useRef<boolean>(isActive);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
setDeepLinkTaskId(initialTaskId);
|
|
67
|
+
}, [initialTaskId]);
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
loadTasks({
|
|
71
|
+
refresh: true,
|
|
72
|
+
tab: activeTab,
|
|
73
|
+
sort: sortBy,
|
|
74
|
+
createdByMeOnly: showCreatedByMeOnly,
|
|
75
|
+
});
|
|
76
|
+
}, [activeTab]);
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (isActive && !wasActive.current) {
|
|
80
|
+
loadTasks({
|
|
81
|
+
refresh: true,
|
|
82
|
+
tab: activeTab,
|
|
83
|
+
sort: sortBy,
|
|
84
|
+
createdByMeOnly: showCreatedByMeOnly,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
wasActive.current = isActive;
|
|
88
|
+
}, [isActive]);
|
|
89
|
+
|
|
90
|
+
const loadTasks = async (opts: {
|
|
91
|
+
refresh?: boolean;
|
|
92
|
+
pullToRefresh?: boolean;
|
|
93
|
+
tab?: 'all' | 'feature' | 'bug';
|
|
94
|
+
sort?: 'upvotes' | 'time';
|
|
95
|
+
createdByMeOnly?: boolean;
|
|
96
|
+
} = {}) => {
|
|
97
|
+
const refresh = opts.refresh ?? false;
|
|
98
|
+
const pullToRefresh = opts.pullToRefresh ?? false;
|
|
99
|
+
const tab = opts.tab ?? activeTab;
|
|
100
|
+
const sort = opts.sort ?? sortBy;
|
|
101
|
+
const createdByMeOnly = opts.createdByMeOnly ?? showCreatedByMeOnly;
|
|
102
|
+
|
|
103
|
+
if (refresh) {
|
|
104
|
+
pageRef.current = 1;
|
|
105
|
+
hasMoreRef.current = true;
|
|
106
|
+
setHasMore(true);
|
|
107
|
+
setError(null);
|
|
108
|
+
if (pullToRefresh) {
|
|
109
|
+
setIsRefreshing(true);
|
|
110
|
+
} else {
|
|
111
|
+
setIsLoading(true);
|
|
112
|
+
setTasks([]);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
if (isLoading || isLoadingMore || !hasMoreRef.current) return;
|
|
116
|
+
setIsLoadingMore(true);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
await FeeddoInternal.instance.ensureUserInitialized();
|
|
121
|
+
const targetPage = pageRef.current;
|
|
122
|
+
const newTasks = await FeeddoInternal.instance.apiService.getTasks({
|
|
123
|
+
userId: FeeddoInternal.instance.userId ?? undefined,
|
|
124
|
+
type: tab === 'all' ? undefined : tab,
|
|
125
|
+
sortBy: sort,
|
|
126
|
+
page: targetPage,
|
|
127
|
+
limit: PAGE_LIMIT,
|
|
128
|
+
createdByMe: createdByMeOnly ? true : undefined,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
setTasks((prev) => (refresh ? newTasks : [...prev, ...newTasks]));
|
|
132
|
+
const more = newTasks.length >= PAGE_LIMIT;
|
|
133
|
+
hasMoreRef.current = more;
|
|
134
|
+
setHasMore(more);
|
|
135
|
+
if (more) {
|
|
136
|
+
pageRef.current = targetPage + 1;
|
|
137
|
+
}
|
|
138
|
+
} catch (e: any) {
|
|
139
|
+
const msg = e?.message || String(e);
|
|
140
|
+
if (refresh) {
|
|
141
|
+
setError(msg);
|
|
142
|
+
} else {
|
|
143
|
+
Alert.alert('Error', `Failed to load more tasks: ${msg}`);
|
|
144
|
+
}
|
|
145
|
+
} finally {
|
|
146
|
+
setIsLoading(false);
|
|
147
|
+
setIsLoadingMore(false);
|
|
148
|
+
setIsRefreshing(false);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const openFilterModal = () => {
|
|
153
|
+
setDraftSortBy(sortBy);
|
|
154
|
+
setDraftCreatedByMeOnly(showCreatedByMeOnly);
|
|
155
|
+
setShowFilterModal(true);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const applyFilterChanges = () => {
|
|
159
|
+
setSortBy(draftSortBy);
|
|
160
|
+
setShowCreatedByMeOnly(draftCreatedByMeOnly);
|
|
161
|
+
setShowFilterModal(false);
|
|
162
|
+
loadTasks({
|
|
163
|
+
refresh: true,
|
|
164
|
+
tab: activeTab,
|
|
165
|
+
sort: draftSortBy,
|
|
166
|
+
createdByMeOnly: draftCreatedByMeOnly,
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const handleVote = async (task: Task, voteType: 'up' | 'remove') => {
|
|
171
|
+
if (votingTaskIdsRef.current.has(task.id)) return;
|
|
172
|
+
votingTaskIdsRef.current.add(task.id);
|
|
173
|
+
|
|
174
|
+
const oldMyVote = task.myVote;
|
|
175
|
+
let newUpvoteCount = task.upvoteCount;
|
|
176
|
+
let newMyVote: 'up' | null = null;
|
|
177
|
+
|
|
178
|
+
if (voteType === 'remove') {
|
|
179
|
+
if (oldMyVote === 'up') newUpvoteCount -= 1;
|
|
180
|
+
else if (oldMyVote === 'down') newUpvoteCount += 1;
|
|
181
|
+
newMyVote = null;
|
|
182
|
+
} else if (voteType === 'up') {
|
|
183
|
+
if (oldMyVote === 'down') newUpvoteCount += 2;
|
|
184
|
+
else if (oldMyVote !== 'up') newUpvoteCount += 1;
|
|
185
|
+
newMyVote = 'up';
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const updatedTask: Task = {
|
|
189
|
+
...task,
|
|
190
|
+
upvoteCount: newUpvoteCount,
|
|
191
|
+
myVote: newMyVote,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
setTasks((prev) => prev.map((t) => (t.id === task.id ? updatedTask : t)));
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
const res = await FeeddoInternal.instance.voteTask(
|
|
198
|
+
task.id,
|
|
199
|
+
voteType === 'remove' ? 'none' : 'up'
|
|
200
|
+
);
|
|
201
|
+
if (res.upvoteCount !== undefined) {
|
|
202
|
+
setTasks((prev) =>
|
|
203
|
+
prev.map((t) =>
|
|
204
|
+
t.id === task.id
|
|
205
|
+
? { ...t, upvoteCount: res.upvoteCount!, myVote: newMyVote }
|
|
206
|
+
: t
|
|
207
|
+
)
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
} catch (e: any) {
|
|
211
|
+
setTasks((prev) => prev.map((t) => (t.id === task.id ? task : t)));
|
|
212
|
+
Alert.alert('Error', `Failed to vote: ${e?.message || e}`);
|
|
213
|
+
} finally {
|
|
214
|
+
votingTaskIdsRef.current.delete(task.id);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const onPrimaryColor = theme.isDark ? '#000000' : '#FFFFFF';
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<SafeAreaView style={[styles.container, { backgroundColor: theme.colors.background }]}>
|
|
222
|
+
{/* AppBar (centered title matching Flutter) */}
|
|
223
|
+
<View
|
|
224
|
+
style={[
|
|
225
|
+
styles.appBar,
|
|
226
|
+
{
|
|
227
|
+
backgroundColor: theme.colors.appBarBackground,
|
|
228
|
+
},
|
|
229
|
+
]}
|
|
230
|
+
>
|
|
231
|
+
<TouchableOpacity activeOpacity={0.8} onPress={onBack} style={styles.backButton}>
|
|
232
|
+
<FeeddoIcon name="arrow_back" size={20} color={theme.colors.iconColor} />
|
|
233
|
+
</TouchableOpacity>
|
|
234
|
+
|
|
235
|
+
<Text style={[styles.appBarTitle, { color: theme.colors.textPrimary }]}>
|
|
236
|
+
Community Board
|
|
237
|
+
</Text>
|
|
238
|
+
|
|
239
|
+
<TouchableOpacity
|
|
240
|
+
activeOpacity={0.8}
|
|
241
|
+
onPress={openFilterModal}
|
|
242
|
+
style={styles.filterButton}
|
|
243
|
+
>
|
|
244
|
+
<FeeddoIcon name="tune" size={20} color={theme.colors.iconColor} />
|
|
245
|
+
</TouchableOpacity>
|
|
246
|
+
</View>
|
|
247
|
+
|
|
248
|
+
{/* Tabs */}
|
|
249
|
+
<View
|
|
250
|
+
style={[
|
|
251
|
+
styles.tabsRow,
|
|
252
|
+
{
|
|
253
|
+
backgroundColor: theme.colors.appBarBackground,
|
|
254
|
+
borderBottomColor: 'transparent',
|
|
255
|
+
},
|
|
256
|
+
]}
|
|
257
|
+
>
|
|
258
|
+
{(['all', 'feature', 'bug'] as const).map((tab) => {
|
|
259
|
+
const isActiveTab = activeTab === tab;
|
|
260
|
+
const label = tab === 'all' ? 'All' : tab === 'feature' ? 'Features' : 'Bugs';
|
|
261
|
+
return (
|
|
262
|
+
<TouchableOpacity
|
|
263
|
+
key={tab}
|
|
264
|
+
activeOpacity={0.8}
|
|
265
|
+
onPress={() => setActiveTab(tab)}
|
|
266
|
+
style={[
|
|
267
|
+
styles.tabItem,
|
|
268
|
+
isActiveTab && { borderBottomColor: theme.colors.primary, borderBottomWidth: 3 },
|
|
269
|
+
]}
|
|
270
|
+
>
|
|
271
|
+
<Text
|
|
272
|
+
style={[
|
|
273
|
+
styles.tabLabel,
|
|
274
|
+
{
|
|
275
|
+
color: isActiveTab ? theme.colors.primary : theme.colors.textSecondary,
|
|
276
|
+
fontWeight: isActiveTab ? '700' : '500',
|
|
277
|
+
},
|
|
278
|
+
]}
|
|
279
|
+
>
|
|
280
|
+
{label}
|
|
281
|
+
</Text>
|
|
282
|
+
</TouchableOpacity>
|
|
283
|
+
);
|
|
284
|
+
})}
|
|
285
|
+
</View>
|
|
286
|
+
|
|
287
|
+
{/* Content */}
|
|
288
|
+
{isLoading ? (
|
|
289
|
+
<View style={styles.centerContainer}>
|
|
290
|
+
<ActivityIndicator size="large" color={theme.colors.primary} />
|
|
291
|
+
</View>
|
|
292
|
+
) : error && tasks.length === 0 ? (
|
|
293
|
+
<View style={styles.centerContainer}>
|
|
294
|
+
<FeeddoIcon name="error" size={48} color={theme.colors.error} />
|
|
295
|
+
<Text style={[styles.errorTitle, { color: theme.colors.textPrimary }]}>
|
|
296
|
+
Something went wrong
|
|
297
|
+
</Text>
|
|
298
|
+
<Text style={[styles.errorSubtitle, { color: theme.colors.textSecondary }]}>
|
|
299
|
+
{error}
|
|
300
|
+
</Text>
|
|
301
|
+
<TouchableOpacity
|
|
302
|
+
onPress={() => loadTasks({ refresh: true })}
|
|
303
|
+
style={[styles.retryBtn, { backgroundColor: theme.colors.primary }]}
|
|
304
|
+
>
|
|
305
|
+
<Text style={[styles.retryBtnText, { color: onPrimaryColor }]}>Retry</Text>
|
|
306
|
+
</TouchableOpacity>
|
|
307
|
+
</View>
|
|
308
|
+
) : tasks.length === 0 ? (
|
|
309
|
+
<View style={styles.centerContainer}>
|
|
310
|
+
<FeeddoIcon name="inbox" size={64} color={`${theme.colors.textSecondary}80`} />
|
|
311
|
+
<Text style={[styles.emptyTitle, { color: theme.colors.textPrimary }]}>
|
|
312
|
+
No posts found
|
|
313
|
+
</Text>
|
|
314
|
+
<Text style={[styles.emptySubtitle, { color: theme.colors.textSecondary }]}>
|
|
315
|
+
Be the first to create one!
|
|
316
|
+
</Text>
|
|
317
|
+
</View>
|
|
318
|
+
) : (
|
|
319
|
+
<FlatList
|
|
320
|
+
data={tasks}
|
|
321
|
+
keyExtractor={(item) => item.id}
|
|
322
|
+
contentContainerStyle={styles.listContent}
|
|
323
|
+
ItemSeparatorComponent={() => <View style={{ height: 10 }} />}
|
|
324
|
+
refreshControl={
|
|
325
|
+
<RefreshControl
|
|
326
|
+
refreshing={isRefreshing}
|
|
327
|
+
onRefresh={() => loadTasks({ refresh: true, pullToRefresh: true })}
|
|
328
|
+
tintColor={theme.colors.primary}
|
|
329
|
+
/>
|
|
330
|
+
}
|
|
331
|
+
onEndReached={() => {
|
|
332
|
+
if (hasMore && !isLoadingMore && !isLoading) {
|
|
333
|
+
loadTasks({ refresh: false });
|
|
334
|
+
}
|
|
335
|
+
}}
|
|
336
|
+
onEndReachedThreshold={0.25}
|
|
337
|
+
ListFooterComponent={
|
|
338
|
+
hasMore ? (
|
|
339
|
+
<View style={styles.footerLoader}>
|
|
340
|
+
<ActivityIndicator size="small" color={theme.colors.primary} />
|
|
341
|
+
</View>
|
|
342
|
+
) : null
|
|
343
|
+
}
|
|
344
|
+
renderItem={({ item }) => (
|
|
345
|
+
<TaskCard
|
|
346
|
+
task={item}
|
|
347
|
+
theme={theme}
|
|
348
|
+
onVote={(type) => handleVote(item, type)}
|
|
349
|
+
onTap={() => setSelectedTask(item)}
|
|
350
|
+
/>
|
|
351
|
+
)}
|
|
352
|
+
/>
|
|
353
|
+
)}
|
|
354
|
+
|
|
355
|
+
{/* Extended FAB: + New Post */}
|
|
356
|
+
<TouchableOpacity
|
|
357
|
+
activeOpacity={0.85}
|
|
358
|
+
onPress={onOpenNewPost}
|
|
359
|
+
style={[
|
|
360
|
+
styles.extendedFab,
|
|
361
|
+
{
|
|
362
|
+
backgroundColor: theme.colors.primary,
|
|
363
|
+
shadowColor: theme.colors.primary,
|
|
364
|
+
},
|
|
365
|
+
]}
|
|
366
|
+
>
|
|
367
|
+
<FeeddoIcon name="add" size={20} color={onPrimaryColor} />
|
|
368
|
+
<Text style={[styles.extendedFabText, { color: onPrimaryColor }]}>
|
|
369
|
+
New Post
|
|
370
|
+
</Text>
|
|
371
|
+
</TouchableOpacity>
|
|
372
|
+
|
|
373
|
+
{/* Task Details Sheet */}
|
|
374
|
+
<TaskDetailsSheet
|
|
375
|
+
visible={Boolean(selectedTask || deepLinkTaskId)}
|
|
376
|
+
task={selectedTask ?? undefined}
|
|
377
|
+
taskId={selectedTask ? undefined : deepLinkTaskId}
|
|
378
|
+
onClose={() => {
|
|
379
|
+
setSelectedTask(null);
|
|
380
|
+
setDeepLinkTaskId(undefined);
|
|
381
|
+
}}
|
|
382
|
+
onOpenConversation={onOpenConversation}
|
|
383
|
+
onTaskUpdated={(updated) => {
|
|
384
|
+
setTasks((prev) => prev.map((t) => (t.id === updated.id ? updated : t)));
|
|
385
|
+
}}
|
|
386
|
+
theme={theme}
|
|
387
|
+
/>
|
|
388
|
+
|
|
389
|
+
{/* Filter Bottom Sheet Modal */}
|
|
390
|
+
<Modal visible={showFilterModal} transparent animationType="slide">
|
|
391
|
+
<View style={styles.filterBackdrop}>
|
|
392
|
+
<TouchableOpacity
|
|
393
|
+
style={styles.filterBackdropTouch}
|
|
394
|
+
activeOpacity={1}
|
|
395
|
+
onPress={() => setShowFilterModal(false)}
|
|
396
|
+
/>
|
|
397
|
+
|
|
398
|
+
<View style={[styles.filterSheet, { backgroundColor: theme.colors.surface }]}>
|
|
399
|
+
<Text style={[styles.filterSheetTitle, { color: theme.colors.textPrimary }]}>
|
|
400
|
+
Sort & Filter
|
|
401
|
+
</Text>
|
|
402
|
+
|
|
403
|
+
<Text style={[styles.filterLabel, { color: theme.colors.textPrimary }]}>
|
|
404
|
+
Sort By
|
|
405
|
+
</Text>
|
|
406
|
+
<View style={styles.chipsRow}>
|
|
407
|
+
<TouchableOpacity
|
|
408
|
+
activeOpacity={0.8}
|
|
409
|
+
onPress={() => setDraftSortBy('time')}
|
|
410
|
+
style={[
|
|
411
|
+
styles.filterChip,
|
|
412
|
+
{
|
|
413
|
+
backgroundColor:
|
|
414
|
+
draftSortBy === 'time'
|
|
415
|
+
? theme.colors.primary
|
|
416
|
+
: theme.colors.background,
|
|
417
|
+
borderColor:
|
|
418
|
+
draftSortBy === 'time'
|
|
419
|
+
? theme.colors.primary
|
|
420
|
+
: theme.colors.border,
|
|
421
|
+
},
|
|
422
|
+
]}
|
|
423
|
+
>
|
|
424
|
+
{draftSortBy === 'time' && (
|
|
425
|
+
<View style={{ marginRight: 6 }}>
|
|
426
|
+
<FeeddoIcon name="check" size={14} color={theme.colors.background} />
|
|
427
|
+
</View>
|
|
428
|
+
)}
|
|
429
|
+
<Text
|
|
430
|
+
style={[
|
|
431
|
+
styles.filterChipText,
|
|
432
|
+
{
|
|
433
|
+
color:
|
|
434
|
+
draftSortBy === 'time'
|
|
435
|
+
? theme.colors.background
|
|
436
|
+
: theme.colors.textPrimary,
|
|
437
|
+
fontWeight: draftSortBy === 'time' ? '700' : '400',
|
|
438
|
+
},
|
|
439
|
+
]}
|
|
440
|
+
>
|
|
441
|
+
Newest First
|
|
442
|
+
</Text>
|
|
443
|
+
</TouchableOpacity>
|
|
444
|
+
|
|
445
|
+
<TouchableOpacity
|
|
446
|
+
activeOpacity={0.8}
|
|
447
|
+
onPress={() => setDraftSortBy('upvotes')}
|
|
448
|
+
style={[
|
|
449
|
+
styles.filterChip,
|
|
450
|
+
{
|
|
451
|
+
backgroundColor:
|
|
452
|
+
draftSortBy === 'upvotes'
|
|
453
|
+
? theme.colors.primary
|
|
454
|
+
: theme.colors.background,
|
|
455
|
+
borderColor:
|
|
456
|
+
draftSortBy === 'upvotes'
|
|
457
|
+
? theme.colors.primary
|
|
458
|
+
: theme.colors.border,
|
|
459
|
+
},
|
|
460
|
+
]}
|
|
461
|
+
>
|
|
462
|
+
{draftSortBy === 'upvotes' && (
|
|
463
|
+
<View style={{ marginRight: 6 }}>
|
|
464
|
+
<FeeddoIcon name="check" size={14} color={theme.colors.background} />
|
|
465
|
+
</View>
|
|
466
|
+
)}
|
|
467
|
+
<Text
|
|
468
|
+
style={[
|
|
469
|
+
styles.filterChipText,
|
|
470
|
+
{
|
|
471
|
+
color:
|
|
472
|
+
draftSortBy === 'upvotes'
|
|
473
|
+
? theme.colors.background
|
|
474
|
+
: theme.colors.textPrimary,
|
|
475
|
+
fontWeight: draftSortBy === 'upvotes' ? '700' : '400',
|
|
476
|
+
},
|
|
477
|
+
]}
|
|
478
|
+
>
|
|
479
|
+
Most Upvoted
|
|
480
|
+
</Text>
|
|
481
|
+
</TouchableOpacity>
|
|
482
|
+
</View>
|
|
483
|
+
|
|
484
|
+
{/* My tasks switch */}
|
|
485
|
+
<View style={styles.switchRow}>
|
|
486
|
+
<Text style={[styles.filterLabel, { color: theme.colors.textPrimary, marginBottom: 0 }]}>
|
|
487
|
+
Show created by me only
|
|
488
|
+
</Text>
|
|
489
|
+
<Switch
|
|
490
|
+
value={draftCreatedByMeOnly}
|
|
491
|
+
onValueChange={setDraftCreatedByMeOnly}
|
|
492
|
+
thumbColor={theme.colors.primary}
|
|
493
|
+
/>
|
|
494
|
+
</View>
|
|
495
|
+
|
|
496
|
+
{/* Apply button */}
|
|
497
|
+
<TouchableOpacity
|
|
498
|
+
activeOpacity={0.85}
|
|
499
|
+
onPress={applyFilterChanges}
|
|
500
|
+
style={[styles.applyButton, { backgroundColor: theme.colors.primary }]}
|
|
501
|
+
>
|
|
502
|
+
<Text style={[styles.applyButtonText, { color: onPrimaryColor }]}>
|
|
503
|
+
Apply Changes
|
|
504
|
+
</Text>
|
|
505
|
+
</TouchableOpacity>
|
|
506
|
+
</View>
|
|
507
|
+
</View>
|
|
508
|
+
</Modal>
|
|
509
|
+
</SafeAreaView>
|
|
510
|
+
);
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
const styles = StyleSheet.create({
|
|
514
|
+
container: {
|
|
515
|
+
flex: 1,
|
|
516
|
+
},
|
|
517
|
+
appBar: {
|
|
518
|
+
flexDirection: 'row',
|
|
519
|
+
alignItems: 'center',
|
|
520
|
+
justifyContent: 'space-between',
|
|
521
|
+
paddingHorizontal: 16,
|
|
522
|
+
paddingVertical: 14,
|
|
523
|
+
},
|
|
524
|
+
backButton: {
|
|
525
|
+
padding: 6,
|
|
526
|
+
width: 36,
|
|
527
|
+
},
|
|
528
|
+
appBarTitle: {
|
|
529
|
+
fontSize: 20,
|
|
530
|
+
fontWeight: '700',
|
|
531
|
+
flex: 1,
|
|
532
|
+
textAlign: 'center',
|
|
533
|
+
},
|
|
534
|
+
filterButton: {
|
|
535
|
+
padding: 6,
|
|
536
|
+
width: 36,
|
|
537
|
+
alignItems: 'flex-end',
|
|
538
|
+
},
|
|
539
|
+
tabsRow: {
|
|
540
|
+
flexDirection: 'row',
|
|
541
|
+
borderBottomWidth: 0,
|
|
542
|
+
},
|
|
543
|
+
tabItem: {
|
|
544
|
+
flex: 1,
|
|
545
|
+
paddingVertical: 12,
|
|
546
|
+
alignItems: 'center',
|
|
547
|
+
justifyContent: 'center',
|
|
548
|
+
},
|
|
549
|
+
tabLabel: {
|
|
550
|
+
fontSize: 14,
|
|
551
|
+
},
|
|
552
|
+
centerContainer: {
|
|
553
|
+
flex: 1,
|
|
554
|
+
alignItems: 'center',
|
|
555
|
+
justifyContent: 'center',
|
|
556
|
+
padding: 24,
|
|
557
|
+
},
|
|
558
|
+
errorTitle: {
|
|
559
|
+
fontSize: 16,
|
|
560
|
+
fontWeight: '700',
|
|
561
|
+
marginTop: 16,
|
|
562
|
+
},
|
|
563
|
+
errorSubtitle: {
|
|
564
|
+
fontSize: 13,
|
|
565
|
+
marginTop: 6,
|
|
566
|
+
textAlign: 'center',
|
|
567
|
+
},
|
|
568
|
+
retryBtn: {
|
|
569
|
+
marginTop: 16,
|
|
570
|
+
paddingHorizontal: 20,
|
|
571
|
+
paddingVertical: 10,
|
|
572
|
+
borderRadius: 8,
|
|
573
|
+
},
|
|
574
|
+
retryBtnText: {
|
|
575
|
+
fontSize: 14,
|
|
576
|
+
fontWeight: '700',
|
|
577
|
+
},
|
|
578
|
+
emptyTitle: {
|
|
579
|
+
fontSize: 18,
|
|
580
|
+
fontWeight: '700',
|
|
581
|
+
marginTop: 16,
|
|
582
|
+
},
|
|
583
|
+
emptySubtitle: {
|
|
584
|
+
fontSize: 14,
|
|
585
|
+
marginTop: 8,
|
|
586
|
+
},
|
|
587
|
+
listContent: {
|
|
588
|
+
paddingHorizontal: 16,
|
|
589
|
+
paddingVertical: 20,
|
|
590
|
+
paddingBottom: 90,
|
|
591
|
+
},
|
|
592
|
+
footerLoader: {
|
|
593
|
+
padding: 16,
|
|
594
|
+
alignItems: 'center',
|
|
595
|
+
},
|
|
596
|
+
extendedFab: {
|
|
597
|
+
position: 'absolute',
|
|
598
|
+
right: 20,
|
|
599
|
+
bottom: 24,
|
|
600
|
+
flexDirection: 'row',
|
|
601
|
+
alignItems: 'center',
|
|
602
|
+
paddingHorizontal: 18,
|
|
603
|
+
paddingVertical: 14,
|
|
604
|
+
borderRadius: 24,
|
|
605
|
+
shadowOffset: { width: 0, height: 4 },
|
|
606
|
+
shadowOpacity: 0.3,
|
|
607
|
+
shadowRadius: 10,
|
|
608
|
+
elevation: 4,
|
|
609
|
+
},
|
|
610
|
+
extendedFabText: {
|
|
611
|
+
fontSize: 14,
|
|
612
|
+
fontWeight: '700',
|
|
613
|
+
marginLeft: 8,
|
|
614
|
+
},
|
|
615
|
+
filterBackdrop: {
|
|
616
|
+
flex: 1,
|
|
617
|
+
backgroundColor: 'rgba(0,0,0,0.5)',
|
|
618
|
+
justifyContent: 'flex-end',
|
|
619
|
+
},
|
|
620
|
+
filterBackdropTouch: {
|
|
621
|
+
flex: 1,
|
|
622
|
+
},
|
|
623
|
+
filterSheet: {
|
|
624
|
+
borderTopLeftRadius: 16,
|
|
625
|
+
borderTopRightRadius: 16,
|
|
626
|
+
padding: 24,
|
|
627
|
+
},
|
|
628
|
+
filterSheetTitle: {
|
|
629
|
+
fontSize: 20,
|
|
630
|
+
fontWeight: '700',
|
|
631
|
+
marginBottom: 24,
|
|
632
|
+
},
|
|
633
|
+
filterLabel: {
|
|
634
|
+
fontSize: 15,
|
|
635
|
+
fontWeight: '600',
|
|
636
|
+
marginBottom: 12,
|
|
637
|
+
},
|
|
638
|
+
chipsRow: {
|
|
639
|
+
flexDirection: 'row',
|
|
640
|
+
flexWrap: 'wrap',
|
|
641
|
+
marginBottom: 24,
|
|
642
|
+
},
|
|
643
|
+
filterChip: {
|
|
644
|
+
flexDirection: 'row',
|
|
645
|
+
alignItems: 'center',
|
|
646
|
+
paddingHorizontal: 14,
|
|
647
|
+
paddingVertical: 8,
|
|
648
|
+
borderRadius: 20,
|
|
649
|
+
borderWidth: 1,
|
|
650
|
+
marginRight: 12,
|
|
651
|
+
},
|
|
652
|
+
filterChipText: {
|
|
653
|
+
fontSize: 13,
|
|
654
|
+
},
|
|
655
|
+
switchRow: {
|
|
656
|
+
flexDirection: 'row',
|
|
657
|
+
alignItems: 'center',
|
|
658
|
+
justifyContent: 'space-between',
|
|
659
|
+
marginBottom: 32,
|
|
660
|
+
},
|
|
661
|
+
applyButton: {
|
|
662
|
+
paddingVertical: 16,
|
|
663
|
+
borderRadius: 12,
|
|
664
|
+
alignItems: 'center',
|
|
665
|
+
marginBottom: 8,
|
|
666
|
+
},
|
|
667
|
+
applyButtonText: {
|
|
668
|
+
fontSize: 15,
|
|
669
|
+
fontWeight: '700',
|
|
670
|
+
},
|
|
671
|
+
});
|