@umituz/react-native-settings 4.8.0 → 4.9.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.8.0",
3
+ "version": "4.9.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",
package/src/index.ts CHANGED
@@ -76,3 +76,5 @@ export type { CloudSyncSettingProps } from './presentation/components/CloudSyncS
76
76
  export { StorageClearSetting } from './presentation/components/StorageClearSetting';
77
77
  export type { StorageClearSettingProps } from './presentation/components/StorageClearSetting';
78
78
 
79
+ export { DevSettingsSection } from './presentation/components/DevSettingsSection';
80
+ export type { DevSettingsProps } from './presentation/components/DevSettingsSection';
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Dev Settings Section Component
3
+ * Only visible in __DEV__ mode
4
+ * Provides development utilities like clearing storage
5
+ */
6
+
7
+ import React from "react";
8
+ import { Alert } from "react-native";
9
+ import { Feather } from "@expo/vector-icons";
10
+ import { useLocalization } from "@umituz/react-native-localization";
11
+ import { useAppDesignTokens } from "@umituz/react-native-design-system-theme";
12
+ import { SettingsSection } from "./SettingsSection";
13
+ import { SettingItem } from "./SettingItem";
14
+
15
+ // Icon wrapper for SettingItem compatibility
16
+ const TrashIcon: React.FC<{ size?: number; color?: string }> = ({ size = 24, color }) => (
17
+ <Feather name="trash-2" size={size} color={color} />
18
+ );
19
+
20
+ export interface DevSettingsProps {
21
+ /** Callback to clear all storage and reset app */
22
+ onClearAllData?: () => Promise<void>;
23
+ /** Custom title for the section */
24
+ sectionTitle?: string;
25
+ /** Custom title for clear data button */
26
+ clearDataTitle?: string;
27
+ /** Custom description for clear data button */
28
+ clearDataDescription?: string;
29
+ }
30
+
31
+ export const DevSettingsSection: React.FC<DevSettingsProps> = ({
32
+ onClearAllData,
33
+ sectionTitle,
34
+ clearDataTitle,
35
+ clearDataDescription,
36
+ }) => {
37
+ const { t } = useLocalization();
38
+ const tokens = useAppDesignTokens();
39
+
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) {
47
+ return null;
48
+ }
49
+
50
+ const handleClearData = () => {
51
+ Alert.alert(
52
+ t("settings.devSettings.clearData.confirmTitle") || "Clear All Data?",
53
+ t("settings.devSettings.clearData.confirmMessage") || "This will clear all app data and reset to initial state. This action cannot be undone.",
54
+ [
55
+ {
56
+ text: t("common.cancel") || "Cancel",
57
+ style: "cancel",
58
+ },
59
+ {
60
+ text: t("common.confirm") || "Confirm",
61
+ style: "destructive",
62
+ onPress: async () => {
63
+ try {
64
+ await onClearAllData();
65
+ } catch {
66
+ Alert.alert(
67
+ t("common.error") || "Error",
68
+ t("settings.devSettings.clearData.error") || "Failed to clear data"
69
+ );
70
+ }
71
+ },
72
+ },
73
+ ]
74
+ );
75
+ };
76
+
77
+ return (
78
+ <SettingsSection
79
+ title={sectionTitle || t("settings.devSettings.title") || "Developer"}
80
+ >
81
+ <SettingItem
82
+ icon={TrashIcon}
83
+ title={clearDataTitle || t("settings.devSettings.clearData.title") || "Clear All Data"}
84
+ value={
85
+ clearDataDescription ||
86
+ t("settings.devSettings.clearData.description") || "Reset app to initial state (DEV only)"
87
+ }
88
+ onPress={handleClearData}
89
+ iconColor={tokens.colors.error}
90
+ titleColor={tokens.colors.error}
91
+ isLast={true}
92
+ />
93
+ </SettingsSection>
94
+ );
95
+ };
@@ -11,6 +11,7 @@ import { useAppDesignTokens } from "@umituz/react-native-design-system-theme";
11
11
  import { SettingsScreen } from "../screens/SettingsScreen";
12
12
  import { AppearanceScreen } from "../screens/AppearanceScreen";
13
13
  import type { SettingsConfig } from "../screens/types";
14
+ import type { DevSettingsProps } from "../components/DevSettingsSection";
14
15
 
15
16
  // Default param list - can be extended by apps
16
17
  export type SettingsStackParamList = {
@@ -58,6 +59,11 @@ export interface SettingsStackNavigatorProps {
58
59
  component: React.ComponentType<any>;
59
60
  options?: any;
60
61
  }>;
62
+
63
+ /**
64
+ * Dev settings (only shown in __DEV__ mode)
65
+ */
66
+ devSettings?: DevSettingsProps;
61
67
  }
62
68
 
63
69
  const Stack = createStackNavigator<SettingsStackParamList>();
@@ -68,6 +74,7 @@ export const SettingsStackNavigator: React.FC<SettingsStackNavigatorProps> = ({
68
74
  showUserProfile = false,
69
75
  userProfile,
70
76
  additionalScreens = [],
77
+ devSettings,
71
78
  }) => {
72
79
  const tokens = useAppDesignTokens();
73
80
 
@@ -93,11 +100,12 @@ export const SettingsStackNavigator: React.FC<SettingsStackNavigatorProps> = ({
93
100
  appVersion={appVersion}
94
101
  showUserProfile={showUserProfile}
95
102
  userProfile={userProfile}
103
+ devSettings={devSettings}
96
104
  />
97
105
  );
98
106
  Wrapper.displayName = "SettingsScreenWrapper";
99
107
  return Wrapper;
100
- }, [config, appVersion, showUserProfile, userProfile]);
108
+ }, [config, appVersion, showUserProfile, userProfile, devSettings]);
101
109
 
102
110
  return (
103
111
  <Stack.Navigator screenOptions={screenOptions}>
@@ -16,6 +16,7 @@ import { SettingsErrorBoundary } from "../components/SettingsErrorBoundary";
16
16
  import { normalizeSettingsConfig } from "./utils/normalizeConfig";
17
17
  import { useFeatureDetection } from "./hooks/useFeatureDetection";
18
18
  import type { SettingsConfig, CustomSettingsSection } from "./types";
19
+ import type { DevSettingsProps } from "../components/DevSettingsSection";
19
20
 
20
21
  export interface SettingsScreenProps {
21
22
  config?: SettingsConfig;
@@ -48,6 +49,8 @@ export interface SettingsScreenProps {
48
49
  featureOptions?: {
49
50
  notificationServiceAvailable?: boolean;
50
51
  };
52
+ /** Dev settings (only shown in __DEV__ mode) */
53
+ devSettings?: DevSettingsProps;
51
54
  }
52
55
 
53
56
  export const SettingsScreen: React.FC<SettingsScreenProps> = ({
@@ -61,6 +64,7 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
61
64
  showCloseButton = false,
62
65
  onClose,
63
66
  featureOptions,
67
+ devSettings,
64
68
  }) => {
65
69
  const navigation = useNavigation();
66
70
  const { themeMode } = useDesignSystemTheme();
@@ -92,6 +96,7 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
92
96
  appVersion={appVersion}
93
97
  customSections={customSections}
94
98
  showCloseButton={showCloseButton}
99
+ devSettings={devSettings}
95
100
  />
96
101
  </SettingsErrorBoundary>
97
102
  </View>
@@ -11,6 +11,7 @@ import { useLocalization } from "@umituz/react-native-localization";
11
11
  import { SettingsFooter } from "../../components/SettingsFooter";
12
12
  import { UserProfileHeader } from "../../components/UserProfileHeader";
13
13
  import { SettingsSection } from "../../components/SettingsSection";
14
+ import { DevSettingsSection, DevSettingsProps } from "../../components/DevSettingsSection";
14
15
  import { NotificationsSection } from "@umituz/react-native-notifications";
15
16
  import { AboutSection } from "@umituz/react-native-about";
16
17
  import { LegalSection } from "@umituz/react-native-legal";
@@ -59,6 +60,8 @@ interface SettingsContentProps {
59
60
  appVersion?: string;
60
61
  customSections?: CustomSettingsSection[];
61
62
  showCloseButton?: boolean;
63
+ /** Dev settings (only shown in __DEV__ mode) */
64
+ devSettings?: DevSettingsProps;
62
65
  }
63
66
 
64
67
  export const SettingsContent: React.FC<SettingsContentProps> = ({
@@ -72,6 +75,7 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
72
75
  appVersion,
73
76
  customSections = [],
74
77
  showCloseButton = false,
78
+ devSettings,
75
79
  }) => {
76
80
  const tokens = useAppDesignTokens();
77
81
  const insets = useSafeAreaInsets();
@@ -216,6 +220,15 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
216
220
  </View>
217
221
  )}
218
222
 
223
+ {devSettings && (
224
+ <DevSettingsSection
225
+ onClearAllData={devSettings.onClearAllData}
226
+ sectionTitle={devSettings.sectionTitle}
227
+ clearDataTitle={devSettings.clearDataTitle}
228
+ clearDataDescription={devSettings.clearDataDescription}
229
+ />
230
+ )}
231
+
219
232
  {showFooter && <SettingsFooter versionText={footerText} appVersion={appVersion} />}
220
233
  </ScrollView>
221
234
  );