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