@squad-sports/react-native 1.3.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.
- package/LICENSE +21 -0
- package/README.md +97 -0
- package/package.json +46 -0
- package/src/SquadExperience.tsx +200 -0
- package/src/SquadProvider.tsx +232 -0
- package/src/SquadSportsSDK.ts +286 -0
- package/src/__tests__/DeepLinkHandler.test.ts +101 -0
- package/src/__tests__/ErrorBoundary.test.tsx +161 -0
- package/src/__tests__/EventProcessor.test.ts +241 -0
- package/src/__tests__/PushNotificationHandler.test.ts +91 -0
- package/src/__tests__/SecureStorage.test.ts +62 -0
- package/src/__tests__/SquadSportsSDK.test.ts +278 -0
- package/src/__tests__/VerificationCooldown.test.ts +153 -0
- package/src/components/ErrorBoundary.tsx +129 -0
- package/src/components/SOTD/SOTDComponents.tsx +101 -0
- package/src/components/audio/AudioPlayerRow.tsx +189 -0
- package/src/components/audio/recording/AudioRecording.tsx +232 -0
- package/src/components/communities/CommunityComponents.tsx +78 -0
- package/src/components/dialogs/AllDialogs.tsx +123 -0
- package/src/components/dialogs/ConfirmDialog.tsx +77 -0
- package/src/components/dialogs/PermissionDialog.tsx +132 -0
- package/src/components/dragAndDrop/DragAndDrop.tsx +56 -0
- package/src/components/events/EventComponents.tsx +93 -0
- package/src/components/feed/ChatBannerCard.tsx +94 -0
- package/src/components/feed/FeedLoadingSkeleton.tsx +43 -0
- package/src/components/feed/FreestyleCard.tsx +119 -0
- package/src/components/feed/InterstitialOverlay.tsx +190 -0
- package/src/components/feed/PollCard.tsx +158 -0
- package/src/components/feed/SponsoredContentCard.tsx +118 -0
- package/src/components/freestyle/FreestyleComponents.tsx +148 -0
- package/src/components/index.ts +42 -0
- package/src/components/message/MessageCard.tsx +166 -0
- package/src/components/message/MessageComponents.tsx +143 -0
- package/src/components/poll/PollComponents.tsx +226 -0
- package/src/components/sentinels/Sentinels.tsx +175 -0
- package/src/components/squad/FeedSquad.tsx +54 -0
- package/src/components/toasts/Toasts.tsx +88 -0
- package/src/components/ux/RootUXComponents.tsx +157 -0
- package/src/components/ux/action-sheet/ActionSheet.tsx +67 -0
- package/src/components/ux/bottom-sheet/BottomSheetComponents.tsx +93 -0
- package/src/components/ux/bottom-sheet/SquadBottomSheet.tsx +119 -0
- package/src/components/ux/buttons/Button.tsx +37 -0
- package/src/components/ux/buttons/InfoButton.tsx +24 -0
- package/src/components/ux/buttons/XButton.tsx +27 -0
- package/src/components/ux/carousel/Carousel.tsx +134 -0
- package/src/components/ux/emoji-picker/EmojiReactionPicker.tsx +139 -0
- package/src/components/ux/errors/ErrorHint.tsx +46 -0
- package/src/components/ux/inputs/CodeInput.tsx +121 -0
- package/src/components/ux/inputs/DatePicker.tsx +76 -0
- package/src/components/ux/inputs/MaskedTextInput.tsx +95 -0
- package/src/components/ux/inputs/PhoneNumberInput.tsx +90 -0
- package/src/components/ux/inputs/SearchTextInput.tsx +70 -0
- package/src/components/ux/inputs/TextInput.tsx +58 -0
- package/src/components/ux/layout/AvoidKeyboardScreen.tsx +58 -0
- package/src/components/ux/layout/BlurOverlay.tsx +26 -0
- package/src/components/ux/layout/CrossFade.tsx +30 -0
- package/src/components/ux/layout/DismissKeyboardOnBlur.tsx +14 -0
- package/src/components/ux/layout/LoadingOverlay.tsx +60 -0
- package/src/components/ux/layout/NetworkBanner.tsx +64 -0
- package/src/components/ux/layout/PermissionsCTAContent.tsx +54 -0
- package/src/components/ux/layout/RefreshControl.tsx +7 -0
- package/src/components/ux/layout/Screen.tsx +31 -0
- package/src/components/ux/layout/ScreenHeader.tsx +89 -0
- package/src/components/ux/layout/TabBar.tsx +39 -0
- package/src/components/ux/layout/Toast.tsx +116 -0
- package/src/components/ux/layout/TransparentOverlay.tsx +21 -0
- package/src/components/ux/navigation/BackButton.tsx +29 -0
- package/src/components/ux/navigation/LinkButton.tsx +21 -0
- package/src/components/ux/navigation/UrlButton.tsx +25 -0
- package/src/components/ux/scroll/RefreshableFlatList.tsx +35 -0
- package/src/components/ux/shapes/Shapes.tsx +23 -0
- package/src/components/ux/text/Typography.tsx +28 -0
- package/src/components/ux/user-image/UserImage.tsx +75 -0
- package/src/components/ux/user-image/UserImageVariants.tsx +104 -0
- package/src/components/wallet/WalletComponents.tsx +116 -0
- package/src/contexts/AuthContext.tsx +45 -0
- package/src/contexts/EventProcessorContext.tsx +41 -0
- package/src/contexts/PlayerQueueContext.tsx +95 -0
- package/src/hooks/useAuth.ts +23 -0
- package/src/hooks/useDataRefresh.ts +30 -0
- package/src/hooks/useEventProcessor.ts +6 -0
- package/src/hooks/useImageOptimization.ts +59 -0
- package/src/hooks/useOnboardingStepGuard.ts +36 -0
- package/src/hooks/usePendingNavigation.ts +26 -0
- package/src/hooks/useSquadData.ts +84 -0
- package/src/hooks/useUserCreated.ts +25 -0
- package/src/hooks/useUserUpdate.ts +25 -0
- package/src/hooks/useViewabilityTracker.ts +40 -0
- package/src/index.ts +109 -0
- package/src/navigation/SquadNavigator.tsx +262 -0
- package/src/realtime/DeepLinkHandler.ts +113 -0
- package/src/realtime/EventProcessor.ts +313 -0
- package/src/realtime/NetworkMonitor.ts +84 -0
- package/src/realtime/OfflineQueue.ts +133 -0
- package/src/realtime/PushNotificationHandler.ts +125 -0
- package/src/realtime/useRealtimeSync.ts +84 -0
- package/src/screens/auth/EmailVerificationScreen.tsx +201 -0
- package/src/screens/auth/EnterCodeScreen.tsx +253 -0
- package/src/screens/auth/EnterEmailScreen.tsx +234 -0
- package/src/screens/auth/LandingScreen.tsx +90 -0
- package/src/screens/auth/LoginScreen.tsx +126 -0
- package/src/screens/events/EventScreen.tsx +163 -0
- package/src/screens/freestyle/CommunityFreestyleScreen.tsx +82 -0
- package/src/screens/freestyle/FreestyleCreationScreen.tsx +255 -0
- package/src/screens/freestyle/FreestyleListensScreen.tsx +44 -0
- package/src/screens/freestyle/FreestyleReactionsScreen.tsx +44 -0
- package/src/screens/freestyle/FreestyleScreen.tsx +64 -0
- package/src/screens/home/HomeScreen.tsx +365 -0
- package/src/screens/home/slivers/SquadCircle.tsx +77 -0
- package/src/screens/invite/InvitationQrCodeScreen.tsx +114 -0
- package/src/screens/invite/InviteScreen.tsx +175 -0
- package/src/screens/messaging/MessagingScreen.tsx +360 -0
- package/src/screens/onboarding/OnboardingAccountSetupScreen.tsx +221 -0
- package/src/screens/onboarding/OnboardingTeamSelectScreen.tsx +215 -0
- package/src/screens/onboarding/OnboardingWelcomeScreen.tsx +93 -0
- package/src/screens/polls/PollResponseScreen.tsx +229 -0
- package/src/screens/polls/PollSummationScreen.tsx +78 -0
- package/src/screens/profile/ProfileScreen.tsx +234 -0
- package/src/screens/settings/BlockedUsersScreen.tsx +139 -0
- package/src/screens/settings/DeleteAccountScreen.tsx +182 -0
- package/src/screens/settings/EditProfileScreen.tsx +154 -0
- package/src/screens/settings/NetworkStatusScreen.tsx +59 -0
- package/src/screens/settings/SettingsScreen.tsx +194 -0
- package/src/screens/squad-line/AddCallTitleScreen.tsx +293 -0
- package/src/screens/wallet/WalletScreen.tsx +174 -0
- package/src/services/AuthStateManager.ts +93 -0
- package/src/services/NavigationService.ts +40 -0
- package/src/services/UserDataManager.ts +59 -0
- package/src/services/UserUpdateService.ts +31 -0
- package/src/services/VerificationStateManager.ts +41 -0
- package/src/squad-line/CallScreen.tsx +158 -0
- package/src/squad-line/IncomingCallOverlay.tsx +113 -0
- package/src/squad-line/SquadLineClient.ts +327 -0
- package/src/squad-line/useSquadLine.ts +80 -0
- package/src/state/audio.ts +38 -0
- package/src/state/client.ts +26 -0
- package/src/state/communities.ts +45 -0
- package/src/state/contacts.ts +28 -0
- package/src/state/device-info.ts +22 -0
- package/src/state/events.ts +16 -0
- package/src/state/features.ts +57 -0
- package/src/state/index.ts +121 -0
- package/src/state/invitations.ts +16 -0
- package/src/state/modal-keys.ts +63 -0
- package/src/state/modal-queue.ts +104 -0
- package/src/state/navigation.ts +34 -0
- package/src/state/permissions.ts +43 -0
- package/src/state/session.ts +223 -0
- package/src/state/squaddie-of-the-day.ts +21 -0
- package/src/state/sync/crdt.ts +70 -0
- package/src/state/sync/dependable.ts +213 -0
- package/src/state/sync/feed-v2.ts +42 -0
- package/src/state/sync/messages.ts +44 -0
- package/src/state/sync/offline-support.ts +42 -0
- package/src/state/sync/polls.ts +37 -0
- package/src/state/sync/refresh.ts +24 -0
- package/src/state/sync/squad-v2.ts +25 -0
- package/src/state/ui.ts +36 -0
- package/src/state/user.ts +46 -0
- package/src/state/wallet.ts +26 -0
- package/src/storage/SecureStorage.ts +77 -0
- package/src/theme/ThemeContext.tsx +159 -0
- package/src/types/modules.d.ts +165 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag and drop components for squad circle reordering.
|
|
3
|
+
* Ported from squad-demo/src/components/dragAndDrop/*.
|
|
4
|
+
*/
|
|
5
|
+
import React, { useRef, useState } from 'react';
|
|
6
|
+
import { View, Text, StyleSheet, PanResponder, Animated, Dimensions } from 'react-native';
|
|
7
|
+
import { Colors } from '../../theme/ThemeContext';
|
|
8
|
+
import UserImage from '../ux/user-image/UserImage';
|
|
9
|
+
|
|
10
|
+
interface DraggableItem {
|
|
11
|
+
id: string;
|
|
12
|
+
displayName?: string;
|
|
13
|
+
imageUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// --- DragViewContainer ---
|
|
17
|
+
export function DragViewContainer({
|
|
18
|
+
items, onReorder, renderItem,
|
|
19
|
+
}: { items: DraggableItem[]; onReorder: (items: DraggableItem[]) => void; renderItem: (item: DraggableItem, index: number) => React.ReactNode }) {
|
|
20
|
+
return (
|
|
21
|
+
<View style={styles.container}>
|
|
22
|
+
{items.map((item, index) => (
|
|
23
|
+
<View key={item.id} style={styles.dragItem}>
|
|
24
|
+
{renderItem(item, index)}
|
|
25
|
+
</View>
|
|
26
|
+
))}
|
|
27
|
+
</View>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- ProfilePlus (add button in drag grid) ---
|
|
32
|
+
export function ProfilePlus({ onPress, color = Colors.purple1 }: { onPress: () => void; color?: string }) {
|
|
33
|
+
return (
|
|
34
|
+
<View style={[styles.profilePlus, { borderColor: color }]}>
|
|
35
|
+
<Text style={[styles.profilePlusIcon, { color }]}>+</Text>
|
|
36
|
+
</View>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// --- DragViewWarning ---
|
|
41
|
+
export function DragViewWarning({ message }: { message: string }) {
|
|
42
|
+
return (
|
|
43
|
+
<View style={styles.warning}>
|
|
44
|
+
<Text style={styles.warningText}>{message}</Text>
|
|
45
|
+
</View>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const styles = StyleSheet.create({
|
|
50
|
+
container: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'center', gap: 12, padding: 16 },
|
|
51
|
+
dragItem: { position: 'relative' },
|
|
52
|
+
profilePlus: { width: 56, height: 56, borderRadius: 28, borderWidth: 2, borderStyle: 'dashed', justifyContent: 'center', alignItems: 'center' },
|
|
53
|
+
profilePlusIcon: { fontSize: 24, fontWeight: '300' },
|
|
54
|
+
warning: { padding: 12, backgroundColor: 'rgba(233,120,92,0.14)', borderRadius: 8, marginHorizontal: 16 },
|
|
55
|
+
warningText: { color: Colors.orange1, fontSize: 13, textAlign: 'center' },
|
|
56
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event components.
|
|
3
|
+
* Ported from squad-demo/src/components/events/*.
|
|
4
|
+
*/
|
|
5
|
+
import React, { memo } from 'react';
|
|
6
|
+
import { View, Text, StyleSheet, Pressable, FlatList } from 'react-native';
|
|
7
|
+
import { Colors } from '../../theme/ThemeContext';
|
|
8
|
+
import UserImage from '../ux/user-image/UserImage';
|
|
9
|
+
import { TitleSmall, BodyRegular, BodyMedium, BodySmall } from '../ux/text/Typography';
|
|
10
|
+
import Button from '../ux/buttons/Button';
|
|
11
|
+
|
|
12
|
+
// --- EventCard ---
|
|
13
|
+
export const EventCard = memo(function EventCard({
|
|
14
|
+
id, title, date, location, attendeeCount, isAttending, imageUrl,
|
|
15
|
+
onPress, onToggleAttend, primaryColor = Colors.purple1,
|
|
16
|
+
}: {
|
|
17
|
+
id: string; title: string; date?: string; location?: string;
|
|
18
|
+
attendeeCount: number; isAttending: boolean; imageUrl?: string;
|
|
19
|
+
onPress?: () => void; onToggleAttend?: () => void; primaryColor?: string;
|
|
20
|
+
}) {
|
|
21
|
+
return (
|
|
22
|
+
<Pressable style={styles.card} onPress={onPress}>
|
|
23
|
+
{imageUrl && <View style={styles.cardImage}><BodySmall style={styles.cardImageText}>Event</BodySmall></View>}
|
|
24
|
+
<View style={styles.cardContent}>
|
|
25
|
+
<TitleSmall style={styles.cardTitle}>{title}</TitleSmall>
|
|
26
|
+
{date && <BodyMedium style={[styles.cardDate, { color: primaryColor }]}>{date}</BodyMedium>}
|
|
27
|
+
{location && <BodySmall style={styles.cardLocation}>{location}</BodySmall>}
|
|
28
|
+
<View style={styles.cardFooter}>
|
|
29
|
+
<BodySmall style={styles.attendeeCount}>{attendeeCount} attending</BodySmall>
|
|
30
|
+
<Button
|
|
31
|
+
style={[styles.attendBtn, isAttending ? styles.attendBtnActive : { backgroundColor: primaryColor }]}
|
|
32
|
+
onPress={onToggleAttend}
|
|
33
|
+
>
|
|
34
|
+
<Text style={[styles.attendBtnText, isAttending && styles.attendBtnTextActive]}>
|
|
35
|
+
{isAttending ? 'Going' : 'Attend'}
|
|
36
|
+
</Text>
|
|
37
|
+
</Button>
|
|
38
|
+
</View>
|
|
39
|
+
</View>
|
|
40
|
+
</Pressable>
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// --- EventsHeader ---
|
|
45
|
+
export function EventsHeader({ title = 'Events' }: { title?: string }) {
|
|
46
|
+
return (
|
|
47
|
+
<View style={styles.header}>
|
|
48
|
+
<TitleSmall style={styles.headerTitle}>{title}</TitleSmall>
|
|
49
|
+
</View>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// --- EventsAttendeesBottomSheet ---
|
|
54
|
+
export function EventsAttendeesBottomSheet({
|
|
55
|
+
attendees, title = 'Attendees',
|
|
56
|
+
}: { attendees: Array<{ id: string; name: string; imageUrl?: string }>; title?: string }) {
|
|
57
|
+
return (
|
|
58
|
+
<View>
|
|
59
|
+
<TitleSmall style={styles.attendeesTitle}>{title} ({attendees.length})</TitleSmall>
|
|
60
|
+
<FlatList
|
|
61
|
+
data={attendees}
|
|
62
|
+
keyExtractor={item => item.id}
|
|
63
|
+
renderItem={({ item }) => (
|
|
64
|
+
<View style={styles.attendeeRow}>
|
|
65
|
+
<UserImage imageUrl={item.imageUrl} displayName={item.name} size={40} />
|
|
66
|
+
<BodyRegular style={styles.attendeeName}>{item.name}</BodyRegular>
|
|
67
|
+
</View>
|
|
68
|
+
)}
|
|
69
|
+
/>
|
|
70
|
+
</View>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const styles = StyleSheet.create({
|
|
75
|
+
card: { backgroundColor: Colors.gray2, borderRadius: 16, overflow: 'hidden', marginBottom: 16 },
|
|
76
|
+
cardImage: { height: 140, backgroundColor: Colors.gray3, justifyContent: 'center', alignItems: 'center' },
|
|
77
|
+
cardImageText: { color: Colors.gray6 },
|
|
78
|
+
cardContent: { padding: 16 },
|
|
79
|
+
cardTitle: { color: Colors.white, marginBottom: 4 },
|
|
80
|
+
cardDate: { marginBottom: 2 },
|
|
81
|
+
cardLocation: { color: Colors.gray6, marginBottom: 12 },
|
|
82
|
+
cardFooter: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' },
|
|
83
|
+
attendeeCount: { color: Colors.gray6 },
|
|
84
|
+
attendBtn: { paddingVertical: 8, paddingHorizontal: 20, borderRadius: 16 },
|
|
85
|
+
attendBtnActive: { backgroundColor: 'transparent', borderWidth: 1, borderColor: Colors.green },
|
|
86
|
+
attendBtnText: { color: Colors.gray1, fontSize: 13, fontWeight: '600' },
|
|
87
|
+
attendBtnTextActive: { color: Colors.green },
|
|
88
|
+
header: { paddingHorizontal: 24, paddingVertical: 12 },
|
|
89
|
+
headerTitle: { color: Colors.white },
|
|
90
|
+
attendeesTitle: { color: Colors.white, paddingHorizontal: 16, paddingVertical: 12 },
|
|
91
|
+
attendeeRow: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingVertical: 8, paddingHorizontal: 16, borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: Colors.gray3 },
|
|
92
|
+
attendeeName: { color: Colors.white },
|
|
93
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { memo, useEffect, useRef } from 'react';
|
|
2
|
+
import { View, Text, StyleSheet, Pressable, Linking } from 'react-native';
|
|
3
|
+
import { Colors } from '../../theme/ThemeContext';
|
|
4
|
+
import UserImage from '../ux/user-image/UserImage';
|
|
5
|
+
import { BodySmall } from '../ux/text/Typography';
|
|
6
|
+
|
|
7
|
+
interface ChatBannerCardProps {
|
|
8
|
+
placementId: string;
|
|
9
|
+
brandName: string;
|
|
10
|
+
brandImageUrl?: string;
|
|
11
|
+
headline: string;
|
|
12
|
+
ctaText?: string;
|
|
13
|
+
ctaUrl?: string;
|
|
14
|
+
onImpression?: (placementId: string, durationMs: number) => void;
|
|
15
|
+
onCtaPress?: (placementId: string) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function ChatBannerCard({
|
|
19
|
+
placementId,
|
|
20
|
+
brandName,
|
|
21
|
+
brandImageUrl,
|
|
22
|
+
headline,
|
|
23
|
+
ctaText,
|
|
24
|
+
ctaUrl,
|
|
25
|
+
onImpression,
|
|
26
|
+
onCtaPress,
|
|
27
|
+
}: ChatBannerCardProps) {
|
|
28
|
+
const viewStartRef = useRef<number>(Date.now());
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
viewStartRef.current = Date.now();
|
|
32
|
+
const timer = setTimeout(() => {
|
|
33
|
+
const duration = Date.now() - viewStartRef.current;
|
|
34
|
+
onImpression?.(placementId, duration);
|
|
35
|
+
}, 5000); // 5 second threshold for chat banners
|
|
36
|
+
|
|
37
|
+
return () => clearTimeout(timer);
|
|
38
|
+
}, [placementId, onImpression]);
|
|
39
|
+
|
|
40
|
+
const handlePress = () => {
|
|
41
|
+
onCtaPress?.(placementId);
|
|
42
|
+
if (ctaUrl) {
|
|
43
|
+
Linking.openURL(ctaUrl).catch(() => {});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Pressable style={styles.banner} onPress={handlePress}>
|
|
49
|
+
<UserImage imageUrl={brandImageUrl} displayName={brandName} size={28} />
|
|
50
|
+
<View style={styles.content}>
|
|
51
|
+
<BodySmall style={styles.headline} numberOfLines={1}>{headline}</BodySmall>
|
|
52
|
+
</View>
|
|
53
|
+
{ctaText && (
|
|
54
|
+
<View style={styles.ctaBadge}>
|
|
55
|
+
<Text style={styles.ctaText}>{ctaText}</Text>
|
|
56
|
+
</View>
|
|
57
|
+
)}
|
|
58
|
+
</Pressable>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default memo(ChatBannerCard);
|
|
63
|
+
|
|
64
|
+
const styles = StyleSheet.create({
|
|
65
|
+
banner: {
|
|
66
|
+
flexDirection: 'row',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
backgroundColor: Colors.gray2,
|
|
69
|
+
borderRadius: 12,
|
|
70
|
+
paddingVertical: 10,
|
|
71
|
+
paddingHorizontal: 14,
|
|
72
|
+
marginHorizontal: 16,
|
|
73
|
+
marginBottom: 8,
|
|
74
|
+
gap: 10,
|
|
75
|
+
},
|
|
76
|
+
content: {
|
|
77
|
+
flex: 1,
|
|
78
|
+
},
|
|
79
|
+
headline: {
|
|
80
|
+
color: Colors.white,
|
|
81
|
+
fontWeight: '500',
|
|
82
|
+
},
|
|
83
|
+
ctaBadge: {
|
|
84
|
+
backgroundColor: Colors.gray3,
|
|
85
|
+
borderRadius: 6,
|
|
86
|
+
paddingVertical: 6,
|
|
87
|
+
paddingHorizontal: 12,
|
|
88
|
+
},
|
|
89
|
+
ctaText: {
|
|
90
|
+
color: Colors.white,
|
|
91
|
+
fontSize: 12,
|
|
92
|
+
fontWeight: '600',
|
|
93
|
+
},
|
|
94
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feed loading skeleton.
|
|
3
|
+
* Ported from squad-demo/src/components/feed/FeedLoadingSkeleton.tsx.
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { View, StyleSheet, Animated } from 'react-native';
|
|
7
|
+
import { Colors } from '../../theme/ThemeContext';
|
|
8
|
+
|
|
9
|
+
function SkeletonBar({ width, height = 12, marginBottom = 8 }: { width: string | number; height?: number; marginBottom?: number }) {
|
|
10
|
+
return <View style={[styles.bar, { width: width as any, height, marginBottom }]} />;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function FeedLoadingSkeleton({ count = 3 }: { count?: number }) {
|
|
14
|
+
return (
|
|
15
|
+
<View style={styles.container}>
|
|
16
|
+
{Array.from({ length: count }, (_, i) => (
|
|
17
|
+
<View key={i} style={styles.card}>
|
|
18
|
+
<View style={styles.header}>
|
|
19
|
+
<View style={styles.avatar} />
|
|
20
|
+
<View>
|
|
21
|
+
<SkeletonBar width={100} height={14} />
|
|
22
|
+
<SkeletonBar width={60} height={10} />
|
|
23
|
+
</View>
|
|
24
|
+
</View>
|
|
25
|
+
<SkeletonBar width="100%" height={48} marginBottom={12} />
|
|
26
|
+
<View style={styles.footer}>
|
|
27
|
+
<SkeletonBar width={60} height={10} />
|
|
28
|
+
<SkeletonBar width={60} height={10} />
|
|
29
|
+
</View>
|
|
30
|
+
</View>
|
|
31
|
+
))}
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const styles = StyleSheet.create({
|
|
37
|
+
container: { paddingHorizontal: 24, gap: 12 },
|
|
38
|
+
card: { backgroundColor: Colors.gray2, borderRadius: 16, padding: 16 },
|
|
39
|
+
header: { flexDirection: 'row', alignItems: 'center', gap: 10, marginBottom: 12 },
|
|
40
|
+
avatar: { width: 40, height: 40, borderRadius: 20, backgroundColor: Colors.gray3 },
|
|
41
|
+
bar: { backgroundColor: Colors.gray3, borderRadius: 4 },
|
|
42
|
+
footer: { flexDirection: 'row', gap: 16, paddingTop: 12, borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: Colors.gray3 },
|
|
43
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React, { memo, useCallback, useState } from 'react';
|
|
2
|
+
import { View, Text, StyleSheet, Pressable } from 'react-native';
|
|
3
|
+
import { Colors } from '../../theme/ThemeContext';
|
|
4
|
+
import UserImage from '../ux/user-image/UserImage';
|
|
5
|
+
import { AudioPlayerRow } from '../audio/AudioPlayerRow';
|
|
6
|
+
import { BodyRegular, BodySmall, SubtitleSmall } from '../ux/text/Typography';
|
|
7
|
+
|
|
8
|
+
interface FreestyleCardProps {
|
|
9
|
+
id: string;
|
|
10
|
+
audioUrl?: string;
|
|
11
|
+
duration?: number;
|
|
12
|
+
creatorName?: string;
|
|
13
|
+
creatorImageUrl?: string;
|
|
14
|
+
createdAt?: string;
|
|
15
|
+
listenCount?: number;
|
|
16
|
+
reactionCount?: number;
|
|
17
|
+
prompt?: string;
|
|
18
|
+
onPress?: () => void;
|
|
19
|
+
onReact?: (emoji: string) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function FreestyleCard({
|
|
23
|
+
id,
|
|
24
|
+
audioUrl,
|
|
25
|
+
duration,
|
|
26
|
+
creatorName,
|
|
27
|
+
creatorImageUrl,
|
|
28
|
+
createdAt,
|
|
29
|
+
listenCount,
|
|
30
|
+
reactionCount,
|
|
31
|
+
prompt,
|
|
32
|
+
onPress,
|
|
33
|
+
onReact,
|
|
34
|
+
}: FreestyleCardProps) {
|
|
35
|
+
const formatTime = (date?: string) => {
|
|
36
|
+
if (!date) return '';
|
|
37
|
+
const d = new Date(date);
|
|
38
|
+
const now = new Date();
|
|
39
|
+
const diffMs = now.getTime() - d.getTime();
|
|
40
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
41
|
+
if (diffMins < 60) return `${diffMins}m`;
|
|
42
|
+
const diffHours = Math.floor(diffMins / 60);
|
|
43
|
+
if (diffHours < 24) return `${diffHours}h`;
|
|
44
|
+
return `${Math.floor(diffHours / 24)}d`;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Pressable style={styles.card} onPress={onPress}>
|
|
49
|
+
<View style={styles.header}>
|
|
50
|
+
<UserImage imageUrl={creatorImageUrl} displayName={creatorName} size={40} />
|
|
51
|
+
<View style={styles.headerText}>
|
|
52
|
+
<SubtitleSmall style={styles.creatorName}>{creatorName}</SubtitleSmall>
|
|
53
|
+
<BodySmall style={styles.timestamp}>{formatTime(createdAt)}</BodySmall>
|
|
54
|
+
</View>
|
|
55
|
+
</View>
|
|
56
|
+
|
|
57
|
+
{prompt && (
|
|
58
|
+
<BodyRegular style={styles.prompt}>{prompt}</BodyRegular>
|
|
59
|
+
)}
|
|
60
|
+
|
|
61
|
+
{audioUrl && (
|
|
62
|
+
<AudioPlayerRow audioUrl={audioUrl} duration={duration} />
|
|
63
|
+
)}
|
|
64
|
+
|
|
65
|
+
<View style={styles.footer}>
|
|
66
|
+
<Pressable style={styles.stat} onPress={() => onReact?.('fire')}>
|
|
67
|
+
<Text style={styles.statIcon}>{'fire'}</Text>
|
|
68
|
+
<BodySmall style={styles.statText}>{reactionCount ?? 0}</BodySmall>
|
|
69
|
+
</Pressable>
|
|
70
|
+
<View style={styles.stat}>
|
|
71
|
+
<Text style={styles.statIcon}>{'ear'}</Text>
|
|
72
|
+
<BodySmall style={styles.statText}>{listenCount ?? 0}</BodySmall>
|
|
73
|
+
</View>
|
|
74
|
+
</View>
|
|
75
|
+
</Pressable>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default memo(FreestyleCard);
|
|
80
|
+
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
card: {
|
|
83
|
+
backgroundColor: Colors.gray2,
|
|
84
|
+
borderRadius: 16,
|
|
85
|
+
padding: 16,
|
|
86
|
+
marginBottom: 12,
|
|
87
|
+
},
|
|
88
|
+
header: {
|
|
89
|
+
flexDirection: 'row',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
marginBottom: 12,
|
|
92
|
+
},
|
|
93
|
+
headerText: {
|
|
94
|
+
marginLeft: 10,
|
|
95
|
+
flex: 1,
|
|
96
|
+
},
|
|
97
|
+
creatorName: { color: Colors.white },
|
|
98
|
+
timestamp: { color: Colors.gray6 },
|
|
99
|
+
prompt: {
|
|
100
|
+
color: Colors.gray8,
|
|
101
|
+
marginBottom: 12,
|
|
102
|
+
fontStyle: 'italic',
|
|
103
|
+
},
|
|
104
|
+
footer: {
|
|
105
|
+
flexDirection: 'row',
|
|
106
|
+
gap: 16,
|
|
107
|
+
marginTop: 12,
|
|
108
|
+
paddingTop: 12,
|
|
109
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
110
|
+
borderTopColor: Colors.gray3,
|
|
111
|
+
},
|
|
112
|
+
stat: {
|
|
113
|
+
flexDirection: 'row',
|
|
114
|
+
alignItems: 'center',
|
|
115
|
+
gap: 4,
|
|
116
|
+
},
|
|
117
|
+
statIcon: { color: Colors.gray6, fontSize: 14 },
|
|
118
|
+
statText: { color: Colors.gray6 },
|
|
119
|
+
});
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import React, { memo, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { View, Text, StyleSheet, Pressable, Linking, Modal, Dimensions } from 'react-native';
|
|
3
|
+
import { Colors } from '../../theme/ThemeContext';
|
|
4
|
+
import UserImage from '../ux/user-image/UserImage';
|
|
5
|
+
import { BodyRegular, BodySmall, SubtitleSmall, TitleMedium } from '../ux/text/Typography';
|
|
6
|
+
|
|
7
|
+
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window');
|
|
8
|
+
const AUTO_DISMISS_MS = 5000;
|
|
9
|
+
|
|
10
|
+
interface InterstitialOverlayProps {
|
|
11
|
+
placementId: string;
|
|
12
|
+
brandName: string;
|
|
13
|
+
brandImageUrl?: string;
|
|
14
|
+
headline: string;
|
|
15
|
+
bodyText?: string;
|
|
16
|
+
imageUrl?: string;
|
|
17
|
+
ctaText?: string;
|
|
18
|
+
ctaUrl?: string;
|
|
19
|
+
onImpression?: (placementId: string, durationMs: number) => void;
|
|
20
|
+
onCtaPress?: (placementId: string) => void;
|
|
21
|
+
onDismiss?: (placementId: string) => void;
|
|
22
|
+
visible: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function InterstitialOverlay({
|
|
26
|
+
placementId,
|
|
27
|
+
brandName,
|
|
28
|
+
brandImageUrl,
|
|
29
|
+
headline,
|
|
30
|
+
bodyText,
|
|
31
|
+
ctaText,
|
|
32
|
+
ctaUrl,
|
|
33
|
+
onImpression,
|
|
34
|
+
onCtaPress,
|
|
35
|
+
onDismiss,
|
|
36
|
+
visible,
|
|
37
|
+
}: InterstitialOverlayProps) {
|
|
38
|
+
const viewStartRef = useRef<number>(0);
|
|
39
|
+
const [countdown, setCountdown] = useState(5);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!visible) return;
|
|
43
|
+
|
|
44
|
+
viewStartRef.current = Date.now();
|
|
45
|
+
setCountdown(5);
|
|
46
|
+
|
|
47
|
+
// Impression after 1 second
|
|
48
|
+
const impressionTimer = setTimeout(() => {
|
|
49
|
+
onImpression?.(placementId, 1000);
|
|
50
|
+
}, 1000);
|
|
51
|
+
|
|
52
|
+
// Countdown ticker
|
|
53
|
+
const tickInterval = setInterval(() => {
|
|
54
|
+
setCountdown(prev => {
|
|
55
|
+
if (prev <= 1) {
|
|
56
|
+
clearInterval(tickInterval);
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
return prev - 1;
|
|
60
|
+
});
|
|
61
|
+
}, 1000);
|
|
62
|
+
|
|
63
|
+
// Auto-dismiss after 5 seconds
|
|
64
|
+
const dismissTimer = setTimeout(() => {
|
|
65
|
+
onDismiss?.(placementId);
|
|
66
|
+
}, AUTO_DISMISS_MS);
|
|
67
|
+
|
|
68
|
+
return () => {
|
|
69
|
+
clearTimeout(impressionTimer);
|
|
70
|
+
clearInterval(tickInterval);
|
|
71
|
+
clearTimeout(dismissTimer);
|
|
72
|
+
};
|
|
73
|
+
}, [visible, placementId, onImpression, onDismiss]);
|
|
74
|
+
|
|
75
|
+
const handleCtaPress = () => {
|
|
76
|
+
onCtaPress?.(placementId);
|
|
77
|
+
if (ctaUrl) {
|
|
78
|
+
Linking.openURL(ctaUrl).catch(() => {});
|
|
79
|
+
}
|
|
80
|
+
onDismiss?.(placementId);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleDismiss = () => {
|
|
84
|
+
onDismiss?.(placementId);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Modal visible={visible} transparent animationType="fade">
|
|
89
|
+
<View style={styles.overlay}>
|
|
90
|
+
<View style={styles.card}>
|
|
91
|
+
{/* Dismiss button */}
|
|
92
|
+
<Pressable style={styles.dismissButton} onPress={handleDismiss}>
|
|
93
|
+
<Text style={styles.dismissText}>
|
|
94
|
+
{countdown > 0 ? String(countdown) : 'X'}
|
|
95
|
+
</Text>
|
|
96
|
+
</Pressable>
|
|
97
|
+
|
|
98
|
+
{/* Brand header */}
|
|
99
|
+
<View style={styles.brandRow}>
|
|
100
|
+
<UserImage imageUrl={brandImageUrl} displayName={brandName} size={32} />
|
|
101
|
+
<BodySmall style={styles.brandName}>{brandName}</BodySmall>
|
|
102
|
+
</View>
|
|
103
|
+
|
|
104
|
+
{/* Content */}
|
|
105
|
+
<TitleMedium style={styles.headline}>{headline}</TitleMedium>
|
|
106
|
+
|
|
107
|
+
{bodyText && (
|
|
108
|
+
<BodyRegular style={styles.bodyText}>{bodyText}</BodyRegular>
|
|
109
|
+
)}
|
|
110
|
+
|
|
111
|
+
{/* CTA */}
|
|
112
|
+
{ctaText && (
|
|
113
|
+
<Pressable style={styles.ctaButton} onPress={handleCtaPress}>
|
|
114
|
+
<Text style={styles.ctaText}>{ctaText}</Text>
|
|
115
|
+
</Pressable>
|
|
116
|
+
)}
|
|
117
|
+
</View>
|
|
118
|
+
</View>
|
|
119
|
+
</Modal>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default memo(InterstitialOverlay);
|
|
124
|
+
|
|
125
|
+
const styles = StyleSheet.create({
|
|
126
|
+
overlay: {
|
|
127
|
+
flex: 1,
|
|
128
|
+
backgroundColor: 'rgba(0, 0, 0, 0.85)',
|
|
129
|
+
justifyContent: 'center',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
padding: 32,
|
|
132
|
+
},
|
|
133
|
+
card: {
|
|
134
|
+
backgroundColor: Colors.gray2,
|
|
135
|
+
borderRadius: 20,
|
|
136
|
+
padding: 28,
|
|
137
|
+
width: SCREEN_WIDTH - 64,
|
|
138
|
+
maxHeight: SCREEN_HEIGHT * 0.7,
|
|
139
|
+
alignItems: 'center',
|
|
140
|
+
},
|
|
141
|
+
dismissButton: {
|
|
142
|
+
position: 'absolute',
|
|
143
|
+
top: 16,
|
|
144
|
+
right: 16,
|
|
145
|
+
width: 32,
|
|
146
|
+
height: 32,
|
|
147
|
+
borderRadius: 16,
|
|
148
|
+
backgroundColor: Colors.gray3,
|
|
149
|
+
justifyContent: 'center',
|
|
150
|
+
alignItems: 'center',
|
|
151
|
+
zIndex: 1,
|
|
152
|
+
},
|
|
153
|
+
dismissText: {
|
|
154
|
+
color: Colors.white,
|
|
155
|
+
fontSize: 14,
|
|
156
|
+
fontWeight: '600',
|
|
157
|
+
},
|
|
158
|
+
brandRow: {
|
|
159
|
+
flexDirection: 'row',
|
|
160
|
+
alignItems: 'center',
|
|
161
|
+
gap: 10,
|
|
162
|
+
marginBottom: 20,
|
|
163
|
+
marginTop: 8,
|
|
164
|
+
},
|
|
165
|
+
brandName: {
|
|
166
|
+
color: Colors.gray6,
|
|
167
|
+
},
|
|
168
|
+
headline: {
|
|
169
|
+
color: Colors.white,
|
|
170
|
+
textAlign: 'center',
|
|
171
|
+
marginBottom: 12,
|
|
172
|
+
},
|
|
173
|
+
bodyText: {
|
|
174
|
+
color: Colors.gray8,
|
|
175
|
+
textAlign: 'center',
|
|
176
|
+
marginBottom: 20,
|
|
177
|
+
},
|
|
178
|
+
ctaButton: {
|
|
179
|
+
backgroundColor: '#6E82E7',
|
|
180
|
+
borderRadius: 10,
|
|
181
|
+
paddingVertical: 14,
|
|
182
|
+
paddingHorizontal: 32,
|
|
183
|
+
marginTop: 8,
|
|
184
|
+
},
|
|
185
|
+
ctaText: {
|
|
186
|
+
color: Colors.white,
|
|
187
|
+
fontSize: 16,
|
|
188
|
+
fontWeight: '600',
|
|
189
|
+
},
|
|
190
|
+
});
|