@oxyhq/services 5.21.5 → 5.21.7

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 (177) hide show
  1. package/lib/commonjs/crypto/keyManager.js +67 -22
  2. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  3. package/lib/commonjs/index.js +66 -0
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/ui/components/BottomSheetRouter.js +100 -286
  6. package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
  7. package/lib/commonjs/ui/components/GroupedItem.js +0 -3
  8. package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
  9. package/lib/commonjs/ui/components/OxyProvider.js +14 -19
  10. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  11. package/lib/commonjs/ui/components/fileManagement/AnimatedButton.js +57 -0
  12. package/lib/commonjs/ui/components/fileManagement/AnimatedButton.js.map +1 -0
  13. package/lib/commonjs/ui/components/profile/EditBioModal.js +24 -156
  14. package/lib/commonjs/ui/components/profile/EditBioModal.js.map +1 -1
  15. package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js +28 -178
  16. package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js.map +1 -1
  17. package/lib/commonjs/ui/components/profile/EditEmailModal.js +32 -159
  18. package/lib/commonjs/ui/components/profile/EditEmailModal.js.map +1 -1
  19. package/lib/commonjs/ui/components/profile/EditLocationModal.js +45 -227
  20. package/lib/commonjs/ui/components/profile/EditLocationModal.js.map +1 -1
  21. package/lib/commonjs/ui/components/profile/EditUsernameModal.js +30 -155
  22. package/lib/commonjs/ui/components/profile/EditUsernameModal.js.map +1 -1
  23. package/lib/commonjs/ui/hooks/mutations/mutationFactory.js +177 -0
  24. package/lib/commonjs/ui/hooks/mutations/mutationFactory.js.map +1 -0
  25. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +10 -123
  26. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  27. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +2 -32
  28. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  29. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +2 -31
  30. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  31. package/lib/commonjs/ui/hooks/useFileFiltering.js +76 -0
  32. package/lib/commonjs/ui/hooks/useFileFiltering.js.map +1 -0
  33. package/lib/commonjs/ui/navigation/bottomSheetManager.js +43 -145
  34. package/lib/commonjs/ui/navigation/bottomSheetManager.js.map +1 -1
  35. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +0 -2
  36. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  37. package/lib/commonjs/ui/screens/FileManagementScreen.js +2 -2
  38. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  39. package/lib/commonjs/ui/utils/authHelpers.js +164 -0
  40. package/lib/commonjs/ui/utils/authHelpers.js.map +1 -0
  41. package/lib/commonjs/ui/utils/avatarUtils.js +18 -61
  42. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  43. package/lib/module/crypto/keyManager.js +67 -22
  44. package/lib/module/crypto/keyManager.js.map +1 -1
  45. package/lib/module/index.js +6 -0
  46. package/lib/module/index.js.map +1 -1
  47. package/lib/module/ui/components/BottomSheetRouter.js +102 -284
  48. package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
  49. package/lib/module/ui/components/GroupedItem.js +0 -3
  50. package/lib/module/ui/components/GroupedItem.js.map +1 -1
  51. package/lib/module/ui/components/OxyProvider.js +14 -19
  52. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  53. package/lib/module/ui/components/fileManagement/AnimatedButton.js +50 -0
  54. package/lib/module/ui/components/fileManagement/AnimatedButton.js.map +1 -0
  55. package/lib/module/ui/components/profile/EditBioModal.js +24 -156
  56. package/lib/module/ui/components/profile/EditBioModal.js.map +1 -1
  57. package/lib/module/ui/components/profile/EditDisplayNameModal.js +28 -178
  58. package/lib/module/ui/components/profile/EditDisplayNameModal.js.map +1 -1
  59. package/lib/module/ui/components/profile/EditEmailModal.js +32 -159
  60. package/lib/module/ui/components/profile/EditEmailModal.js.map +1 -1
  61. package/lib/module/ui/components/profile/EditLocationModal.js +45 -227
  62. package/lib/module/ui/components/profile/EditLocationModal.js.map +1 -1
  63. package/lib/module/ui/components/profile/EditUsernameModal.js +30 -155
  64. package/lib/module/ui/components/profile/EditUsernameModal.js.map +1 -1
  65. package/lib/module/ui/hooks/mutations/mutationFactory.js +173 -0
  66. package/lib/module/ui/hooks/mutations/mutationFactory.js.map +1 -0
  67. package/lib/module/ui/hooks/mutations/useAccountMutations.js +10 -122
  68. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  69. package/lib/module/ui/hooks/queries/useAccountQueries.js +2 -32
  70. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  71. package/lib/module/ui/hooks/queries/useServicesQueries.js +2 -31
  72. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  73. package/lib/module/ui/hooks/useFileFiltering.js +72 -0
  74. package/lib/module/ui/hooks/useFileFiltering.js.map +1 -0
  75. package/lib/module/ui/navigation/bottomSheetManager.js +37 -135
  76. package/lib/module/ui/navigation/bottomSheetManager.js.map +1 -1
  77. package/lib/module/ui/screens/AccountSettingsScreen.js +0 -2
  78. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  79. package/lib/module/ui/screens/FileManagementScreen.js +2 -2
  80. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  81. package/lib/module/ui/utils/authHelpers.js +154 -0
  82. package/lib/module/ui/utils/authHelpers.js.map +1 -0
  83. package/lib/module/ui/utils/avatarUtils.js +18 -61
  84. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  85. package/lib/typescript/commonjs/crypto/keyManager.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/index.d.ts +6 -0
  87. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/ui/components/BottomSheetRouter.d.ts +2 -7
  89. package/lib/typescript/commonjs/ui/components/BottomSheetRouter.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/ui/components/GroupedItem.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/ui/components/fileManagement/AnimatedButton.d.ts +16 -0
  93. package/lib/typescript/commonjs/ui/components/fileManagement/AnimatedButton.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/ui/components/profile/EditBioModal.d.ts.map +1 -1
  95. package/lib/typescript/commonjs/ui/components/profile/EditDisplayNameModal.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/ui/components/profile/EditEmailModal.d.ts.map +1 -1
  97. package/lib/typescript/commonjs/ui/components/profile/EditLocationModal.d.ts +1 -0
  98. package/lib/typescript/commonjs/ui/components/profile/EditLocationModal.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/ui/components/profile/EditUsernameModal.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/ui/hooks/mutations/mutationFactory.d.ts +76 -0
  101. package/lib/typescript/commonjs/ui/hooks/mutations/mutationFactory.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +29 -4
  103. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts +1 -1
  105. package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts +1 -1
  107. package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/ui/hooks/useFileFiltering.d.ts +29 -0
  109. package/lib/typescript/commonjs/ui/hooks/useFileFiltering.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts +11 -60
  111. package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/ui/utils/authHelpers.d.ts +99 -0
  114. package/lib/typescript/commonjs/ui/utils/authHelpers.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
  116. package/lib/typescript/module/crypto/keyManager.d.ts.map +1 -1
  117. package/lib/typescript/module/index.d.ts +6 -0
  118. package/lib/typescript/module/index.d.ts.map +1 -1
  119. package/lib/typescript/module/ui/components/BottomSheetRouter.d.ts +2 -7
  120. package/lib/typescript/module/ui/components/BottomSheetRouter.d.ts.map +1 -1
  121. package/lib/typescript/module/ui/components/GroupedItem.d.ts.map +1 -1
  122. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  123. package/lib/typescript/module/ui/components/fileManagement/AnimatedButton.d.ts +16 -0
  124. package/lib/typescript/module/ui/components/fileManagement/AnimatedButton.d.ts.map +1 -0
  125. package/lib/typescript/module/ui/components/profile/EditBioModal.d.ts.map +1 -1
  126. package/lib/typescript/module/ui/components/profile/EditDisplayNameModal.d.ts.map +1 -1
  127. package/lib/typescript/module/ui/components/profile/EditEmailModal.d.ts.map +1 -1
  128. package/lib/typescript/module/ui/components/profile/EditLocationModal.d.ts +1 -0
  129. package/lib/typescript/module/ui/components/profile/EditLocationModal.d.ts.map +1 -1
  130. package/lib/typescript/module/ui/components/profile/EditUsernameModal.d.ts.map +1 -1
  131. package/lib/typescript/module/ui/hooks/mutations/mutationFactory.d.ts +76 -0
  132. package/lib/typescript/module/ui/hooks/mutations/mutationFactory.d.ts.map +1 -0
  133. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +29 -4
  134. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  135. package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts +1 -1
  136. package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  137. package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts +1 -1
  138. package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  139. package/lib/typescript/module/ui/hooks/useFileFiltering.d.ts +29 -0
  140. package/lib/typescript/module/ui/hooks/useFileFiltering.d.ts.map +1 -0
  141. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts +11 -60
  142. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts.map +1 -1
  143. package/lib/typescript/module/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  144. package/lib/typescript/module/ui/utils/authHelpers.d.ts +99 -0
  145. package/lib/typescript/module/ui/utils/authHelpers.d.ts.map +1 -0
  146. package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
  147. package/package.json +2 -2
  148. package/src/crypto/keyManager.ts +23 -22
  149. package/src/index.ts +25 -0
  150. package/src/ui/components/BottomSheetRouter.tsx +97 -319
  151. package/src/ui/components/GroupedItem.tsx +0 -4
  152. package/src/ui/components/OxyProvider.tsx +13 -18
  153. package/src/ui/components/fileManagement/AnimatedButton.tsx +56 -0
  154. package/src/ui/components/profile/EditBioModal.tsx +38 -176
  155. package/src/ui/components/profile/EditDisplayNameModal.tsx +48 -195
  156. package/src/ui/components/profile/EditEmailModal.tsx +49 -180
  157. package/src/ui/components/profile/EditLocationModal.tsx +76 -263
  158. package/src/ui/components/profile/EditUsernameModal.tsx +47 -175
  159. package/src/ui/hooks/mutations/mutationFactory.ts +215 -0
  160. package/src/ui/hooks/mutations/useAccountMutations.ts +48 -136
  161. package/src/ui/hooks/queries/useAccountQueries.ts +6 -33
  162. package/src/ui/hooks/queries/useServicesQueries.ts +6 -32
  163. package/src/ui/hooks/useFileFiltering.ts +115 -0
  164. package/src/ui/navigation/bottomSheetManager.ts +43 -150
  165. package/src/ui/screens/AccountSettingsScreen.tsx +0 -2
  166. package/src/ui/screens/FileManagementScreen.tsx +2 -2
  167. package/src/ui/utils/authHelpers.ts +183 -0
  168. package/src/ui/utils/avatarUtils.ts +25 -65
  169. package/lib/commonjs/ui/hooks/use-haptic-press.js +0 -21
  170. package/lib/commonjs/ui/hooks/use-haptic-press.js.map +0 -1
  171. package/lib/module/ui/hooks/use-haptic-press.js +0 -17
  172. package/lib/module/ui/hooks/use-haptic-press.js.map +0 -1
  173. package/lib/typescript/commonjs/ui/hooks/use-haptic-press.d.ts +0 -8
  174. package/lib/typescript/commonjs/ui/hooks/use-haptic-press.d.ts.map +0 -1
  175. package/lib/typescript/module/ui/hooks/use-haptic-press.d.ts +0 -8
  176. package/lib/typescript/module/ui/hooks/use-haptic-press.d.ts.map +0 -1
  177. package/src/ui/hooks/use-haptic-press.ts +0 -15
@@ -1,184 +1,46 @@
1
- import React, { useState, useEffect } from 'react';
2
- import {
3
- View,
4
- Text,
5
- TextInput,
6
- TouchableOpacity,
7
- StyleSheet,
8
- Modal,
9
- Platform,
10
- } from 'react-native';
11
- import { Ionicons } from '@expo/vector-icons';
12
- import { useThemeStyles } from '../../hooks/useThemeStyles';
13
- import { useColorScheme } from '../../hooks/use-color-scheme';
14
- import { useI18n } from '../../hooks/useI18n';
15
- import { fontFamilies } from '../../styles/fonts';
1
+ import React from 'react';
2
+ import { EditFieldModal } from './EditFieldModal';
16
3
  import { useProfileEditing } from '../../hooks/useProfileEditing';
4
+ import { useI18n } from '../../hooks/useI18n';
17
5
 
18
6
  interface EditBioModalProps {
19
- visible: boolean;
20
- onClose: () => void;
21
- initialValue?: string;
22
- theme?: 'light' | 'dark';
23
- onSave?: () => void;
7
+ visible: boolean;
8
+ onClose: () => void;
9
+ initialValue?: string;
10
+ theme?: 'light' | 'dark';
11
+ onSave?: () => void;
24
12
  }
25
13
 
26
14
  export const EditBioModal: React.FC<EditBioModalProps> = ({
27
- visible,
28
- onClose,
29
- initialValue = '',
30
- theme = 'light',
31
- onSave,
15
+ visible,
16
+ onClose,
17
+ initialValue = '',
18
+ theme = 'light',
19
+ onSave,
32
20
  }) => {
33
- const { t } = useI18n();
34
- const colorScheme = useColorScheme();
35
- const themeStyles = useThemeStyles(theme || 'light', colorScheme);
36
- const colors = themeStyles.colors;
37
- const { updateField, isSaving } = useProfileEditing();
38
-
39
- const [bio, setBio] = useState(initialValue);
40
-
41
- useEffect(() => {
42
- if (visible) {
43
- setBio(initialValue);
44
- }
45
- }, [visible, initialValue]);
46
-
47
- const handleSave = async () => {
48
- const success = await updateField('bio', bio);
49
- if (success) {
50
- onSave?.();
51
- onClose();
52
- }
53
- };
54
-
55
- return (
56
- <Modal
57
- visible={visible}
58
- animationType="slide"
59
- transparent={true}
60
- onRequestClose={onClose}
61
- >
62
- <View style={styles.modalOverlay}>
63
- <View style={[styles.modalContent, { backgroundColor: colors.background }]}>
64
- <View style={styles.modalHeader}>
65
- <TouchableOpacity onPress={onClose} style={styles.closeButton}>
66
- <Ionicons name="close" size={24} color={colors.text} />
67
- </TouchableOpacity>
68
- <Text style={[styles.modalTitle, { color: colors.text }]}>
69
- {t('editProfile.items.bio.title') || 'Bio'}
70
- </Text>
71
- <TouchableOpacity
72
- onPress={handleSave}
73
- disabled={isSaving}
74
- style={[styles.saveButton, { opacity: isSaving ? 0.5 : 1 }]}
75
- >
76
- <Text style={[styles.saveButtonText, { color: colors.tint }]}>
77
- {isSaving ? 'Saving...' : 'Save'}
78
- </Text>
79
- </TouchableOpacity>
80
- </View>
81
-
82
- <View style={styles.modalBody}>
83
- <View style={styles.inputGroup}>
84
- <Text style={[styles.label, { color: colors.text }]}>
85
- {t('editProfile.items.bio.label') || 'Bio'}
86
- </Text>
87
- <TextInput
88
- style={[
89
- styles.textArea,
90
- {
91
- backgroundColor: colors.card,
92
- color: colors.text,
93
- borderColor: colors.border,
94
- },
95
- ]}
96
- value={bio}
97
- onChangeText={setBio}
98
- placeholder={t('editProfile.items.bio.placeholder') || 'Tell people about yourself...'}
99
- placeholderTextColor={colors.secondaryText}
100
- autoFocus
101
- multiline
102
- numberOfLines={6}
103
- textAlignVertical="top"
104
- selectionColor={colors.tint}
105
- />
106
- </View>
107
- </View>
108
- </View>
109
- </View>
110
- </Modal>
111
- );
21
+ const { t } = useI18n();
22
+ const { updateField } = useProfileEditing();
23
+
24
+ return (
25
+ <EditFieldModal
26
+ visible={visible}
27
+ onClose={onClose}
28
+ title={t('editProfile.items.bio.title') || 'Bio'}
29
+ theme={theme}
30
+ onSave={onSave}
31
+ variant="single"
32
+ fields={[
33
+ {
34
+ key: 'bio',
35
+ label: t('editProfile.items.bio.label') || 'Bio',
36
+ initialValue,
37
+ placeholder: t('editProfile.items.bio.placeholder') || 'Tell people about yourself...',
38
+ inputProps: { multiline: true, numberOfLines: 6 },
39
+ },
40
+ ]}
41
+ onSubmit={async (data) => {
42
+ return await updateField('bio', data.bio as string);
43
+ }}
44
+ />
45
+ );
112
46
  };
113
-
114
- const styles = StyleSheet.create({
115
- modalOverlay: {
116
- flex: 1,
117
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
118
- justifyContent: 'flex-end',
119
- },
120
- modalContent: {
121
- borderTopLeftRadius: 20,
122
- borderTopRightRadius: 20,
123
- paddingTop: Platform.OS === 'ios' ? 20 : 16,
124
- maxHeight: '80%',
125
- },
126
- modalHeader: {
127
- flexDirection: 'row',
128
- alignItems: 'center',
129
- justifyContent: 'space-between',
130
- paddingHorizontal: 16,
131
- paddingBottom: 16,
132
- borderBottomWidth: StyleSheet.hairlineWidth,
133
- borderBottomColor: '#E5E5EA',
134
- },
135
- closeButton: {
136
- width: 40,
137
- height: 40,
138
- alignItems: 'center',
139
- justifyContent: 'center',
140
- },
141
- modalTitle: {
142
- fontSize: 18,
143
- fontWeight: '600',
144
- fontFamily: fontFamilies.phuduSemiBold,
145
- flex: 1,
146
- textAlign: 'center',
147
- },
148
- saveButton: {
149
- paddingHorizontal: 16,
150
- paddingVertical: 8,
151
- },
152
- saveButtonText: {
153
- fontSize: 16,
154
- fontWeight: '600',
155
- fontFamily: fontFamilies.phuduSemiBold,
156
- },
157
- modalBody: {
158
- padding: 16,
159
- gap: 16,
160
- },
161
- inputGroup: {
162
- gap: 8,
163
- },
164
- label: {
165
- fontSize: 14,
166
- fontWeight: '600',
167
- fontFamily: fontFamilies.phuduSemiBold,
168
- },
169
- textArea: {
170
- borderWidth: StyleSheet.hairlineWidth,
171
- borderRadius: 12,
172
- padding: 16,
173
- fontSize: 16,
174
- minHeight: 120,
175
- },
176
- });
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
@@ -1,203 +1,56 @@
1
- import React, { useState, useEffect } from 'react';
2
- import {
3
- View,
4
- Text,
5
- TextInput,
6
- TouchableOpacity,
7
- StyleSheet,
8
- Modal,
9
- Platform,
10
- } from 'react-native';
11
- import { Ionicons } from '@expo/vector-icons';
12
- import { useThemeStyles } from '../../hooks/useThemeStyles';
13
- import { useColorScheme } from '../../hooks/use-color-scheme';
14
- import { useI18n } from '../../hooks/useI18n';
15
- import { fontFamilies } from '../../styles/fonts';
1
+ import React from 'react';
2
+ import { EditFieldModal } from './EditFieldModal';
16
3
  import { useProfileEditing } from '../../hooks/useProfileEditing';
4
+ import { useI18n } from '../../hooks/useI18n';
17
5
 
18
6
  interface EditDisplayNameModalProps {
19
- visible: boolean;
20
- onClose: () => void;
21
- initialDisplayName?: string;
22
- initialLastName?: string;
23
- theme?: 'light' | 'dark';
24
- onSave?: () => void;
7
+ visible: boolean;
8
+ onClose: () => void;
9
+ initialDisplayName?: string;
10
+ initialLastName?: string;
11
+ theme?: 'light' | 'dark';
12
+ onSave?: () => void;
25
13
  }
26
14
 
27
15
  export const EditDisplayNameModal: React.FC<EditDisplayNameModalProps> = ({
28
- visible,
29
- onClose,
30
- initialDisplayName = '',
31
- initialLastName = '',
32
- theme = 'light',
33
- onSave,
16
+ visible,
17
+ onClose,
18
+ initialDisplayName = '',
19
+ initialLastName = '',
20
+ theme = 'light',
21
+ onSave,
34
22
  }) => {
35
- const { t } = useI18n();
36
- const colorScheme = useColorScheme();
37
- const themeStyles = useThemeStyles(theme || 'light', colorScheme);
38
- const colors = themeStyles.colors;
39
- const { saveProfile, isSaving } = useProfileEditing();
40
-
41
- const [displayName, setDisplayName] = useState(initialDisplayName);
42
- const [lastName, setLastName] = useState(initialLastName);
43
-
44
- useEffect(() => {
45
- if (visible) {
46
- setDisplayName(initialDisplayName);
47
- setLastName(initialLastName);
48
- }
49
- }, [visible, initialDisplayName, initialLastName]);
50
-
51
- const handleSave = async () => {
52
- const updates = {
53
- displayName,
54
- lastName,
55
- };
56
- const success = await saveProfile(updates);
57
- if (success) {
58
- onSave?.();
59
- onClose();
60
- }
61
- };
62
-
63
- return (
64
- <Modal
65
- visible={visible}
66
- animationType="slide"
67
- transparent={true}
68
- onRequestClose={onClose}
69
- >
70
- <View style={styles.modalOverlay}>
71
- <View style={[styles.modalContent, { backgroundColor: colors.background }]}>
72
- <View style={styles.modalHeader}>
73
- <TouchableOpacity onPress={onClose} style={styles.closeButton}>
74
- <Ionicons name="close" size={24} color={colors.text} />
75
- </TouchableOpacity>
76
- <Text style={[styles.modalTitle, { color: colors.text }]}>
77
- {t('editProfile.items.displayName.title') || 'Display Name'}
78
- </Text>
79
- <TouchableOpacity
80
- onPress={handleSave}
81
- disabled={isSaving}
82
- style={[styles.saveButton, { opacity: isSaving ? 0.5 : 1 }]}
83
- >
84
- <Text style={[styles.saveButtonText, { color: colors.tint }]}>
85
- {isSaving ? 'Saving...' : 'Save'}
86
- </Text>
87
- </TouchableOpacity>
88
- </View>
89
-
90
- <View style={styles.modalBody}>
91
- <View style={styles.inputGroup}>
92
- <Text style={[styles.label, { color: colors.text }]}>
93
- {t('editProfile.items.displayName.firstName') || 'First Name'}
94
- </Text>
95
- <TextInput
96
- style={[
97
- styles.input,
98
- {
99
- backgroundColor: colors.card,
100
- color: colors.text,
101
- borderColor: colors.border,
102
- },
103
- ]}
104
- value={displayName}
105
- onChangeText={setDisplayName}
106
- placeholder={t('editProfile.items.displayName.firstNamePlaceholder') || 'Enter first name'}
107
- placeholderTextColor={colors.secondaryText}
108
- autoFocus
109
- selectionColor={colors.tint}
110
- />
111
- </View>
112
-
113
- <View style={styles.inputGroup}>
114
- <Text style={[styles.label, { color: colors.text }]}>
115
- {t('editProfile.items.displayName.lastName') || 'Last Name'}
116
- </Text>
117
- <TextInput
118
- style={[
119
- styles.input,
120
- {
121
- backgroundColor: colors.card,
122
- color: colors.text,
123
- borderColor: colors.border,
124
- },
125
- ]}
126
- value={lastName}
127
- onChangeText={setLastName}
128
- placeholder={t('editProfile.items.displayName.lastNamePlaceholder') || 'Enter last name (optional)'}
129
- placeholderTextColor={colors.secondaryText}
130
- selectionColor={colors.tint}
131
- />
132
- </View>
133
- </View>
134
- </View>
135
- </View>
136
- </Modal>
137
- );
23
+ const { t } = useI18n();
24
+ const { saveProfile } = useProfileEditing();
25
+
26
+ return (
27
+ <EditFieldModal
28
+ visible={visible}
29
+ onClose={onClose}
30
+ title={t('editProfile.items.displayName.title') || 'Display Name'}
31
+ theme={theme}
32
+ onSave={onSave}
33
+ variant="multi"
34
+ fields={[
35
+ {
36
+ key: 'displayName',
37
+ label: t('editProfile.items.displayName.firstName') || 'First Name',
38
+ initialValue: initialDisplayName,
39
+ placeholder: t('editProfile.items.displayName.firstNamePlaceholder') || 'Enter first name',
40
+ },
41
+ {
42
+ key: 'lastName',
43
+ label: t('editProfile.items.displayName.lastName') || 'Last Name',
44
+ initialValue: initialLastName,
45
+ placeholder: t('editProfile.items.displayName.lastNamePlaceholder') || 'Enter last name (optional)',
46
+ },
47
+ ]}
48
+ onSubmit={async (data) => {
49
+ return await saveProfile({
50
+ displayName: data.displayName as string,
51
+ lastName: data.lastName as string,
52
+ });
53
+ }}
54
+ />
55
+ );
138
56
  };
139
-
140
- const styles = StyleSheet.create({
141
- modalOverlay: {
142
- flex: 1,
143
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
144
- justifyContent: 'flex-end',
145
- },
146
- modalContent: {
147
- borderTopLeftRadius: 20,
148
- borderTopRightRadius: 20,
149
- paddingTop: Platform.OS === 'ios' ? 20 : 16,
150
- maxHeight: '80%',
151
- },
152
- modalHeader: {
153
- flexDirection: 'row',
154
- alignItems: 'center',
155
- justifyContent: 'space-between',
156
- paddingHorizontal: 16,
157
- paddingBottom: 16,
158
- borderBottomWidth: StyleSheet.hairlineWidth,
159
- borderBottomColor: '#E5E5EA',
160
- },
161
- closeButton: {
162
- width: 40,
163
- height: 40,
164
- alignItems: 'center',
165
- justifyContent: 'center',
166
- },
167
- modalTitle: {
168
- fontSize: 18,
169
- fontWeight: '600',
170
- fontFamily: fontFamilies.phuduSemiBold,
171
- flex: 1,
172
- textAlign: 'center',
173
- },
174
- saveButton: {
175
- paddingHorizontal: 16,
176
- paddingVertical: 8,
177
- },
178
- saveButtonText: {
179
- fontSize: 16,
180
- fontWeight: '600',
181
- fontFamily: fontFamilies.phuduSemiBold,
182
- },
183
- modalBody: {
184
- padding: 16,
185
- gap: 16,
186
- },
187
- inputGroup: {
188
- gap: 8,
189
- },
190
- label: {
191
- fontSize: 14,
192
- fontWeight: '600',
193
- fontFamily: fontFamilies.phuduSemiBold,
194
- },
195
- input: {
196
- borderWidth: StyleSheet.hairlineWidth,
197
- borderRadius: 12,
198
- padding: 16,
199
- fontSize: 16,
200
- minHeight: 52,
201
- },
202
- });
203
-