@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,139 @@
1
+ import React, { memo, useCallback } from 'react';
2
+ import { View, Text, StyleSheet, Pressable, ScrollView } from 'react-native';
3
+ import { Colors } from '../../../theme/ThemeContext';
4
+
5
+ const QUICK_REACTIONS = ['fire', 'heart', '100', 'clap', 'laugh', 'cry'];
6
+
7
+ const EMOJI_MAP: Record<string, string> = {
8
+ fire: '\u{1F525}',
9
+ heart: '\u{2764}\u{FE0F}',
10
+ '100': '\u{1F4AF}',
11
+ clap: '\u{1F44F}',
12
+ laugh: '\u{1F602}',
13
+ cry: '\u{1F622}',
14
+ thumbsup: '\u{1F44D}',
15
+ thumbsdown: '\u{1F44E}',
16
+ mind_blown: '\u{1F92F}',
17
+ eyes: '\u{1F440}',
18
+ pray: '\u{1F64F}',
19
+ muscle: '\u{1F4AA}',
20
+ };
21
+
22
+ interface EmojiReactionPickerProps {
23
+ onSelect: (emoji: string) => void;
24
+ onDismiss: () => void;
25
+ selectedEmoji?: string;
26
+ compact?: boolean;
27
+ }
28
+
29
+ function EmojiReactionPicker({
30
+ onSelect,
31
+ onDismiss,
32
+ selectedEmoji,
33
+ compact = false,
34
+ }: EmojiReactionPickerProps) {
35
+ const handleSelect = useCallback(
36
+ (key: string) => {
37
+ onSelect(key);
38
+ onDismiss();
39
+ },
40
+ [onSelect, onDismiss],
41
+ );
42
+
43
+ if (compact) {
44
+ return (
45
+ <View style={styles.compactContainer}>
46
+ {QUICK_REACTIONS.map(key => (
47
+ <Pressable
48
+ key={key}
49
+ style={[styles.compactEmoji, selectedEmoji === key && styles.compactEmojiSelected]}
50
+ onPress={() => handleSelect(key)}
51
+ >
52
+ <Text style={styles.emojiText}>{EMOJI_MAP[key] ?? key}</Text>
53
+ </Pressable>
54
+ ))}
55
+ </View>
56
+ );
57
+ }
58
+
59
+ return (
60
+ <View style={styles.overlay}>
61
+ <Pressable style={styles.backdrop} onPress={onDismiss} />
62
+ <View style={styles.picker}>
63
+ <View style={styles.handle} />
64
+ <ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.emojiRow}>
65
+ {Object.entries(EMOJI_MAP).map(([key, emoji]) => (
66
+ <Pressable
67
+ key={key}
68
+ style={[styles.emojiButton, selectedEmoji === key && styles.emojiButtonSelected]}
69
+ onPress={() => handleSelect(key)}
70
+ >
71
+ <Text style={styles.emojiTextLarge}>{emoji}</Text>
72
+ </Pressable>
73
+ ))}
74
+ </ScrollView>
75
+ </View>
76
+ </View>
77
+ );
78
+ }
79
+
80
+ export default memo(EmojiReactionPicker);
81
+
82
+ const styles = StyleSheet.create({
83
+ // Compact inline row
84
+ compactContainer: {
85
+ flexDirection: 'row',
86
+ gap: 4,
87
+ backgroundColor: Colors.gray2,
88
+ borderRadius: 24,
89
+ paddingVertical: 6,
90
+ paddingHorizontal: 8,
91
+ },
92
+ compactEmoji: {
93
+ width: 36, height: 36, borderRadius: 18,
94
+ justifyContent: 'center', alignItems: 'center',
95
+ },
96
+ compactEmojiSelected: {
97
+ backgroundColor: 'rgba(110, 130, 231, 0.2)',
98
+ },
99
+ emojiText: { fontSize: 20 },
100
+
101
+ // Full overlay picker
102
+ overlay: {
103
+ ...StyleSheet.absoluteFillObject,
104
+ justifyContent: 'flex-end',
105
+ zIndex: 9999,
106
+ },
107
+ backdrop: {
108
+ ...StyleSheet.absoluteFillObject,
109
+ backgroundColor: 'rgba(0,0,0,0.4)',
110
+ },
111
+ picker: {
112
+ backgroundColor: Colors.gray2,
113
+ borderTopLeftRadius: 20,
114
+ borderTopRightRadius: 20,
115
+ paddingBottom: 32,
116
+ paddingTop: 12,
117
+ },
118
+ handle: {
119
+ width: 40, height: 4, borderRadius: 2,
120
+ backgroundColor: Colors.gray5,
121
+ alignSelf: 'center',
122
+ marginBottom: 16,
123
+ },
124
+ emojiRow: {
125
+ paddingHorizontal: 16,
126
+ gap: 8,
127
+ },
128
+ emojiButton: {
129
+ width: 48, height: 48, borderRadius: 24,
130
+ justifyContent: 'center', alignItems: 'center',
131
+ backgroundColor: Colors.gray3,
132
+ },
133
+ emojiButtonSelected: {
134
+ backgroundColor: 'rgba(110, 130, 231, 0.3)',
135
+ borderWidth: 2,
136
+ borderColor: Colors.purple1,
137
+ },
138
+ emojiTextLarge: { fontSize: 24 },
139
+ });
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { View, Text, StyleSheet, Pressable } from 'react-native';
3
+ import { Colors } from '../../../theme/ThemeContext';
4
+
5
+ interface ErrorHintProps {
6
+ hint?: string | null;
7
+ error?: { name: string; message: string } | null;
8
+ onDismiss?: () => void;
9
+ }
10
+
11
+ export function ErrorHint({ hint, error, onDismiss }: ErrorHintProps) {
12
+ if (!hint && !error) return null;
13
+
14
+ const message = hint ?? error?.message;
15
+
16
+ return (
17
+ <Pressable onPress={onDismiss} style={styles.container}>
18
+ <View style={styles.indicator} />
19
+ <Text style={styles.text}>{message}</Text>
20
+ </Pressable>
21
+ );
22
+ }
23
+
24
+ const styles = StyleSheet.create({
25
+ container: {
26
+ flexDirection: 'row',
27
+ alignItems: 'center',
28
+ marginTop: 12,
29
+ paddingVertical: 8,
30
+ paddingHorizontal: 12,
31
+ backgroundColor: 'rgba(233, 120, 92, 0.14)',
32
+ borderRadius: 8,
33
+ },
34
+ indicator: {
35
+ width: 4,
36
+ height: 16,
37
+ borderRadius: 2,
38
+ backgroundColor: Colors.orange1,
39
+ marginRight: 8,
40
+ },
41
+ text: {
42
+ color: Colors.orange1,
43
+ fontSize: 14,
44
+ flex: 1,
45
+ },
46
+ });
@@ -0,0 +1,121 @@
1
+ import React, { useCallback, useRef, useState, useEffect } from 'react';
2
+ import {
3
+ View,
4
+ TextInput,
5
+ StyleSheet,
6
+ StyleProp,
7
+ ViewStyle,
8
+ } from 'react-native';
9
+ import { Colors } from '../../../theme/ThemeContext';
10
+
11
+ interface CodeInputProps {
12
+ length?: number;
13
+ value: string;
14
+ onChangeText: (text: string) => void;
15
+ onComplete?: (code: string) => void;
16
+ style?: StyleProp<ViewStyle>;
17
+ autoFocus?: boolean;
18
+ }
19
+
20
+ export function CodeInput({
21
+ length = 6,
22
+ value,
23
+ onChangeText,
24
+ onComplete,
25
+ style,
26
+ autoFocus = true,
27
+ }: CodeInputProps) {
28
+ const inputRef = useRef<TextInput>(null);
29
+
30
+ useEffect(() => {
31
+ if (autoFocus) {
32
+ setTimeout(() => inputRef.current?.focus(), 100);
33
+ }
34
+ }, [autoFocus]);
35
+
36
+ const handleChange = useCallback(
37
+ (text: string) => {
38
+ const cleaned = text.replace(/[^0-9]/g, '').slice(0, length);
39
+ onChangeText(cleaned);
40
+ if (cleaned.length === length) {
41
+ onComplete?.(cleaned);
42
+ }
43
+ },
44
+ [length, onChangeText, onComplete],
45
+ );
46
+
47
+ const digits = value.padEnd(length, '').split('');
48
+
49
+ return (
50
+ <View style={[styles.container, style]}>
51
+ <TextInput
52
+ ref={inputRef}
53
+ value={value}
54
+ onChangeText={handleChange}
55
+ keyboardType="number-pad"
56
+ maxLength={length}
57
+ style={styles.hiddenInput}
58
+ caretHidden
59
+ />
60
+ <View style={styles.digits}>
61
+ {digits.map((digit, index) => (
62
+ <View
63
+ key={index}
64
+ style={[
65
+ styles.digitBox,
66
+ index < value.length && styles.digitBoxFilled,
67
+ index === value.length && styles.digitBoxActive,
68
+ ]}
69
+ >
70
+ <View style={digit ? styles.dot : styles.dotEmpty} />
71
+ </View>
72
+ ))}
73
+ </View>
74
+ </View>
75
+ );
76
+ }
77
+
78
+ const styles = StyleSheet.create({
79
+ container: {
80
+ position: 'relative',
81
+ },
82
+ hiddenInput: {
83
+ position: 'absolute',
84
+ opacity: 0,
85
+ width: '100%',
86
+ height: '100%',
87
+ },
88
+ digits: {
89
+ flexDirection: 'row',
90
+ justifyContent: 'center',
91
+ gap: 12,
92
+ },
93
+ digitBox: {
94
+ width: 48,
95
+ height: 56,
96
+ borderWidth: 1,
97
+ borderColor: Colors.gray5,
98
+ borderRadius: 8,
99
+ justifyContent: 'center',
100
+ alignItems: 'center',
101
+ backgroundColor: Colors.black,
102
+ },
103
+ digitBoxFilled: {
104
+ borderColor: Colors.white,
105
+ },
106
+ digitBoxActive: {
107
+ borderColor: Colors.purple1,
108
+ },
109
+ dot: {
110
+ width: 12,
111
+ height: 12,
112
+ borderRadius: 6,
113
+ backgroundColor: Colors.white,
114
+ },
115
+ dotEmpty: {
116
+ width: 12,
117
+ height: 12,
118
+ borderRadius: 6,
119
+ backgroundColor: Colors.gray5,
120
+ },
121
+ });
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Date picker for birthdate selection.
3
+ * Ported from squad-demo/src/components/ux/inputs/DatePicker.tsx.
4
+ */
5
+ import React, { useState } from 'react';
6
+ import { View, Text, StyleSheet, Pressable, Platform } from 'react-native';
7
+ import { Colors } from '../../../theme/ThemeContext';
8
+
9
+ interface DatePickerProps {
10
+ value?: Date;
11
+ onChange: (date: Date) => void;
12
+ label?: string;
13
+ minimumAge?: number;
14
+ }
15
+
16
+ export default function DatePicker({ value, onChange, label, minimumAge = 13 }: DatePickerProps) {
17
+ const [showPicker, setShowPicker] = useState(false);
18
+
19
+ const maxDate = new Date();
20
+ maxDate.setFullYear(maxDate.getFullYear() - minimumAge);
21
+
22
+ const formatDate = (date?: Date) => {
23
+ if (!date) return 'Select date';
24
+ return date.toLocaleDateString(undefined, { month: 'long', day: 'numeric', year: 'numeric' });
25
+ };
26
+
27
+ const handlePress = async () => {
28
+ try {
29
+ const DateTimePicker = (await import('react-native-date-picker')).default;
30
+ setShowPicker(true);
31
+ } catch {
32
+ // react-native-date-picker not installed — use simple text fallback
33
+ }
34
+ };
35
+
36
+ return (
37
+ <View>
38
+ {label && <Text style={styles.label}>{label}</Text>}
39
+ <Pressable
40
+ style={styles.container}
41
+ onPress={handlePress}
42
+ accessibilityRole="button"
43
+ accessibilityLabel={label ?? 'Select date'}
44
+ >
45
+ <Text style={[styles.text, !value && styles.placeholder]}>
46
+ {formatDate(value)}
47
+ </Text>
48
+ </Pressable>
49
+ </View>
50
+ );
51
+ }
52
+
53
+ const styles = StyleSheet.create({
54
+ label: {
55
+ color: Colors.gray6,
56
+ fontSize: 12,
57
+ marginBottom: 8,
58
+ textTransform: 'uppercase',
59
+ letterSpacing: 1,
60
+ },
61
+ container: {
62
+ borderWidth: 1,
63
+ borderColor: Colors.gray5,
64
+ borderRadius: 8,
65
+ backgroundColor: Colors.black,
66
+ paddingVertical: 16,
67
+ paddingHorizontal: 16,
68
+ },
69
+ text: {
70
+ color: Colors.white,
71
+ fontSize: 16,
72
+ },
73
+ placeholder: {
74
+ color: Colors.gray6,
75
+ },
76
+ });
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Masked text input — for phone numbers, codes, etc.
3
+ * Ported from squad-demo/src/components/ux/inputs/MaskedTextInput.tsx.
4
+ */
5
+ import React, { useCallback, useState } from 'react';
6
+ import {
7
+ NativeSyntheticEvent,
8
+ StyleProp,
9
+ TextInput,
10
+ TextInputFocusEventData,
11
+ ViewStyle,
12
+ TextInputProps,
13
+ StyleSheet,
14
+ } from 'react-native';
15
+ import { Colors } from '../../../theme/ThemeContext';
16
+
17
+ type MaskedTextInputProps = TextInputProps & {
18
+ focusStyle?: StyleProp<ViewStyle>;
19
+ mask?: (RegExp | string)[];
20
+ placeholderFillCharacter?: string;
21
+ };
22
+
23
+ const MaskedTextInput = React.forwardRef(function MaskedTextInputComponent(
24
+ { style, focusStyle, onFocus, onBlur, mask, onChangeText, value, placeholderFillCharacter, ...props }: MaskedTextInputProps,
25
+ ref,
26
+ ) {
27
+ const [focused, setFocused] = useState(false);
28
+
29
+ const handleFocus = useCallback(
30
+ (event: NativeSyntheticEvent<TextInputFocusEventData>) => {
31
+ setFocused(true);
32
+ onFocus?.(event);
33
+ },
34
+ [onFocus],
35
+ );
36
+
37
+ const handleBlur = useCallback(
38
+ (event: NativeSyntheticEvent<TextInputFocusEventData>) => {
39
+ setFocused(false);
40
+ onBlur?.(event);
41
+ },
42
+ [onBlur],
43
+ );
44
+
45
+ const handleChange = useCallback(
46
+ (text: string) => {
47
+ if (mask) {
48
+ // Apply mask — keep only characters matching mask patterns
49
+ let masked = '';
50
+ let textIdx = 0;
51
+ for (let i = 0; i < mask.length && textIdx < text.length; i++) {
52
+ const pattern = mask[i];
53
+ if (pattern instanceof RegExp) {
54
+ if (pattern.test(text[textIdx]!)) {
55
+ masked += text[textIdx]!;
56
+ }
57
+ textIdx++;
58
+ } else {
59
+ masked += pattern;
60
+ if (text[textIdx] === pattern) textIdx++;
61
+ }
62
+ }
63
+ onChangeText?.(masked);
64
+ } else {
65
+ onChangeText?.(text);
66
+ }
67
+ },
68
+ [mask, onChangeText],
69
+ );
70
+
71
+ return (
72
+ <TextInput
73
+ {...props}
74
+ value={value}
75
+ onChangeText={handleChange}
76
+ onFocus={handleFocus as any}
77
+ onBlur={handleBlur as any}
78
+ style={[styles.input, style, focused ? focusStyle : {}]}
79
+ ref={ref as any}
80
+ accessibilityRole="text"
81
+ />
82
+ );
83
+ });
84
+
85
+ export default MaskedTextInput;
86
+
87
+ const styles = StyleSheet.create({
88
+ input: {
89
+ color: Colors.white,
90
+ fontSize: 24,
91
+ fontWeight: '500',
92
+ letterSpacing: 8,
93
+ textAlign: 'center',
94
+ },
95
+ });
@@ -0,0 +1,90 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ TextInput,
6
+ StyleSheet,
7
+ StyleProp,
8
+ ViewStyle,
9
+ } from 'react-native';
10
+ import { Colors } from '../../../theme/ThemeContext';
11
+
12
+ interface PhoneNumberInputProps {
13
+ value: string;
14
+ onChangeText: (text: string) => void;
15
+ onSubmitEditing?: () => void;
16
+ style?: StyleProp<ViewStyle>;
17
+ countryCode?: string;
18
+ }
19
+
20
+ export function PhoneNumberInput({
21
+ value,
22
+ onChangeText,
23
+ onSubmitEditing,
24
+ style,
25
+ countryCode = '+1',
26
+ }: PhoneNumberInputProps) {
27
+ const [focused, setFocused] = useState(false);
28
+
29
+ const handleChange = useCallback(
30
+ (text: string) => {
31
+ const cleaned = text.replace(/[^0-9]/g, '');
32
+ onChangeText(cleaned);
33
+ },
34
+ [onChangeText],
35
+ );
36
+
37
+ return (
38
+ <View style={[styles.container, focused && styles.containerFocused, style]}>
39
+ <View style={styles.countryCode}>
40
+ <Text style={styles.countryCodeText}>{countryCode}</Text>
41
+ </View>
42
+ <TextInput
43
+ value={value}
44
+ onChangeText={handleChange}
45
+ onSubmitEditing={onSubmitEditing}
46
+ onFocus={() => setFocused(true)}
47
+ onBlur={() => setFocused(false)}
48
+ placeholder="Phone number"
49
+ placeholderTextColor={Colors.gray6}
50
+ keyboardType="phone-pad"
51
+ style={styles.input}
52
+ maxLength={15}
53
+ />
54
+ </View>
55
+ );
56
+ }
57
+
58
+ const styles = StyleSheet.create({
59
+ container: {
60
+ flexDirection: 'row',
61
+ alignItems: 'center',
62
+ borderWidth: 1,
63
+ borderColor: Colors.gray5,
64
+ borderRadius: 8,
65
+ backgroundColor: Colors.black,
66
+ overflow: 'hidden',
67
+ },
68
+ containerFocused: {
69
+ borderColor: Colors.white,
70
+ },
71
+ countryCode: {
72
+ paddingHorizontal: 16,
73
+ paddingVertical: 16,
74
+ borderRightWidth: 1,
75
+ borderRightColor: Colors.gray5,
76
+ },
77
+ countryCodeText: {
78
+ color: Colors.white,
79
+ fontSize: 16,
80
+ fontWeight: '500',
81
+ },
82
+ input: {
83
+ flex: 1,
84
+ paddingHorizontal: 16,
85
+ paddingVertical: 16,
86
+ color: Colors.white,
87
+ fontSize: 16,
88
+ fontWeight: '500',
89
+ },
90
+ });
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Search text input with debounced updates and search icon.
3
+ * Ported from squad-demo/src/components/ux/inputs/SearchTextInput.tsx.
4
+ */
5
+ import React, { useCallback, useRef, useState } from 'react';
6
+ import { View, StyleSheet, TextInputProps, Text } from 'react-native';
7
+ import { TextInput } from './TextInput';
8
+ import { Colors } from '../../../theme/ThemeContext';
9
+
10
+ interface SearchTextInputProps extends TextInputProps {
11
+ debounceUpdate?: (text: string) => void;
12
+ inputBackgroundColor?: string;
13
+ }
14
+
15
+ export default function SearchTextInput({
16
+ debounceUpdate,
17
+ inputBackgroundColor,
18
+ ...props
19
+ }: SearchTextInputProps) {
20
+ const [searchText, setSearchText] = useState('');
21
+ const timerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
22
+
23
+ const handleChange = useCallback(
24
+ (text: string) => {
25
+ setSearchText(text);
26
+ if (timerRef.current) clearTimeout(timerRef.current);
27
+ timerRef.current = setTimeout(() => {
28
+ debounceUpdate?.(text);
29
+ }, 200);
30
+ },
31
+ [debounceUpdate],
32
+ );
33
+
34
+ return (
35
+ <View style={[styles.container, { backgroundColor: inputBackgroundColor ?? Colors.gray1 }]}>
36
+ <Text style={styles.icon} accessibilityElementsHidden>Q</Text>
37
+ <TextInput
38
+ {...props}
39
+ style={styles.input}
40
+ value={searchText}
41
+ onChangeText={handleChange}
42
+ placeholderTextColor={Colors.gray6}
43
+ accessibilityLabel={props.accessibilityLabel ?? 'Search'}
44
+ />
45
+ </View>
46
+ );
47
+ }
48
+
49
+ const styles = StyleSheet.create({
50
+ container: {
51
+ alignItems: 'center',
52
+ borderRadius: 8,
53
+ flexDirection: 'row',
54
+ justifyContent: 'center',
55
+ marginBottom: 16,
56
+ paddingHorizontal: 16,
57
+ paddingVertical: 8,
58
+ },
59
+ icon: {
60
+ marginRight: 8,
61
+ color: Colors.gray6,
62
+ fontSize: 16,
63
+ },
64
+ input: {
65
+ color: Colors.white,
66
+ flex: 1,
67
+ fontSize: 14,
68
+ paddingVertical: 8,
69
+ },
70
+ });
@@ -0,0 +1,58 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import {
3
+ NativeSyntheticEvent,
4
+ StyleProp,
5
+ TextInput as RNTextInput,
6
+ TextInputProps as RNTextInputProps,
7
+ TextInputFocusEventData,
8
+ ViewStyle,
9
+ StyleSheet,
10
+ } from 'react-native';
11
+
12
+ type TextInputProps = RNTextInputProps & {
13
+ ref?: any;
14
+ focusStyle?: StyleProp<ViewStyle>;
15
+ };
16
+
17
+ export const TextInput = React.forwardRef(function TextInputComponent(
18
+ { style, onFocus, onBlur, focusStyle, ...props }: TextInputProps,
19
+ ref,
20
+ ) {
21
+ const [focused, setFocused] = useState(false);
22
+
23
+ const handleFocus = useCallback(
24
+ (event: NativeSyntheticEvent<TextInputFocusEventData>) => {
25
+ setFocused(true);
26
+ onFocus?.(event);
27
+ },
28
+ [onFocus],
29
+ );
30
+
31
+ const handleBlur = useCallback(
32
+ (event: NativeSyntheticEvent<TextInputFocusEventData>) => {
33
+ setFocused(false);
34
+ onBlur?.(event);
35
+ },
36
+ [onBlur],
37
+ );
38
+
39
+ return (
40
+ <RNTextInput
41
+ {...props}
42
+ onFocus={handleFocus as any}
43
+ onBlur={handleBlur as any}
44
+ textAlignVertical="center"
45
+ style={[styles.input, style, focused ? focusStyle : {}]}
46
+ ref={ref as any}
47
+ autoComplete="off"
48
+ accessibilityRole="text"
49
+ accessibilityLabel={props.accessibilityLabel ?? props.placeholder}
50
+ />
51
+ );
52
+ });
53
+
54
+ const styles = StyleSheet.create({
55
+ input: {
56
+ textAlignVertical: 'center',
57
+ },
58
+ });