@umituz/react-native-settings 4.9.0 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-settings",
3
- "version": "4.9.0",
3
+ "version": "4.10.0",
4
4
  "description": "Settings management for React Native apps - user preferences, theme, language, notifications",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -9,6 +9,7 @@ import { Alert } from "react-native";
9
9
  import { Feather } from "@expo/vector-icons";
10
10
  import { useLocalization } from "@umituz/react-native-localization";
11
11
  import { useAppDesignTokens } from "@umituz/react-native-design-system-theme";
12
+ import { storageRepository } from "@umituz/react-native-storage";
12
13
  import { SettingsSection } from "./SettingsSection";
13
14
  import { SettingItem } from "./SettingItem";
14
15
 
@@ -18,8 +19,10 @@ const TrashIcon: React.FC<{ size?: number; color?: string }> = ({ size = 24, col
18
19
  );
19
20
 
20
21
  export interface DevSettingsProps {
21
- /** Callback to clear all storage and reset app */
22
- onClearAllData?: () => Promise<void>;
22
+ /** Enable dev settings section (default: true in __DEV__ mode) */
23
+ enabled?: boolean;
24
+ /** Optional callback after storage is cleared (e.g., reload app) */
25
+ onAfterClear?: () => Promise<void>;
23
26
  /** Custom title for the section */
24
27
  sectionTitle?: string;
25
28
  /** Custom title for clear data button */
@@ -29,7 +32,8 @@ export interface DevSettingsProps {
29
32
  }
30
33
 
31
34
  export const DevSettingsSection: React.FC<DevSettingsProps> = ({
32
- onClearAllData,
35
+ enabled = true,
36
+ onAfterClear,
33
37
  sectionTitle,
34
38
  clearDataTitle,
35
39
  clearDataDescription,
@@ -37,13 +41,8 @@ export const DevSettingsSection: React.FC<DevSettingsProps> = ({
37
41
  const { t } = useLocalization();
38
42
  const tokens = useAppDesignTokens();
39
43
 
40
- // Only render in development mode
41
- if (!__DEV__) {
42
- return null;
43
- }
44
-
45
- // Don't render if no handler provided
46
- if (!onClearAllData) {
44
+ // Only render in development mode and when enabled
45
+ if (!__DEV__ || !enabled) {
47
46
  return null;
48
47
  }
49
48
 
@@ -61,7 +60,18 @@ export const DevSettingsSection: React.FC<DevSettingsProps> = ({
61
60
  style: "destructive",
62
61
  onPress: async () => {
63
62
  try {
64
- await onClearAllData();
63
+ // Clear all storage using the package's storageRepository
64
+ await storageRepository.clearAll();
65
+
66
+ // Call optional after-clear callback (e.g., reload app)
67
+ if (onAfterClear) {
68
+ await onAfterClear();
69
+ }
70
+
71
+ Alert.alert(
72
+ t("common.success") || "Success",
73
+ t("settings.devSettings.clearData.success") || "All data cleared successfully"
74
+ );
65
75
  } catch {
66
76
  Alert.alert(
67
77
  t("common.error") || "Error",
@@ -222,7 +222,8 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
222
222
 
223
223
  {devSettings && (
224
224
  <DevSettingsSection
225
- onClearAllData={devSettings.onClearAllData}
225
+ enabled={devSettings.enabled}
226
+ onAfterClear={devSettings.onAfterClear}
226
227
  sectionTitle={devSettings.sectionTitle}
227
228
  clearDataTitle={devSettings.clearDataTitle}
228
229
  clearDataDescription={devSettings.clearDataDescription}