fix onboarding
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator, Platform } from 'react-native';
|
import { View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator, Platform } from 'react-native';
|
||||||
import { useNavigation } from '@react-navigation/native';
|
import { useNavigation, CommonActions } from '@react-navigation/native';
|
||||||
import type { NavigationProp } from '@react-navigation/native';
|
|
||||||
import { useDevice } from '../contexts/DeviceContext';
|
import { useDevice } from '../contexts/DeviceContext';
|
||||||
|
|
||||||
export function DeviceSetupScreen() {
|
export function DeviceSetupScreen() {
|
||||||
const navigation = useNavigation<NavigationProp<any>>();
|
const navigation = useNavigation();
|
||||||
const { register, deviceName } = useDevice();
|
const { register, deviceName } = useDevice();
|
||||||
const [name, setName] = useState(deviceName || `${Platform.OS.charAt(0).toUpperCase() + Platform.OS.slice(1)} de ${Platform.OS === 'ios' ? 'l\'utilisateur' : 'utilisateur'}`);
|
const [name, setName] = useState(deviceName || `${Platform.OS.charAt(0).toUpperCase() + Platform.OS.slice(1)} de ${Platform.OS === 'ios' ? 'l\'utilisateur' : 'utilisateur'}`);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
@@ -17,7 +16,7 @@ export function DeviceSetupScreen() {
|
|||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
await register(name.trim());
|
await register(name.trim());
|
||||||
navigation.reset({ index: 0, routes: [{ name: 'Home' }] });
|
navigation.dispatch(CommonActions.reset({ index: 0, routes: [{ name: 'Home' }] }));
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setError(err?.message || "Échec de l'enregistrement");
|
setError(err?.message || "Échec de l'enregistrement");
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { useNavigation } from '@react-navigation/native';
|
import { useNavigation, CommonActions } from '@react-navigation/native';
|
||||||
import { MaterialIcons } from '@expo/vector-icons';
|
import { MaterialIcons } from '@expo/vector-icons';
|
||||||
import { ONBOARDING_STEPS, CURRENT_ONBOARDING_VERSION } from '../config/onboarding';
|
import { ONBOARDING_STEPS, CURRENT_ONBOARDING_VERSION } from '../config/onboarding';
|
||||||
import { onboardingStorage } from '../services/onboardingStorage';
|
import { onboardingStorage } from '../services/onboardingStorage';
|
||||||
@@ -69,7 +69,7 @@ export function OnboardingScreen() {
|
|||||||
|
|
||||||
const complete = useCallback(() => {
|
const complete = useCallback(() => {
|
||||||
onboardingStorage.setCompletedVersion(CURRENT_ONBOARDING_VERSION);
|
onboardingStorage.setCompletedVersion(CURRENT_ONBOARDING_VERSION);
|
||||||
navigation.reset({ index: 0, routes: [{ name: 'Home' as never }] });
|
navigation.dispatch(CommonActions.reset({ index: 0, routes: [{ name: 'Home' }] }));
|
||||||
}, [navigation]);
|
}, [navigation]);
|
||||||
|
|
||||||
const handlePickDirectory = useCallback(async () => {
|
const handlePickDirectory = useCallback(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user