264 lines
7.8 KiB
TypeScript
264 lines
7.8 KiB
TypeScript
/*
|
|
* File: navigationUtils.ts
|
|
* Description: Navigation utilities for Settings module
|
|
* Design & Developed by Tech4Biz Solutions
|
|
* Copyright (c) Spurrin Innovations. All rights reserved.
|
|
*/
|
|
|
|
import { SettingsNavigationProp } from './navigationTypes';
|
|
import { UserProfile, UserPreferences } from '../../../shared/types';
|
|
|
|
/**
|
|
* SettingsNavigationUtils - Utility functions for Settings module navigation
|
|
*
|
|
* This module provides helper functions for common navigation patterns
|
|
* within the Settings module, ensuring consistent navigation behavior.
|
|
*/
|
|
|
|
/**
|
|
* Navigate to Settings screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param params - Optional parameters for the settings screen
|
|
*/
|
|
export const navigateToSettings = (
|
|
navigation: SettingsNavigationProp,
|
|
params?: {
|
|
section?: 'profile' | 'security' | 'notifications' | 'clinical' | 'privacy' | 'accessibility' | 'about' | 'help';
|
|
refresh?: boolean;
|
|
}
|
|
): void => {
|
|
navigation.navigate('Settings', params);
|
|
};
|
|
|
|
/**
|
|
* Navigate to Profile Edit screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param profile - Optional profile data to pre-populate
|
|
* @param fromScreen - Optional source screen for back navigation
|
|
*/
|
|
export const navigateToProfileEdit = (
|
|
navigation: SettingsNavigationProp,
|
|
profile?: UserProfile,
|
|
fromScreen?: keyof import('./navigationTypes').SettingsStackParamList
|
|
): void => {
|
|
navigation.navigate('ProfileEdit', {
|
|
profile,
|
|
fromScreen,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Navigate to Security Settings screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param showBiometricSetup - Optional flag to show biometric setup
|
|
* @param fromScreen - Optional source screen for back navigation
|
|
*/
|
|
export const navigateToSecuritySettings = (
|
|
navigation: SettingsNavigationProp,
|
|
showBiometricSetup?: boolean,
|
|
fromScreen?: keyof import('./navigationTypes').SettingsStackParamList
|
|
): void => {
|
|
navigation.navigate('SecuritySettings', {
|
|
showBiometricSetup,
|
|
fromScreen,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Navigate to Notification Settings screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param preferences - Optional notification preferences to pre-populate
|
|
* @param fromScreen - Optional source screen for back navigation
|
|
*/
|
|
export const navigateToNotificationSettings = (
|
|
navigation: SettingsNavigationProp,
|
|
preferences?: UserPreferences['notificationPreferences'],
|
|
fromScreen?: keyof import('./navigationTypes').SettingsStackParamList
|
|
): void => {
|
|
navigation.navigate('NotificationSettings', {
|
|
preferences,
|
|
fromScreen,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Navigate to Clinical Preferences screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param preferences - Optional clinical preferences to pre-populate
|
|
* @param fromScreen - Optional source screen for back navigation
|
|
*/
|
|
export const navigateToClinicalPreferences = (
|
|
navigation: SettingsNavigationProp,
|
|
preferences?: UserPreferences['clinicalPreferences'],
|
|
fromScreen?: keyof import('./navigationTypes').SettingsStackParamList
|
|
): void => {
|
|
navigation.navigate('ClinicalPreferences', {
|
|
preferences,
|
|
fromScreen,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Navigate to Privacy Settings screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param preferences - Optional privacy preferences to pre-populate
|
|
* @param fromScreen - Optional source screen for back navigation
|
|
*/
|
|
export const navigateToPrivacySettings = (
|
|
navigation: SettingsNavigationProp,
|
|
preferences?: UserPreferences['privacyPreferences'],
|
|
fromScreen?: keyof import('./navigationTypes').SettingsStackParamList
|
|
): void => {
|
|
navigation.navigate('PrivacySettings', {
|
|
preferences,
|
|
fromScreen,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Navigate to Accessibility Settings screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param preferences - Optional accessibility preferences to pre-populate
|
|
* @param fromScreen - Optional source screen for back navigation
|
|
*/
|
|
export const navigateToAccessibilitySettings = (
|
|
navigation: SettingsNavigationProp,
|
|
preferences?: UserPreferences['accessibilityPreferences'],
|
|
fromScreen?: keyof import('./navigationTypes').SettingsStackParamList
|
|
): void => {
|
|
navigation.navigate('AccessibilitySettings', {
|
|
preferences,
|
|
fromScreen,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Navigate to About screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param showChangelog - Optional flag to show changelog
|
|
* @param showLicenses - Optional flag to show licenses
|
|
*/
|
|
export const navigateToAbout = (
|
|
navigation: SettingsNavigationProp,
|
|
showChangelog?: boolean,
|
|
showLicenses?: boolean
|
|
): void => {
|
|
navigation.navigate('About', {
|
|
showChangelog,
|
|
showLicenses,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Navigate to Help & Support screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param topic - Optional help topic to navigate to
|
|
* @param showContact - Optional flag to show contact form
|
|
*/
|
|
export const navigateToHelpSupport = (
|
|
navigation: SettingsNavigationProp,
|
|
topic?: 'faq' | 'troubleshooting' | 'contact' | 'feedback',
|
|
showContact?: boolean
|
|
): void => {
|
|
navigation.navigate('HelpSupport', {
|
|
topic,
|
|
showContact,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Go back to previous screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
*/
|
|
export const goBack = (navigation: SettingsNavigationProp): void => {
|
|
if (navigation.canGoBack()) {
|
|
navigation.goBack();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Reset navigation stack to Settings screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param params - Optional parameters for the settings screen
|
|
*/
|
|
export const resetToSettings = (
|
|
navigation: SettingsNavigationProp,
|
|
params?: {
|
|
section?: 'profile' | 'security' | 'notifications' | 'clinical' | 'privacy' | 'accessibility' | 'about' | 'help';
|
|
refresh?: boolean;
|
|
}
|
|
): void => {
|
|
navigation.reset({
|
|
index: 0,
|
|
routes: [{ name: 'Settings', params }],
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Replace current screen with Settings screen
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param params - Optional parameters for the settings screen
|
|
*/
|
|
export const replaceWithSettings = (
|
|
navigation: SettingsNavigationProp,
|
|
params?: {
|
|
section?: 'profile' | 'security' | 'notifications' | 'clinical' | 'privacy' | 'accessibility' | 'about' | 'help';
|
|
refresh?: boolean;
|
|
}
|
|
): void => {
|
|
navigation.replace('Settings', params);
|
|
};
|
|
|
|
/**
|
|
* Navigate to Settings and clear back stack
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param params - Optional parameters for the settings screen
|
|
*/
|
|
export const navigateToSettingsAndClearStack = (
|
|
navigation: SettingsNavigationProp,
|
|
params?: {
|
|
section?: 'profile' | 'security' | 'notifications' | 'clinical' | 'privacy' | 'accessibility' | 'about' | 'help';
|
|
refresh?: boolean;
|
|
}
|
|
): void => {
|
|
navigation.reset({
|
|
index: 0,
|
|
routes: [{ name: 'Settings', params }],
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Navigate to Profile Edit and clear back stack
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param profile - Optional profile data to pre-populate
|
|
*/
|
|
export const navigateToProfileEditAndClearStack = (
|
|
navigation: SettingsNavigationProp,
|
|
profile?: UserProfile
|
|
): void => {
|
|
navigation.reset({
|
|
index: 0,
|
|
routes: [{ name: 'ProfileEdit', params: { profile } }],
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Navigate to Security Settings and clear back stack
|
|
* @param navigation - Navigation prop from React Navigation
|
|
* @param showBiometricSetup - Optional flag to show biometric setup
|
|
*/
|
|
export const navigateToSecuritySettingsAndClearStack = (
|
|
navigation: SettingsNavigationProp,
|
|
showBiometricSetup?: boolean
|
|
): void => {
|
|
navigation.reset({
|
|
index: 0,
|
|
routes: [{ name: 'SecuritySettings', params: { showBiometricSetup } }],
|
|
});
|
|
};
|
|
|
|
/*
|
|
* End of File: navigationUtils.ts
|
|
* Design & Developed by Tech4Biz Solutions
|
|
* Copyright (c) Spurrin Innovations. All rights reserved.
|
|
*/
|