@umituz/react-native-settings 2.0.0 → 2.4.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 (160) hide show
  1. package/README.md +129 -3
  2. package/lib/__tests__/setup.d.ts +5 -0
  3. package/lib/__tests__/setup.d.ts.map +1 -0
  4. package/lib/__tests__/setup.js +143 -0
  5. package/lib/__tests__/setup.js.map +1 -0
  6. package/lib/domain/repositories/ISettingsRepository.d.ts +51 -0
  7. package/lib/domain/repositories/ISettingsRepository.d.ts.map +1 -0
  8. package/lib/domain/repositories/ISettingsRepository.js +8 -0
  9. package/lib/domain/repositories/ISettingsRepository.js.map +1 -0
  10. package/lib/index.d.ts +35 -0
  11. package/lib/index.d.ts.map +1 -0
  12. package/lib/index.js +32 -0
  13. package/lib/index.js.map +1 -0
  14. package/lib/infrastructure/storage/SettingsStore.d.ts +36 -0
  15. package/lib/infrastructure/storage/SettingsStore.d.ts.map +1 -0
  16. package/lib/infrastructure/storage/SettingsStore.js +144 -0
  17. package/lib/infrastructure/storage/SettingsStore.js.map +1 -0
  18. package/lib/presentation/components/CloudSyncSetting.d.ts +16 -0
  19. package/lib/presentation/components/CloudSyncSetting.d.ts.map +1 -0
  20. package/lib/presentation/components/CloudSyncSetting.js +30 -0
  21. package/lib/presentation/components/CloudSyncSetting.js.map +1 -0
  22. package/lib/presentation/components/DisclaimerCard.d.ts +15 -0
  23. package/lib/presentation/components/DisclaimerCard.d.ts.map +1 -0
  24. package/lib/presentation/components/DisclaimerCard.js +73 -0
  25. package/lib/presentation/components/DisclaimerCard.js.map +1 -0
  26. package/lib/presentation/components/DisclaimerModal.d.ts +13 -0
  27. package/lib/presentation/components/DisclaimerModal.d.ts.map +1 -0
  28. package/lib/presentation/components/DisclaimerModal.js +62 -0
  29. package/lib/presentation/components/DisclaimerModal.js.map +1 -0
  30. package/lib/presentation/components/DisclaimerSetting.d.ts +39 -0
  31. package/lib/presentation/components/DisclaimerSetting.d.ts.map +1 -0
  32. package/lib/presentation/components/DisclaimerSetting.js +59 -0
  33. package/lib/presentation/components/DisclaimerSetting.js.map +1 -0
  34. package/lib/presentation/components/SettingItem.d.ts +45 -0
  35. package/lib/presentation/components/SettingItem.d.ts.map +1 -0
  36. package/lib/presentation/components/SettingItem.js +113 -0
  37. package/lib/presentation/components/SettingItem.js.map +1 -0
  38. package/lib/presentation/components/SettingsErrorBoundary.d.ts +23 -0
  39. package/lib/presentation/components/SettingsErrorBoundary.d.ts.map +1 -0
  40. package/lib/presentation/components/SettingsErrorBoundary.js +73 -0
  41. package/lib/presentation/components/SettingsErrorBoundary.js.map +1 -0
  42. package/lib/presentation/components/SettingsFooter.d.ts +11 -0
  43. package/lib/presentation/components/SettingsFooter.d.ts.map +1 -0
  44. package/lib/presentation/components/SettingsFooter.js +31 -0
  45. package/lib/presentation/components/SettingsFooter.js.map +1 -0
  46. package/lib/presentation/components/SettingsSection.d.ts +13 -0
  47. package/lib/presentation/components/SettingsSection.d.ts.map +1 -0
  48. package/lib/presentation/components/SettingsSection.js +37 -0
  49. package/lib/presentation/components/SettingsSection.js.map +1 -0
  50. package/lib/presentation/components/StorageClearSetting.d.ts +16 -0
  51. package/lib/presentation/components/StorageClearSetting.d.ts.map +1 -0
  52. package/lib/presentation/components/StorageClearSetting.js +21 -0
  53. package/lib/presentation/components/StorageClearSetting.js.map +1 -0
  54. package/lib/presentation/components/UserProfileHeader.d.ts +30 -0
  55. package/lib/presentation/components/UserProfileHeader.d.ts.map +1 -0
  56. package/lib/presentation/components/UserProfileHeader.js +119 -0
  57. package/lib/presentation/components/UserProfileHeader.js.map +1 -0
  58. package/lib/presentation/screens/AppearanceScreen.d.ts +8 -0
  59. package/lib/presentation/screens/AppearanceScreen.d.ts.map +1 -0
  60. package/lib/presentation/screens/AppearanceScreen.js +8 -0
  61. package/lib/presentation/screens/AppearanceScreen.js.map +1 -0
  62. package/lib/presentation/screens/SettingsScreen.d.ts +38 -0
  63. package/lib/presentation/screens/SettingsScreen.d.ts.map +1 -0
  64. package/lib/presentation/screens/SettingsScreen.js +37 -0
  65. package/lib/presentation/screens/SettingsScreen.js.map +1 -0
  66. package/lib/presentation/screens/components/AboutLegalSection.d.ts +15 -0
  67. package/lib/presentation/screens/components/AboutLegalSection.d.ts.map +1 -0
  68. package/lib/presentation/screens/components/AboutLegalSection.js +28 -0
  69. package/lib/presentation/screens/components/AboutLegalSection.js.map +1 -0
  70. package/lib/presentation/screens/components/AppearanceSection.d.ts +12 -0
  71. package/lib/presentation/screens/components/AppearanceSection.d.ts.map +1 -0
  72. package/lib/presentation/screens/components/AppearanceSection.js +21 -0
  73. package/lib/presentation/screens/components/AppearanceSection.js.map +1 -0
  74. package/lib/presentation/screens/components/LanguageSection.d.ts +12 -0
  75. package/lib/presentation/screens/components/LanguageSection.d.ts.map +1 -0
  76. package/lib/presentation/screens/components/LanguageSection.js +26 -0
  77. package/lib/presentation/screens/components/LanguageSection.js.map +1 -0
  78. package/lib/presentation/screens/components/NotificationsSection.d.ts +12 -0
  79. package/lib/presentation/screens/components/NotificationsSection.d.ts.map +1 -0
  80. package/lib/presentation/screens/components/NotificationsSection.js +58 -0
  81. package/lib/presentation/screens/components/NotificationsSection.js.map +1 -0
  82. package/lib/presentation/screens/components/SettingsContent.d.ts +36 -0
  83. package/lib/presentation/screens/components/SettingsContent.d.ts.map +1 -0
  84. package/lib/presentation/screens/components/SettingsContent.js +81 -0
  85. package/lib/presentation/screens/components/SettingsContent.js.map +1 -0
  86. package/lib/presentation/screens/components/SettingsHeader.d.ts +12 -0
  87. package/lib/presentation/screens/components/SettingsHeader.d.ts.map +1 -0
  88. package/lib/presentation/screens/components/SettingsHeader.js +59 -0
  89. package/lib/presentation/screens/components/SettingsHeader.js.map +1 -0
  90. package/lib/presentation/screens/components/index.d.ts +9 -0
  91. package/lib/presentation/screens/components/index.d.ts.map +1 -0
  92. package/lib/presentation/screens/components/index.js +9 -0
  93. package/lib/presentation/screens/components/index.js.map +1 -0
  94. package/lib/presentation/screens/hooks/useFeatureDetection.d.ts +21 -0
  95. package/lib/presentation/screens/hooks/useFeatureDetection.d.ts.map +1 -0
  96. package/lib/presentation/screens/hooks/useFeatureDetection.js +82 -0
  97. package/lib/presentation/screens/hooks/useFeatureDetection.js.map +1 -0
  98. package/lib/presentation/screens/types/CustomSection.d.ts +19 -0
  99. package/lib/presentation/screens/types/CustomSection.d.ts.map +1 -0
  100. package/lib/presentation/screens/types/CustomSection.js +6 -0
  101. package/lib/presentation/screens/types/CustomSection.js.map +1 -0
  102. package/lib/presentation/screens/types/ExtendedConfig.d.ts +68 -0
  103. package/lib/presentation/screens/types/ExtendedConfig.d.ts.map +1 -0
  104. package/lib/presentation/screens/types/ExtendedConfig.js +6 -0
  105. package/lib/presentation/screens/types/ExtendedConfig.js.map +1 -0
  106. package/lib/presentation/screens/types/FeatureConfig.d.ts +95 -0
  107. package/lib/presentation/screens/types/FeatureConfig.d.ts.map +1 -0
  108. package/lib/presentation/screens/types/FeatureConfig.js +6 -0
  109. package/lib/presentation/screens/types/FeatureConfig.js.map +1 -0
  110. package/lib/presentation/screens/types/SettingsConfig.d.ts +97 -0
  111. package/lib/presentation/screens/types/SettingsConfig.d.ts.map +1 -0
  112. package/lib/presentation/screens/types/SettingsConfig.js +6 -0
  113. package/lib/presentation/screens/types/SettingsConfig.js.map +1 -0
  114. package/lib/presentation/screens/types/index.d.ts +10 -0
  115. package/lib/presentation/screens/types/index.d.ts.map +1 -0
  116. package/lib/presentation/screens/types/index.js +6 -0
  117. package/lib/presentation/screens/types/index.js.map +1 -0
  118. package/lib/presentation/screens/utils/normalizeConfig.d.ts +44 -0
  119. package/lib/presentation/screens/utils/normalizeConfig.d.ts.map +1 -0
  120. package/lib/presentation/screens/utils/normalizeConfig.js +38 -0
  121. package/lib/presentation/screens/utils/normalizeConfig.js.map +1 -0
  122. package/package.json +46 -11
  123. package/src/__tests__/integration.test.tsx +371 -0
  124. package/src/__tests__/performance.test.tsx +369 -0
  125. package/src/__tests__/setup.test.tsx +20 -0
  126. package/src/__tests__/setup.ts +157 -0
  127. package/src/index.ts +9 -0
  128. package/src/infrastructure/storage/SettingsStore.ts +90 -45
  129. package/src/infrastructure/storage/__tests__/SettingsStore.test.tsx +302 -0
  130. package/src/presentation/components/CloudSyncSetting.tsx +11 -17
  131. package/src/presentation/components/DisclaimerCard.tsx +115 -0
  132. package/src/presentation/components/DisclaimerModal.tsx +104 -0
  133. package/src/presentation/components/DisclaimerSetting.tsx +77 -159
  134. package/src/presentation/components/SettingItem.tsx +11 -2
  135. package/src/presentation/components/SettingsErrorBoundary.tsx +126 -0
  136. package/src/presentation/components/StorageClearSetting.tsx +13 -8
  137. package/src/presentation/components/UserProfileHeader.tsx +48 -11
  138. package/src/presentation/components/__tests__/CloudSyncSetting.test.tsx +78 -0
  139. package/src/presentation/components/__tests__/DisclaimerCard.test.tsx +208 -0
  140. package/src/presentation/components/__tests__/DisclaimerModal.test.tsx +236 -0
  141. package/src/presentation/components/__tests__/DisclaimerSetting.test.tsx +74 -0
  142. package/src/presentation/components/__tests__/SettingItem.test.tsx +189 -0
  143. package/src/presentation/components/__tests__/SettingsErrorBoundary.test.tsx +186 -0
  144. package/src/presentation/screens/SettingsScreen.tsx +29 -159
  145. package/src/presentation/screens/__tests__/SettingsScreen.test.tsx +322 -0
  146. package/src/presentation/screens/components/AboutLegalSection.tsx +14 -5
  147. package/src/presentation/screens/components/AppearanceSection.tsx +1 -1
  148. package/src/presentation/screens/components/LanguageSection.tsx +2 -1
  149. package/src/presentation/screens/components/NotificationsSection.tsx +19 -14
  150. package/src/presentation/screens/components/SettingsContent.tsx +167 -0
  151. package/src/presentation/screens/components/SettingsHeader.tsx +79 -0
  152. package/src/presentation/screens/hooks/__tests__/useFeatureDetection.test.tsx +261 -0
  153. package/src/presentation/screens/hooks/useFeatureDetection.ts +15 -5
  154. package/src/presentation/screens/types/CustomSection.ts +20 -0
  155. package/src/presentation/screens/types/ExtendedConfig.ts +68 -0
  156. package/src/presentation/screens/types/FeatureConfig.ts +102 -0
  157. package/src/presentation/screens/types/SettingsConfig.ts +116 -0
  158. package/src/presentation/screens/types/index.ts +20 -0
  159. package/src/presentation/screens/utils/normalizeConfig.ts +2 -1
  160. package/src/presentation/screens/types.ts +0 -263
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Settings Types - Public API
3
+ * Exports all settings-related types
4
+ */
5
+
6
+ export type { FeatureVisibility } from "./FeatureConfig";
7
+ export type {
8
+ AppearanceConfig,
9
+ LanguageConfig,
10
+ NotificationsConfig,
11
+ AboutConfig,
12
+ LegalConfig,
13
+ } from "./FeatureConfig";
14
+ export type {
15
+ AccountConfig,
16
+ SupportConfig,
17
+ DeveloperConfig,
18
+ } from "./ExtendedConfig";
19
+ export type { SettingsConfig } from "./SettingsConfig";
20
+ export type { CustomSettingsSection } from "./CustomSection";
@@ -13,6 +13,7 @@ import type {
13
13
  AccountConfig,
14
14
  SupportConfig,
15
15
  DeveloperConfig,
16
+ SettingsConfig,
16
17
  } from "../types";
17
18
 
18
19
  export interface NormalizedConfig {
@@ -79,7 +80,7 @@ function normalizeConfigValue<T>(
79
80
  * Normalize entire SettingsConfig to consistent format
80
81
  */
81
82
  export function normalizeSettingsConfig(
82
- config: any,
83
+ config: SettingsConfig | undefined,
83
84
  ): NormalizedConfig {
84
85
  return {
85
86
  appearance: normalizeConfigValue(config?.appearance, "auto"),
@@ -1,263 +0,0 @@
1
- /**
2
- * Settings Configuration Types
3
- *
4
- * Comprehensive configuration system for SettingsScreen
5
- * Supports built-in features and custom sections
6
- */
7
-
8
- import type { ComponentType, ReactNode } from "react";
9
-
10
- /**
11
- * Feature visibility configuration
12
- * - true: Always show (if navigation screen exists)
13
- * - false: Never show
14
- * - 'auto': Automatically detect (check if navigation screen exists and package is available)
15
- */
16
- export type FeatureVisibility = boolean | "auto";
17
-
18
- /**
19
- * Appearance Settings Configuration
20
- */
21
- export interface AppearanceConfig {
22
- /** Show appearance section */
23
- enabled?: FeatureVisibility;
24
- /** Custom navigation route for appearance screen */
25
- route?: string;
26
- /** Show theme toggle */
27
- showTheme?: boolean;
28
- /** Custom appearance title */
29
- title?: string;
30
- /** Custom appearance description */
31
- description?: string;
32
- }
33
-
34
- /**
35
- * Language Settings Configuration
36
- */
37
- export interface LanguageConfig {
38
- /** Show language section */
39
- enabled?: FeatureVisibility;
40
- /** Custom navigation route for language selection screen */
41
- route?: string;
42
- /** Custom language title */
43
- title?: string;
44
- /** Custom language description */
45
- description?: string;
46
- }
47
-
48
- /**
49
- * Notifications Settings Configuration
50
- */
51
- export interface NotificationsConfig {
52
- /** Show notifications section */
53
- enabled?: FeatureVisibility;
54
- /** Custom navigation route for notifications screen */
55
- route?: string;
56
- /** Show notifications toggle switch */
57
- showToggle?: boolean;
58
- /** Initial notifications state */
59
- initialValue?: boolean;
60
- /** Custom toggle handler */
61
- onToggleChange?: (value: boolean) => void;
62
- /** Custom notifications title */
63
- title?: string;
64
- /** Custom notifications description */
65
- description?: string;
66
- }
67
-
68
- /**
69
- * About Settings Configuration
70
- */
71
- export interface AboutConfig {
72
- /** Show about section */
73
- enabled?: FeatureVisibility;
74
- /** Custom navigation route for about screen */
75
- route?: string;
76
- /** Custom about title */
77
- title?: string;
78
- /** Custom about description */
79
- description?: string;
80
- }
81
-
82
- /**
83
- * Legal Settings Configuration
84
- */
85
- export interface LegalConfig {
86
- /** Show legal section */
87
- enabled?: FeatureVisibility;
88
- /** Custom navigation route for legal screen */
89
- route?: string;
90
- /** Custom legal title */
91
- title?: string;
92
- /** Custom legal description */
93
- description?: string;
94
- }
95
-
96
- /**
97
- * Account Settings Configuration
98
- */
99
- export interface AccountConfig {
100
- /** Show account section */
101
- enabled?: FeatureVisibility;
102
- /** Custom navigation route for account screen */
103
- route?: string;
104
- /** Custom account title */
105
- title?: string;
106
- /** Custom account description */
107
- description?: string;
108
- }
109
-
110
- /**
111
- * Support Settings Configuration
112
- */
113
- export interface SupportConfig {
114
- /** Show support section */
115
- enabled?: FeatureVisibility;
116
- /** Support items configuration */
117
- items?: {
118
- /** Live support configuration */
119
- liveSupport?: {
120
- enabled?: boolean;
121
- route?: string;
122
- title?: string;
123
- description?: string;
124
- };
125
- /** Help support configuration */
126
- helpSupport?: {
127
- enabled?: boolean;
128
- route?: string;
129
- title?: string;
130
- description?: string;
131
- };
132
- };
133
- /** Custom support section title */
134
- title?: string;
135
- }
136
-
137
- /**
138
- * Developer Settings Configuration
139
- */
140
- export interface DeveloperConfig {
141
- /** Show developer section (only in __DEV__ mode) */
142
- enabled?: boolean;
143
- /** Developer settings items */
144
- items?: Array<{
145
- title: string;
146
- description?: string;
147
- route?: string;
148
- onPress?: () => void;
149
- icon?: ComponentType<{ size?: number; color?: string }>;
150
- iconColor?: string;
151
- titleColor?: string;
152
- }>;
153
- /** Custom developer section title */
154
- title?: string;
155
- }
156
-
157
- /**
158
- * Main Settings Configuration
159
- *
160
- * Controls which settings features are visible in the SettingsScreen.
161
- * Each feature can be configured with:
162
- * - Simple: boolean | 'auto' (quick setup)
163
- * - Advanced: Detailed config object (full control)
164
- *
165
- * @example
166
- * // Simple configuration
167
- * const config: SettingsConfig = {
168
- * appearance: true,
169
- * notifications: 'auto',
170
- * about: false,
171
- * };
172
- *
173
- * @example
174
- * // Advanced configuration
175
- * const config: SettingsConfig = {
176
- * appearance: {
177
- * enabled: true,
178
- * route: 'CustomAppearance',
179
- * showLanguage: true,
180
- * showTheme: true,
181
- * },
182
- * notifications: {
183
- * enabled: 'auto',
184
- * showToggle: true,
185
- * initialValue: false,
186
- * onToggleChange: (value) => console.log(value),
187
- * },
188
- * support: {
189
- * enabled: true,
190
- * items: {
191
- * liveSupport: {
192
- * enabled: true,
193
- * route: 'ChatSupport',
194
- * title: 'Live Chat',
195
- * },
196
- * },
197
- * },
198
- * };
199
- */
200
- export interface SettingsConfig {
201
- /**
202
- * Appearance settings (Theme customization)
203
- * @default 'auto'
204
- */
205
- appearance?: FeatureVisibility | AppearanceConfig;
206
-
207
- /**
208
- * Language settings
209
- * @default 'auto'
210
- */
211
- language?: FeatureVisibility | LanguageConfig;
212
-
213
- /**
214
- * Notifications settings
215
- * @default 'auto'
216
- */
217
- notifications?: FeatureVisibility | NotificationsConfig;
218
-
219
- /**
220
- * About settings
221
- * @default 'auto'
222
- */
223
- about?: FeatureVisibility | AboutConfig;
224
-
225
- /**
226
- * Legal settings (Terms, Privacy Policy)
227
- * @default 'auto'
228
- */
229
- legal?: FeatureVisibility | LegalConfig;
230
-
231
- /**
232
- * Account settings
233
- * @default false
234
- */
235
- account?: FeatureVisibility | AccountConfig;
236
-
237
- /**
238
- * Support settings
239
- * @default false
240
- */
241
- support?: FeatureVisibility | SupportConfig;
242
-
243
- /**
244
- * Developer settings (only shown in __DEV__ mode)
245
- * @default false
246
- */
247
- developer?: boolean | DeveloperConfig;
248
- }
249
-
250
- /**
251
- * Custom Settings Section
252
- * Allows apps to add custom sections to the settings screen
253
- */
254
- export interface CustomSettingsSection {
255
- /** Section title */
256
- title: string;
257
- /** Section content (React nodes) */
258
- content: ReactNode;
259
- /** Section order (lower = higher in list) */
260
- order?: number;
261
- /** Section ID for identification */
262
- id?: string;
263
- }