diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index ce1a6a5b..5548bef5 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -759,12 +759,18 @@ "reset_campaigns": "Reset Campaigns", "reset_campaigns_desc": "Clear campaign impressions", "clear_all_data": "Clear All Data", - "clear_all_data_desc": "Reset all settings and cached data", + "clear_all_data_desc": "Reset all settings and cached data.", "enable_intro_submission": "Enable Intro Submission", "enable_intro_submission_desc": "Contribute timestamps to the community", "introdb_api_key": "INTRODB API KEY", "introdb_key_placeholder": "Enter your API Key", - "api_key_cleared": "API Key Cleared" + "api_key_cleared": "API Key Cleared", + "plugin_tester": "Plugin Tester", + "plugin_tester_desc": "Run a plugin and inspect logs/streams", + "onboarding_success_desc": "Onboarding has been reset. Restart the app to see the onboarding flow.", + "clear_all_data_prompt": "This will reset all settings and clear all cached data. Are you sure?", + "clear_all_data_success": "All data cleared. Please restart the app.", + "clear_all_data_error": "Failed to clear data." }, "options": { "horizontal": "Horizontal", diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json index bf62fc49..8ccba9fd 100644 --- a/src/i18n/locales/it.json +++ b/src/i18n/locales/it.json @@ -760,11 +760,17 @@ "reset_campaigns_desc": "Cancella le impressioni delle campagne", "clear_all_data": "Cancella tutti i dati", "clear_all_data_desc": "Ripristina tutte le impostazioni e i dati memorizzati", - "enable_intro_submission":"Abilita contributi IntroDB", - "enable_intro_submission_desc":"Contribuisci con i tuoi timestamp", - "introdb_api_key":"CHIAVE API INTRODB", - "introdb_key_placeholder":"Inserisci la tua chiave API", - "api_key_cleared":"Chiave API rimossa" + "enable_intro_submission": "Abilita contributi IntroDB", + "enable_intro_submission_desc": "Contribuisci con i tuoi timestamp", + "introdb_api_key": "CHIAVE API INTRODB", + "introdb_key_placeholder": "Inserisci la tua chiave API", + "api_key_cleared": "Chiave API rimossa", + "plugin_tester": "Plugin Tester", + "plugin_tester_desc": "Esegui un plugin vedendo i log e i flussi", + "onboarding_success_desc": "La schermata iniziale è stata resettata . Riavvia l'app per vedere il flusso.", + "clear_all_data_prompt": "Questo ripristinerà tutte le impostazioni cancellando anche i dati salvati. Sei sicuro?", + "clear_all_data_success": "Tutti i dati sono stati cancellati. Riavvia l'app", + "clear_all_data_error": "C'è stato un errore nella cancellazione dei dati" }, "options": { "horizontal": "Orizzontale", diff --git a/src/screens/settings/DeveloperSettingsScreen.tsx b/src/screens/settings/DeveloperSettingsScreen.tsx index 8b002e27..a7d6ab2c 100644 --- a/src/screens/settings/DeveloperSettingsScreen.tsx +++ b/src/screens/settings/DeveloperSettingsScreen.tsx @@ -13,153 +13,177 @@ import { SettingsCard, SettingItem, ChevronRight } from './SettingsComponents'; import { useTranslation } from 'react-i18next'; const DeveloperSettingsScreen: React.FC = () => { - const navigation = useNavigation>(); - const { currentTheme } = useTheme(); - const { t } = useTranslation(); - const insets = useSafeAreaInsets(); + const navigation = useNavigation>(); + const { currentTheme } = useTheme(); + const { t } = useTranslation(); + const insets = useSafeAreaInsets(); - const [developerModeEnabled, setDeveloperModeEnabled] = useState(__DEV__); - const [alertVisible, setAlertVisible] = useState(false); - const [alertTitle, setAlertTitle] = useState(''); - const [alertMessage, setAlertMessage] = useState(''); - const [alertActions, setAlertActions] = useState void }>>([]); + const [developerModeEnabled, setDeveloperModeEnabled] = useState(__DEV__); + const [alertVisible, setAlertVisible] = useState(false); + const [alertTitle, setAlertTitle] = useState(''); + const [alertMessage, setAlertMessage] = useState(''); + const [alertActions, setAlertActions] = useState< + Array<{ label: string; onPress: () => void }> + >([]); - // Load developer mode state on mount - useEffect(() => { - const loadDevModeState = async () => { - try { - const devModeEnabled = await mmkvStorage.getItem('developer_mode_enabled'); - setDeveloperModeEnabled(__DEV__ || devModeEnabled === 'true'); - } catch (error) { - console.error('Failed to load developer mode state:', error); - } - }; - loadDevModeState(); - }, []); + // Load developer mode state on mount + useEffect(() => { + const loadDevModeState = async () => { + try { + const devModeEnabled = await mmkvStorage.getItem('developer_mode_enabled'); + setDeveloperModeEnabled(__DEV__ || devModeEnabled === 'true'); + } catch (error) { + console.error('Failed to load developer mode state:', error); + } + }; + loadDevModeState(); + }, []); - const openAlert = ( - title: string, - message: string, - actions?: Array<{ label: string; onPress: () => void }> - ) => { - setAlertTitle(title); - setAlertMessage(message); - setAlertActions(actions && actions.length > 0 ? actions : [{ label: 'OK', onPress: () => { } }]); - setAlertVisible(true); - }; + const openAlert = ( + title: string, + message: string, + actions?: Array<{ label: string; onPress: () => void }>, + ) => { + setAlertTitle(title); + setAlertMessage(message); + setAlertActions( + actions && actions.length > 0 + ? actions + : [{ label: 'OK', onPress: () => {} }], + ); + setAlertVisible(true); + }; - const handleResetOnboarding = async () => { - try { - await mmkvStorage.removeItem('hasCompletedOnboarding'); - openAlert('Success', 'Onboarding has been reset. Restart the app to see the onboarding flow.'); - } catch (error) { - openAlert('Error', 'Failed to reset onboarding.'); - } - }; + const handleResetOnboarding = async () => { + try { + await mmkvStorage.removeItem('hasCompletedOnboarding'); + openAlert(t('common.success'), t('settings.items.onboarding_success_desc')); + } catch (error) { + openAlert('Error', 'Failed to reset onboarding.'); + } + }; - const handleResetCampaigns = async () => { - await campaignService.resetCampaigns(); - openAlert('Success', 'Campaign history reset. Restart app to see posters again.'); - }; + const handleResetCampaigns = async () => { + await campaignService.resetCampaigns(); + openAlert( + 'Success', + 'Campaign history reset. Restart app to see posters again.', + ); + }; - const handleClearAllData = () => { - openAlert( - 'Clear All Data', - 'This will reset all settings and clear all cached data. Are you sure?', - [ - { label: 'Cancel', onPress: () => { } }, - { - label: 'Clear', - onPress: async () => { - try { - await mmkvStorage.clear(); - openAlert('Success', 'All data cleared. Please restart the app.'); - } catch (error) { - openAlert('Error', 'Failed to clear data.'); - } - } - } - ] - ); - }; + const handleClearAllData = () => { + openAlert( + t('settings.items.clear_all_data'), + t('settings.items.clear_all_data_prompt'), + [ + { label: t('common.cancel'), onPress: () => {} }, + { + label: t('common.clear'), + onPress: async () => { + try { + await mmkvStorage.clear(); + openAlert( + t('common.success'), + t('settings.items.clear_all_data_success'), + ); + } catch (error) { + openAlert(t('common.error'), t('settings.items.clear_all_data_error')); + } + }, + }, + ], + ); + }; - // Only show if developer mode is enabled (via __DEV__ or manually unlocked) - if (!developerModeEnabled) { - return null; - } + // Only show if developer mode is enabled (via __DEV__ or manually unlocked) + if (!developerModeEnabled) { + return null; + } - return ( - - - navigation.goBack()} /> + return ( + + + navigation.goBack()} + /> - - - navigation.navigate('PluginTester')} - renderControl={() => } - /> - navigation.navigate('Onboarding')} - renderControl={() => } - /> - } - /> - } - isLast - /> - + + + navigation.navigate('PluginTester')} + renderControl={() => } + /> + navigation.navigate('Onboarding')} + renderControl={() => } + /> + } + /> + } + isLast + /> + - - - - + + + + - setAlertVisible(false)} - /> - - ); + setAlertVisible(false)} + /> + + ); }; const styles = StyleSheet.create({ - container: { - flex: 1, - }, - scrollView: { - flex: 1, - }, - scrollContent: { - paddingTop: 16, - }, + container: { + flex: 1, + }, + scrollView: { + flex: 1, + }, + scrollContent: { + paddingTop: 16, + }, }); export default DeveloperSettingsScreen;