@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.
Files changed (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -0
  3. package/package.json +46 -0
  4. package/src/SquadExperience.tsx +200 -0
  5. package/src/SquadProvider.tsx +232 -0
  6. package/src/SquadSportsSDK.ts +286 -0
  7. package/src/__tests__/DeepLinkHandler.test.ts +101 -0
  8. package/src/__tests__/ErrorBoundary.test.tsx +161 -0
  9. package/src/__tests__/EventProcessor.test.ts +241 -0
  10. package/src/__tests__/PushNotificationHandler.test.ts +91 -0
  11. package/src/__tests__/SecureStorage.test.ts +62 -0
  12. package/src/__tests__/SquadSportsSDK.test.ts +278 -0
  13. package/src/__tests__/VerificationCooldown.test.ts +153 -0
  14. package/src/components/ErrorBoundary.tsx +129 -0
  15. package/src/components/SOTD/SOTDComponents.tsx +101 -0
  16. package/src/components/audio/AudioPlayerRow.tsx +189 -0
  17. package/src/components/audio/recording/AudioRecording.tsx +232 -0
  18. package/src/components/communities/CommunityComponents.tsx +78 -0
  19. package/src/components/dialogs/AllDialogs.tsx +123 -0
  20. package/src/components/dialogs/ConfirmDialog.tsx +77 -0
  21. package/src/components/dialogs/PermissionDialog.tsx +132 -0
  22. package/src/components/dragAndDrop/DragAndDrop.tsx +56 -0
  23. package/src/components/events/EventComponents.tsx +93 -0
  24. package/src/components/feed/ChatBannerCard.tsx +94 -0
  25. package/src/components/feed/FeedLoadingSkeleton.tsx +43 -0
  26. package/src/components/feed/FreestyleCard.tsx +119 -0
  27. package/src/components/feed/InterstitialOverlay.tsx +190 -0
  28. package/src/components/feed/PollCard.tsx +158 -0
  29. package/src/components/feed/SponsoredContentCard.tsx +118 -0
  30. package/src/components/freestyle/FreestyleComponents.tsx +148 -0
  31. package/src/components/index.ts +42 -0
  32. package/src/components/message/MessageCard.tsx +166 -0
  33. package/src/components/message/MessageComponents.tsx +143 -0
  34. package/src/components/poll/PollComponents.tsx +226 -0
  35. package/src/components/sentinels/Sentinels.tsx +175 -0
  36. package/src/components/squad/FeedSquad.tsx +54 -0
  37. package/src/components/toasts/Toasts.tsx +88 -0
  38. package/src/components/ux/RootUXComponents.tsx +157 -0
  39. package/src/components/ux/action-sheet/ActionSheet.tsx +67 -0
  40. package/src/components/ux/bottom-sheet/BottomSheetComponents.tsx +93 -0
  41. package/src/components/ux/bottom-sheet/SquadBottomSheet.tsx +119 -0
  42. package/src/components/ux/buttons/Button.tsx +37 -0
  43. package/src/components/ux/buttons/InfoButton.tsx +24 -0
  44. package/src/components/ux/buttons/XButton.tsx +27 -0
  45. package/src/components/ux/carousel/Carousel.tsx +134 -0
  46. package/src/components/ux/emoji-picker/EmojiReactionPicker.tsx +139 -0
  47. package/src/components/ux/errors/ErrorHint.tsx +46 -0
  48. package/src/components/ux/inputs/CodeInput.tsx +121 -0
  49. package/src/components/ux/inputs/DatePicker.tsx +76 -0
  50. package/src/components/ux/inputs/MaskedTextInput.tsx +95 -0
  51. package/src/components/ux/inputs/PhoneNumberInput.tsx +90 -0
  52. package/src/components/ux/inputs/SearchTextInput.tsx +70 -0
  53. package/src/components/ux/inputs/TextInput.tsx +58 -0
  54. package/src/components/ux/layout/AvoidKeyboardScreen.tsx +58 -0
  55. package/src/components/ux/layout/BlurOverlay.tsx +26 -0
  56. package/src/components/ux/layout/CrossFade.tsx +30 -0
  57. package/src/components/ux/layout/DismissKeyboardOnBlur.tsx +14 -0
  58. package/src/components/ux/layout/LoadingOverlay.tsx +60 -0
  59. package/src/components/ux/layout/NetworkBanner.tsx +64 -0
  60. package/src/components/ux/layout/PermissionsCTAContent.tsx +54 -0
  61. package/src/components/ux/layout/RefreshControl.tsx +7 -0
  62. package/src/components/ux/layout/Screen.tsx +31 -0
  63. package/src/components/ux/layout/ScreenHeader.tsx +89 -0
  64. package/src/components/ux/layout/TabBar.tsx +39 -0
  65. package/src/components/ux/layout/Toast.tsx +116 -0
  66. package/src/components/ux/layout/TransparentOverlay.tsx +21 -0
  67. package/src/components/ux/navigation/BackButton.tsx +29 -0
  68. package/src/components/ux/navigation/LinkButton.tsx +21 -0
  69. package/src/components/ux/navigation/UrlButton.tsx +25 -0
  70. package/src/components/ux/scroll/RefreshableFlatList.tsx +35 -0
  71. package/src/components/ux/shapes/Shapes.tsx +23 -0
  72. package/src/components/ux/text/Typography.tsx +28 -0
  73. package/src/components/ux/user-image/UserImage.tsx +75 -0
  74. package/src/components/ux/user-image/UserImageVariants.tsx +104 -0
  75. package/src/components/wallet/WalletComponents.tsx +116 -0
  76. package/src/contexts/AuthContext.tsx +45 -0
  77. package/src/contexts/EventProcessorContext.tsx +41 -0
  78. package/src/contexts/PlayerQueueContext.tsx +95 -0
  79. package/src/hooks/useAuth.ts +23 -0
  80. package/src/hooks/useDataRefresh.ts +30 -0
  81. package/src/hooks/useEventProcessor.ts +6 -0
  82. package/src/hooks/useImageOptimization.ts +59 -0
  83. package/src/hooks/useOnboardingStepGuard.ts +36 -0
  84. package/src/hooks/usePendingNavigation.ts +26 -0
  85. package/src/hooks/useSquadData.ts +84 -0
  86. package/src/hooks/useUserCreated.ts +25 -0
  87. package/src/hooks/useUserUpdate.ts +25 -0
  88. package/src/hooks/useViewabilityTracker.ts +40 -0
  89. package/src/index.ts +109 -0
  90. package/src/navigation/SquadNavigator.tsx +262 -0
  91. package/src/realtime/DeepLinkHandler.ts +113 -0
  92. package/src/realtime/EventProcessor.ts +313 -0
  93. package/src/realtime/NetworkMonitor.ts +84 -0
  94. package/src/realtime/OfflineQueue.ts +133 -0
  95. package/src/realtime/PushNotificationHandler.ts +125 -0
  96. package/src/realtime/useRealtimeSync.ts +84 -0
  97. package/src/screens/auth/EmailVerificationScreen.tsx +201 -0
  98. package/src/screens/auth/EnterCodeScreen.tsx +253 -0
  99. package/src/screens/auth/EnterEmailScreen.tsx +234 -0
  100. package/src/screens/auth/LandingScreen.tsx +90 -0
  101. package/src/screens/auth/LoginScreen.tsx +126 -0
  102. package/src/screens/events/EventScreen.tsx +163 -0
  103. package/src/screens/freestyle/CommunityFreestyleScreen.tsx +82 -0
  104. package/src/screens/freestyle/FreestyleCreationScreen.tsx +255 -0
  105. package/src/screens/freestyle/FreestyleListensScreen.tsx +44 -0
  106. package/src/screens/freestyle/FreestyleReactionsScreen.tsx +44 -0
  107. package/src/screens/freestyle/FreestyleScreen.tsx +64 -0
  108. package/src/screens/home/HomeScreen.tsx +365 -0
  109. package/src/screens/home/slivers/SquadCircle.tsx +77 -0
  110. package/src/screens/invite/InvitationQrCodeScreen.tsx +114 -0
  111. package/src/screens/invite/InviteScreen.tsx +175 -0
  112. package/src/screens/messaging/MessagingScreen.tsx +360 -0
  113. package/src/screens/onboarding/OnboardingAccountSetupScreen.tsx +221 -0
  114. package/src/screens/onboarding/OnboardingTeamSelectScreen.tsx +215 -0
  115. package/src/screens/onboarding/OnboardingWelcomeScreen.tsx +93 -0
  116. package/src/screens/polls/PollResponseScreen.tsx +229 -0
  117. package/src/screens/polls/PollSummationScreen.tsx +78 -0
  118. package/src/screens/profile/ProfileScreen.tsx +234 -0
  119. package/src/screens/settings/BlockedUsersScreen.tsx +139 -0
  120. package/src/screens/settings/DeleteAccountScreen.tsx +182 -0
  121. package/src/screens/settings/EditProfileScreen.tsx +154 -0
  122. package/src/screens/settings/NetworkStatusScreen.tsx +59 -0
  123. package/src/screens/settings/SettingsScreen.tsx +194 -0
  124. package/src/screens/squad-line/AddCallTitleScreen.tsx +293 -0
  125. package/src/screens/wallet/WalletScreen.tsx +174 -0
  126. package/src/services/AuthStateManager.ts +93 -0
  127. package/src/services/NavigationService.ts +40 -0
  128. package/src/services/UserDataManager.ts +59 -0
  129. package/src/services/UserUpdateService.ts +31 -0
  130. package/src/services/VerificationStateManager.ts +41 -0
  131. package/src/squad-line/CallScreen.tsx +158 -0
  132. package/src/squad-line/IncomingCallOverlay.tsx +113 -0
  133. package/src/squad-line/SquadLineClient.ts +327 -0
  134. package/src/squad-line/useSquadLine.ts +80 -0
  135. package/src/state/audio.ts +38 -0
  136. package/src/state/client.ts +26 -0
  137. package/src/state/communities.ts +45 -0
  138. package/src/state/contacts.ts +28 -0
  139. package/src/state/device-info.ts +22 -0
  140. package/src/state/events.ts +16 -0
  141. package/src/state/features.ts +57 -0
  142. package/src/state/index.ts +121 -0
  143. package/src/state/invitations.ts +16 -0
  144. package/src/state/modal-keys.ts +63 -0
  145. package/src/state/modal-queue.ts +104 -0
  146. package/src/state/navigation.ts +34 -0
  147. package/src/state/permissions.ts +43 -0
  148. package/src/state/session.ts +223 -0
  149. package/src/state/squaddie-of-the-day.ts +21 -0
  150. package/src/state/sync/crdt.ts +70 -0
  151. package/src/state/sync/dependable.ts +213 -0
  152. package/src/state/sync/feed-v2.ts +42 -0
  153. package/src/state/sync/messages.ts +44 -0
  154. package/src/state/sync/offline-support.ts +42 -0
  155. package/src/state/sync/polls.ts +37 -0
  156. package/src/state/sync/refresh.ts +24 -0
  157. package/src/state/sync/squad-v2.ts +25 -0
  158. package/src/state/ui.ts +36 -0
  159. package/src/state/user.ts +46 -0
  160. package/src/state/wallet.ts +26 -0
  161. package/src/storage/SecureStorage.ts +77 -0
  162. package/src/theme/ThemeContext.tsx +159 -0
  163. package/src/types/modules.d.ts +165 -0
@@ -0,0 +1,158 @@
1
+ import React, { memo } from 'react';
2
+ import { View, Text, StyleSheet, Pressable } from 'react-native';
3
+ import { Colors } from '../../theme/ThemeContext';
4
+ import { TitleSmall, BodyRegular, BodySmall } from '../ux/text/Typography';
5
+
6
+ interface PollOption {
7
+ id: string;
8
+ text: string;
9
+ percentage?: number;
10
+ }
11
+
12
+ interface PollCardProps {
13
+ id: string;
14
+ question: string;
15
+ options: PollOption[];
16
+ hasVoted: boolean;
17
+ selectedOptionId?: string;
18
+ totalVotes?: number;
19
+ onPress?: () => void;
20
+ primaryColor?: string;
21
+ sponsorBrandName?: string;
22
+ sponsorBrandImageUrl?: string;
23
+ sponsorPlacementId?: string;
24
+ }
25
+
26
+ function PollCard({
27
+ id,
28
+ question,
29
+ options,
30
+ hasVoted,
31
+ selectedOptionId,
32
+ totalVotes,
33
+ onPress,
34
+ primaryColor = Colors.purple1,
35
+ sponsorBrandName,
36
+ }: PollCardProps) {
37
+ return (
38
+ <Pressable style={styles.card} onPress={onPress}>
39
+ {sponsorBrandName && (
40
+ <BodySmall style={styles.sponsorLabel}>
41
+ Presented by {sponsorBrandName}
42
+ </BodySmall>
43
+ )}
44
+ <TitleSmall style={styles.question}>{question}</TitleSmall>
45
+
46
+ <View style={styles.options}>
47
+ {options.slice(0, 4).map(option => {
48
+ const isSelected = selectedOptionId === option.id;
49
+ return (
50
+ <View key={option.id} style={styles.option}>
51
+ <View style={styles.optionHeader}>
52
+ <BodyRegular
53
+ style={[styles.optionText, isSelected && { color: primaryColor }]}
54
+ >
55
+ {option.text}
56
+ </BodyRegular>
57
+ {hasVoted && option.percentage !== undefined && (
58
+ <BodySmall style={styles.percentage}>
59
+ {Math.round(option.percentage)}%
60
+ </BodySmall>
61
+ )}
62
+ </View>
63
+ {hasVoted && option.percentage !== undefined && (
64
+ <View style={styles.progressBg}>
65
+ <View
66
+ style={[
67
+ styles.progressFill,
68
+ {
69
+ width: `${option.percentage}%`,
70
+ backgroundColor: isSelected ? primaryColor : Colors.gray5,
71
+ },
72
+ ]}
73
+ />
74
+ </View>
75
+ )}
76
+ </View>
77
+ );
78
+ })}
79
+ </View>
80
+
81
+ {totalVotes !== undefined && (
82
+ <BodySmall style={styles.totalVotes}>
83
+ {totalVotes} {totalVotes === 1 ? 'vote' : 'votes'}
84
+ </BodySmall>
85
+ )}
86
+
87
+ {!hasVoted && (
88
+ <View style={[styles.voteCta, { backgroundColor: primaryColor }]}>
89
+ <Text style={styles.voteCtaText}>Vote</Text>
90
+ </View>
91
+ )}
92
+ </Pressable>
93
+ );
94
+ }
95
+
96
+ export default memo(PollCard);
97
+
98
+ const styles = StyleSheet.create({
99
+ card: {
100
+ backgroundColor: Colors.gray2,
101
+ borderRadius: 16,
102
+ padding: 16,
103
+ marginBottom: 12,
104
+ },
105
+ sponsorLabel: {
106
+ color: Colors.gray6,
107
+ fontSize: 11,
108
+ marginBottom: 8,
109
+ },
110
+ question: {
111
+ color: Colors.white,
112
+ marginBottom: 16,
113
+ },
114
+ options: {
115
+ gap: 8,
116
+ },
117
+ option: {
118
+ gap: 6,
119
+ },
120
+ optionHeader: {
121
+ flexDirection: 'row',
122
+ justifyContent: 'space-between',
123
+ },
124
+ optionText: {
125
+ color: Colors.white,
126
+ flex: 1,
127
+ },
128
+ percentage: {
129
+ color: Colors.gray6,
130
+ fontWeight: '600',
131
+ },
132
+ progressBg: {
133
+ height: 4,
134
+ backgroundColor: Colors.gray3,
135
+ borderRadius: 2,
136
+ overflow: 'hidden',
137
+ },
138
+ progressFill: {
139
+ height: '100%',
140
+ borderRadius: 2,
141
+ },
142
+ totalVotes: {
143
+ color: Colors.gray6,
144
+ marginTop: 12,
145
+ textAlign: 'center',
146
+ },
147
+ voteCta: {
148
+ marginTop: 12,
149
+ paddingVertical: 10,
150
+ borderRadius: 20,
151
+ alignItems: 'center',
152
+ },
153
+ voteCtaText: {
154
+ color: Colors.gray1,
155
+ fontWeight: '600',
156
+ fontSize: 14,
157
+ },
158
+ });
@@ -0,0 +1,118 @@
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 { BodyRegular, BodySmall, SubtitleSmall } from '../ux/text/Typography';
6
+
7
+ interface SponsoredContentCardProps {
8
+ placementId: string;
9
+ brandName: string;
10
+ brandImageUrl?: string;
11
+ headline: string;
12
+ bodyText?: string;
13
+ imageUrl?: string;
14
+ ctaText?: string;
15
+ ctaUrl?: string;
16
+ onImpression?: (placementId: string, durationMs: number) => void;
17
+ onCtaPress?: (placementId: string) => void;
18
+ }
19
+
20
+ function SponsoredContentCard({
21
+ placementId,
22
+ brandName,
23
+ brandImageUrl,
24
+ headline,
25
+ bodyText,
26
+ ctaText,
27
+ ctaUrl,
28
+ onImpression,
29
+ onCtaPress,
30
+ }: SponsoredContentCardProps) {
31
+ const viewStartRef = useRef<number>(Date.now());
32
+
33
+ useEffect(() => {
34
+ viewStartRef.current = Date.now();
35
+ const timer = setTimeout(() => {
36
+ const duration = Date.now() - viewStartRef.current;
37
+ onImpression?.(placementId, duration);
38
+ }, 1000); // 1 second threshold for sponsored content
39
+
40
+ return () => clearTimeout(timer);
41
+ }, [placementId, onImpression]);
42
+
43
+ const handleCtaPress = () => {
44
+ onCtaPress?.(placementId);
45
+ if (ctaUrl) {
46
+ Linking.openURL(ctaUrl).catch(() => {});
47
+ }
48
+ };
49
+
50
+ return (
51
+ <View style={styles.card}>
52
+ <View style={styles.header}>
53
+ <UserImage imageUrl={brandImageUrl} displayName={brandName} size={36} />
54
+ <View style={styles.headerText}>
55
+ <SubtitleSmall style={styles.brandName}>{brandName}</SubtitleSmall>
56
+ <BodySmall style={styles.sponsoredLabel}>Sponsored</BodySmall>
57
+ </View>
58
+ </View>
59
+
60
+ <BodyRegular style={styles.headline}>{headline}</BodyRegular>
61
+
62
+ {bodyText && (
63
+ <BodySmall style={styles.bodyText}>{bodyText}</BodySmall>
64
+ )}
65
+
66
+ {ctaText && (
67
+ <Pressable style={styles.ctaButton} onPress={handleCtaPress}>
68
+ <Text style={styles.ctaText}>{ctaText}</Text>
69
+ </Pressable>
70
+ )}
71
+ </View>
72
+ );
73
+ }
74
+
75
+ export default memo(SponsoredContentCard);
76
+
77
+ const styles = StyleSheet.create({
78
+ card: {
79
+ backgroundColor: Colors.gray2,
80
+ borderRadius: 16,
81
+ padding: 16,
82
+ marginBottom: 12,
83
+ },
84
+ header: {
85
+ flexDirection: 'row',
86
+ alignItems: 'center',
87
+ marginBottom: 12,
88
+ },
89
+ headerText: {
90
+ marginLeft: 10,
91
+ flex: 1,
92
+ },
93
+ brandName: { color: Colors.white },
94
+ sponsoredLabel: { color: Colors.gray6, fontSize: 11 },
95
+ headline: {
96
+ color: Colors.white,
97
+ fontSize: 16,
98
+ fontWeight: '600',
99
+ marginBottom: 8,
100
+ },
101
+ bodyText: {
102
+ color: Colors.gray8,
103
+ marginBottom: 12,
104
+ },
105
+ ctaButton: {
106
+ backgroundColor: Colors.gray3,
107
+ borderRadius: 8,
108
+ paddingVertical: 10,
109
+ paddingHorizontal: 16,
110
+ alignSelf: 'flex-start',
111
+ marginTop: 4,
112
+ },
113
+ ctaText: {
114
+ color: Colors.white,
115
+ fontSize: 14,
116
+ fontWeight: '600',
117
+ },
118
+ });
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Full freestyle component system.
3
+ * Ported from squad-demo/src/components/freestyle/*.
4
+ * Components: FeedItem, FeedSectionHeader, UserListen, UserReaction,
5
+ * UserReactionDetailed, CommunityUserReaction, card/ButtonWrapper, card/EmojiReactions.
6
+ */
7
+ import React, { memo } from 'react';
8
+ import { View, Text, StyleSheet, Pressable, FlatList } from 'react-native';
9
+ import { Colors } from '../../theme/ThemeContext';
10
+ import UserImage from '../ux/user-image/UserImage';
11
+ import { AudioPlayerRow } from '../audio/AudioPlayerRow';
12
+ import { BodySmall, BodyRegular, SubtitleSmall, TitleSmall } from '../ux/text/Typography';
13
+
14
+ // --- FeedSectionHeader ---
15
+ export function FreestyleFeedSectionHeader({ title, count }: { title: string; count?: number }) {
16
+ return (
17
+ <View style={styles.sectionHeader}>
18
+ <TitleSmall style={styles.sectionTitle}>{title}</TitleSmall>
19
+ {count !== undefined && <BodySmall style={styles.sectionCount}>{count}</BodySmall>}
20
+ </View>
21
+ );
22
+ }
23
+
24
+ // --- FeedItem (full freestyle card) ---
25
+ export interface FreestyleFeedItemProps {
26
+ id: string;
27
+ audioUrl?: string;
28
+ duration?: number;
29
+ creatorName?: string;
30
+ creatorImageUrl?: string;
31
+ createdAt?: string;
32
+ listenCount?: number;
33
+ reactionCount?: number;
34
+ promptText?: string;
35
+ onPress?: () => void;
36
+ onReact?: (emoji: string) => void;
37
+ onListen?: () => void;
38
+ primaryColor?: string;
39
+ }
40
+
41
+ export const FreestyleFeedItem = memo(function FreestyleFeedItem({
42
+ audioUrl, duration, creatorName, creatorImageUrl, createdAt,
43
+ listenCount, reactionCount, promptText, onPress, onReact, primaryColor = Colors.purple1,
44
+ }: FreestyleFeedItemProps) {
45
+ const formatTime = (date?: string) => {
46
+ if (!date) return '';
47
+ const d = new Date(date);
48
+ const diff = Date.now() - d.getTime();
49
+ const mins = Math.floor(diff / 60000);
50
+ if (mins < 60) return `${mins}m`;
51
+ const hrs = Math.floor(mins / 60);
52
+ if (hrs < 24) return `${hrs}h`;
53
+ return `${Math.floor(hrs / 24)}d`;
54
+ };
55
+
56
+ return (
57
+ <Pressable style={styles.card} onPress={onPress}>
58
+ <View style={styles.cardHeader}>
59
+ <UserImage imageUrl={creatorImageUrl} displayName={creatorName} size={40} />
60
+ <View style={styles.cardHeaderText}>
61
+ <SubtitleSmall style={styles.cardCreatorName}>{creatorName}</SubtitleSmall>
62
+ <BodySmall style={styles.cardTimestamp}>{formatTime(createdAt)}</BodySmall>
63
+ </View>
64
+ </View>
65
+
66
+ {promptText && <BodyRegular style={styles.cardPrompt}>{promptText}</BodyRegular>}
67
+
68
+ {audioUrl && <AudioPlayerRow audioUrl={audioUrl} duration={duration} />}
69
+
70
+ <View style={styles.cardFooter}>
71
+ <Pressable style={styles.cardStat} onPress={() => onReact?.('fire')}>
72
+ <Text style={styles.cardStatIcon}>fire</Text>
73
+ <BodySmall style={styles.cardStatText}>{reactionCount ?? 0}</BodySmall>
74
+ </Pressable>
75
+ <View style={styles.cardStat}>
76
+ <Text style={styles.cardStatIcon}>ear</Text>
77
+ <BodySmall style={styles.cardStatText}>{listenCount ?? 0}</BodySmall>
78
+ </View>
79
+ </View>
80
+ </Pressable>
81
+ );
82
+ });
83
+
84
+ // --- UserListen ---
85
+ export function FreestyleUserListen({ userName, userImageUrl, listenedAt }: {
86
+ userName: string; userImageUrl?: string; listenedAt?: string;
87
+ }) {
88
+ return (
89
+ <View style={styles.userListenRow}>
90
+ <UserImage imageUrl={userImageUrl} displayName={userName} size={36} />
91
+ <BodyRegular style={styles.userListenName}>{userName}</BodyRegular>
92
+ <BodySmall style={styles.userListenTime}>listened</BodySmall>
93
+ </View>
94
+ );
95
+ }
96
+
97
+ // --- UserReaction ---
98
+ export function FreestyleUserReaction({ userName, userImageUrl, emoji }: {
99
+ userName: string; userImageUrl?: string; emoji: string;
100
+ }) {
101
+ return (
102
+ <View style={styles.userListenRow}>
103
+ <UserImage imageUrl={userImageUrl} displayName={userName} size={36} />
104
+ <BodyRegular style={styles.userListenName}>{userName}</BodyRegular>
105
+ <Text style={styles.reactionEmoji}>{emoji}</Text>
106
+ </View>
107
+ );
108
+ }
109
+
110
+ // --- EmojiReactions bar (for cards) ---
111
+ export function FreestyleEmojiReactions({
112
+ reactions, onReact,
113
+ }: { reactions: Array<{ emoji: string; count: number }>; onReact?: (emoji: string) => void }) {
114
+ return (
115
+ <View style={styles.emojiBar}>
116
+ {reactions.map((r, i) => (
117
+ <Pressable key={i} style={styles.emojiItem} onPress={() => onReact?.(r.emoji)}>
118
+ <Text style={styles.emojiText}>{r.emoji}</Text>
119
+ <BodySmall style={styles.emojiCount}>{r.count}</BodySmall>
120
+ </Pressable>
121
+ ))}
122
+ </View>
123
+ );
124
+ }
125
+
126
+ const styles = StyleSheet.create({
127
+ sectionHeader: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: 24, paddingVertical: 8 },
128
+ sectionTitle: { color: Colors.white },
129
+ sectionCount: { color: Colors.gray6 },
130
+ card: { backgroundColor: Colors.gray2, borderRadius: 16, padding: 16, marginBottom: 12 },
131
+ cardHeader: { flexDirection: 'row', alignItems: 'center', marginBottom: 12 },
132
+ cardHeaderText: { marginLeft: 10, flex: 1 },
133
+ cardCreatorName: { color: Colors.white },
134
+ cardTimestamp: { color: Colors.gray6 },
135
+ cardPrompt: { color: Colors.gray8, marginBottom: 12, fontStyle: 'italic' },
136
+ cardFooter: { flexDirection: 'row', gap: 16, marginTop: 12, paddingTop: 12, borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: Colors.gray3 },
137
+ cardStat: { flexDirection: 'row', alignItems: 'center', gap: 4 },
138
+ cardStatIcon: { color: Colors.gray6, fontSize: 14 },
139
+ cardStatText: { color: Colors.gray6 },
140
+ userListenRow: { flexDirection: 'row', alignItems: 'center', gap: 10, paddingVertical: 8, paddingHorizontal: 16, borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: Colors.gray3 },
141
+ userListenName: { color: Colors.white, flex: 1 },
142
+ userListenTime: { color: Colors.gray6 },
143
+ reactionEmoji: { fontSize: 20 },
144
+ emojiBar: { flexDirection: 'row', gap: 8, paddingVertical: 8 },
145
+ emojiItem: { flexDirection: 'row', alignItems: 'center', gap: 4, backgroundColor: Colors.gray3, borderRadius: 16, paddingVertical: 4, paddingHorizontal: 8 },
146
+ emojiText: { fontSize: 16 },
147
+ emojiCount: { color: Colors.gray6 },
148
+ });
@@ -0,0 +1,42 @@
1
+ // Buttons
2
+ export { default as Button } from './ux/buttons/Button';
3
+ export type { ButtonProps } from './ux/buttons/Button';
4
+ export { default as XButton } from './ux/buttons/XButton';
5
+
6
+ // Inputs
7
+ export { TextInput } from './ux/inputs/TextInput';
8
+ export { PhoneNumberInput } from './ux/inputs/PhoneNumberInput';
9
+ export { CodeInput } from './ux/inputs/CodeInput';
10
+
11
+ // Layout
12
+ export { default as Screen } from './ux/layout/Screen';
13
+ export { default as ScreenHeader } from './ux/layout/ScreenHeader';
14
+ export { default as LoadingOverlay } from './ux/layout/LoadingOverlay';
15
+ export { default as AvoidKeyboardScreen } from './ux/layout/AvoidKeyboardScreen';
16
+ export { Toast } from './ux/layout/Toast';
17
+ export type { ToastType } from './ux/layout/Toast';
18
+
19
+ // Typography
20
+ export {
21
+ TitleLarge,
22
+ TitleRegular,
23
+ TitleMedium,
24
+ TitleSmall,
25
+ TitleTiny,
26
+ SubtitleSmall,
27
+ BodyRegular,
28
+ BodyMedium,
29
+ BodySmall,
30
+ ButtonLarge,
31
+ ButtonSmall,
32
+ } from './ux/text/Typography';
33
+
34
+ // Errors
35
+ export { ErrorHint } from './ux/errors/ErrorHint';
36
+ export { ScreenErrorBoundary } from './ErrorBoundary';
37
+
38
+ // User Image
39
+ export { default as UserImage } from './ux/user-image/UserImage';
40
+
41
+ // Navigation
42
+ export { default as BackButton } from './ux/navigation/BackButton';
@@ -0,0 +1,166 @@
1
+ import React, { memo } 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 } from '../ux/text/Typography';
7
+
8
+ interface MessageCardProps {
9
+ id: string;
10
+ text?: string;
11
+ audioUrl?: string;
12
+ audioDuration?: number;
13
+ isOwn: boolean;
14
+ senderName?: string;
15
+ senderImageUrl?: string;
16
+ timestamp?: string;
17
+ reactions?: Array<{ emoji: string; count: number }>;
18
+ primaryColor?: string;
19
+ onLongPress?: () => void;
20
+ onReact?: (emoji: string) => void;
21
+ }
22
+
23
+ function MessageCard({
24
+ id,
25
+ text,
26
+ audioUrl,
27
+ audioDuration,
28
+ isOwn,
29
+ senderName,
30
+ senderImageUrl,
31
+ timestamp,
32
+ reactions,
33
+ primaryColor = Colors.purple1,
34
+ onLongPress,
35
+ onReact,
36
+ }: MessageCardProps) {
37
+ const formatTime = (ts?: string) => {
38
+ if (!ts) return '';
39
+ const d = new Date(ts);
40
+ return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
41
+ };
42
+
43
+ return (
44
+ <View style={[styles.container, isOwn && styles.containerOwn]}>
45
+ {!isOwn && (
46
+ <UserImage
47
+ imageUrl={senderImageUrl}
48
+ displayName={senderName}
49
+ size={32}
50
+ />
51
+ )}
52
+
53
+ <Pressable
54
+ style={[
55
+ styles.bubble,
56
+ isOwn
57
+ ? [styles.bubbleOwn, { backgroundColor: primaryColor }]
58
+ : styles.bubbleOther,
59
+ ]}
60
+ onLongPress={onLongPress}
61
+ >
62
+ {text && (
63
+ <BodyRegular
64
+ style={[
65
+ styles.text,
66
+ { color: isOwn ? Colors.gray1 : Colors.white },
67
+ ]}
68
+ >
69
+ {text}
70
+ </BodyRegular>
71
+ )}
72
+
73
+ {audioUrl && (
74
+ <View style={styles.audioContainer}>
75
+ <AudioPlayerRow audioUrl={audioUrl} duration={audioDuration} />
76
+ </View>
77
+ )}
78
+
79
+ {timestamp && (
80
+ <BodySmall style={[styles.time, { color: isOwn ? 'rgba(0,0,0,0.4)' : Colors.gray6 }]}>
81
+ {formatTime(timestamp)}
82
+ </BodySmall>
83
+ )}
84
+ </Pressable>
85
+
86
+ {reactions && reactions.length > 0 && (
87
+ <View style={styles.reactions}>
88
+ {reactions.map((r, i) => (
89
+ <Pressable
90
+ key={i}
91
+ style={styles.reaction}
92
+ onPress={() => onReact?.(r.emoji)}
93
+ >
94
+ <Text style={styles.reactionEmoji}>{r.emoji}</Text>
95
+ {r.count > 1 && (
96
+ <BodySmall style={styles.reactionCount}>{r.count}</BodySmall>
97
+ )}
98
+ </Pressable>
99
+ ))}
100
+ </View>
101
+ )}
102
+ </View>
103
+ );
104
+ }
105
+
106
+ export default memo(MessageCard);
107
+
108
+ const styles = StyleSheet.create({
109
+ container: {
110
+ flexDirection: 'row',
111
+ alignItems: 'flex-end',
112
+ gap: 8,
113
+ maxWidth: '85%',
114
+ marginBottom: 4,
115
+ },
116
+ containerOwn: {
117
+ alignSelf: 'flex-end',
118
+ flexDirection: 'row-reverse',
119
+ },
120
+ bubble: {
121
+ paddingVertical: 10,
122
+ paddingHorizontal: 14,
123
+ borderRadius: 18,
124
+ maxWidth: '100%',
125
+ },
126
+ bubbleOwn: {
127
+ borderBottomRightRadius: 4,
128
+ },
129
+ bubbleOther: {
130
+ backgroundColor: Colors.gray2,
131
+ borderBottomLeftRadius: 4,
132
+ },
133
+ text: {
134
+ fontSize: 15,
135
+ lineHeight: 20,
136
+ },
137
+ audioContainer: {
138
+ minWidth: 200,
139
+ },
140
+ time: {
141
+ marginTop: 4,
142
+ textAlign: 'right',
143
+ fontSize: 11,
144
+ },
145
+ reactions: {
146
+ flexDirection: 'row',
147
+ gap: 4,
148
+ marginTop: -4,
149
+ marginBottom: 4,
150
+ },
151
+ reaction: {
152
+ flexDirection: 'row',
153
+ alignItems: 'center',
154
+ backgroundColor: Colors.gray3,
155
+ borderRadius: 12,
156
+ paddingVertical: 2,
157
+ paddingHorizontal: 6,
158
+ },
159
+ reactionEmoji: {
160
+ fontSize: 14,
161
+ },
162
+ reactionCount: {
163
+ color: Colors.gray6,
164
+ marginLeft: 2,
165
+ },
166
+ });