@umituz/react-native-settings 1.3.4 → 1.3.6
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
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import React, { useMemo } from 'react';
|
|
15
15
|
import { List, Divider } from 'react-native-paper';
|
|
16
|
-
import { View, TouchableOpacity, StyleSheet } from 'react-native';
|
|
16
|
+
import { DeviceEventEmitter, Alert, View, TouchableOpacity, StyleSheet } from 'react-native';
|
|
17
17
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
18
18
|
|
|
19
19
|
import { useNavigation } from '@react-navigation/native';
|
|
@@ -32,6 +32,16 @@ try {
|
|
|
32
32
|
// Package not available, notificationService will be null
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// Optional onboarding store - only import if package is available
|
|
36
|
+
let useOnboardingStore: any = null;
|
|
37
|
+
try {
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
39
|
+
const onboardingPackage = require('@umituz/react-native-onboarding');
|
|
40
|
+
useOnboardingStore = onboardingPackage.useOnboardingStore;
|
|
41
|
+
} catch {
|
|
42
|
+
// Package not available, useOnboardingStore will be null
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
/**
|
|
36
46
|
* Check if a navigation screen exists in the navigation state
|
|
37
47
|
*/
|
|
@@ -130,8 +140,50 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
|
|
|
130
140
|
};
|
|
131
141
|
|
|
132
142
|
const handleClose = () => {
|
|
143
|
+
// Try to go back in current navigator first
|
|
133
144
|
if (navigation.canGoBack()) {
|
|
134
145
|
navigation.goBack();
|
|
146
|
+
} else {
|
|
147
|
+
// If we can't go back in current navigator, try parent navigator
|
|
148
|
+
// This handles the case where Settings is the root screen of a stack
|
|
149
|
+
const parent = navigation.getParent();
|
|
150
|
+
if (parent?.canGoBack()) {
|
|
151
|
+
parent.goBack();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const handleShowOnboarding = async () => {
|
|
157
|
+
if (!useOnboardingStore) {
|
|
158
|
+
Alert.alert('Error', 'Onboarding package is not available');
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
const onboardingStore = useOnboardingStore.getState();
|
|
164
|
+
// Reset onboarding state
|
|
165
|
+
await onboardingStore.reset();
|
|
166
|
+
// Emit event to trigger navigation to onboarding
|
|
167
|
+
DeviceEventEmitter.emit('reset-onboarding');
|
|
168
|
+
// Close settings first - try parent navigator if current can't go back
|
|
169
|
+
if (navigation.canGoBack()) {
|
|
170
|
+
navigation.goBack();
|
|
171
|
+
} else {
|
|
172
|
+
const parent = navigation.getParent();
|
|
173
|
+
if (parent?.canGoBack()) {
|
|
174
|
+
parent.goBack();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Small delay to ensure navigation completes
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
DeviceEventEmitter.emit('show-onboarding');
|
|
180
|
+
}, 100);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
Alert.alert(
|
|
183
|
+
'Error',
|
|
184
|
+
'Failed to show onboarding. Please try again.',
|
|
185
|
+
[{ text: 'OK' }],
|
|
186
|
+
);
|
|
135
187
|
}
|
|
136
188
|
};
|
|
137
189
|
|
|
@@ -200,6 +252,21 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
|
|
|
200
252
|
</List.Section>
|
|
201
253
|
)}
|
|
202
254
|
|
|
255
|
+
{/* Development/Test: Show Onboarding */}
|
|
256
|
+
{__DEV__ && useOnboardingStore && (
|
|
257
|
+
<List.Section style={{ marginBottom: 8 }}>
|
|
258
|
+
<List.Subheader style={{ color: theme.colors.textSecondary }}>Development</List.Subheader>
|
|
259
|
+
<SettingItem
|
|
260
|
+
icon="Play"
|
|
261
|
+
iconGradient={theme.colors.settingGradients.info as unknown as string[]}
|
|
262
|
+
title="Show Onboarding (Dev)"
|
|
263
|
+
description="Navigate to onboarding screen"
|
|
264
|
+
onPress={handleShowOnboarding}
|
|
265
|
+
testID="show-onboarding-button"
|
|
266
|
+
/>
|
|
267
|
+
</List.Section>
|
|
268
|
+
)}
|
|
269
|
+
|
|
203
270
|
{/* About & Legal Section */}
|
|
204
271
|
{(features.about || features.legal) && (
|
|
205
272
|
<List.Section style={{ marginBottom: 8 }}>
|