Developer Settings Localization Patch

This commit is contained in:
cyberalby2 2026-03-06 20:12:41 +01:00
parent b710f786e4
commit d1732bbfcd
3 changed files with 176 additions and 140 deletions

View file

@ -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",

View file

@ -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",

View file

@ -13,153 +13,177 @@ import { SettingsCard, SettingItem, ChevronRight } from './SettingsComponents';
import { useTranslation } from 'react-i18next';
const DeveloperSettingsScreen: React.FC = () => {
const navigation = useNavigation<NavigationProp<RootStackParamList>>();
const { currentTheme } = useTheme();
const { t } = useTranslation();
const insets = useSafeAreaInsets();
const navigation = useNavigation<NavigationProp<RootStackParamList>>();
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<Array<{ label: string; onPress: () => 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 (
<View style={[styles.container, { backgroundColor: currentTheme.colors.darkBackground }]}>
<StatusBar barStyle="light-content" />
<ScreenHeader title={t('settings.developer')} showBackButton onBackPress={() => navigation.goBack()} />
return (
<View
style={[
styles.container,
{ backgroundColor: currentTheme.colors.darkBackground },
]}
>
<StatusBar barStyle="light-content" />
<ScreenHeader
title={t('settings.developer')}
showBackButton
onBackPress={() => navigation.goBack()}
/>
<ScrollView
style={styles.scrollView}
showsVerticalScrollIndicator={false}
contentContainerStyle={[styles.scrollContent, { paddingBottom: insets.bottom + 24 }]}
>
<SettingsCard title={t('settings.sections.testing')}>
<SettingItem
title={'Plugin Tester'}
description={'Run a plugin and inspect logs/streams'}
icon="terminal"
onPress={() => navigation.navigate('PluginTester')}
renderControl={() => <ChevronRight />}
/>
<SettingItem
title={t('settings.items.test_onboarding')}
icon="play-circle"
onPress={() => navigation.navigate('Onboarding')}
renderControl={() => <ChevronRight />}
/>
<SettingItem
title={t('settings.items.reset_onboarding')}
icon="refresh-ccw"
onPress={handleResetOnboarding}
renderControl={() => <ChevronRight />}
/>
<SettingItem
title={t('settings.items.reset_campaigns')}
description={t('settings.items.reset_campaigns_desc')}
icon="refresh-cw"
onPress={handleResetCampaigns}
renderControl={() => <ChevronRight />}
isLast
/>
</SettingsCard>
<ScrollView
style={styles.scrollView}
showsVerticalScrollIndicator={false}
contentContainerStyle={[
styles.scrollContent,
{ paddingBottom: insets.bottom + 24 },
]}
>
<SettingsCard title={t('settings.sections.testing')}>
<SettingItem
title={t('settings.items.plugin_tester')}
description={t('settings.items.plugin_tester_desc')}
icon="terminal"
onPress={() => navigation.navigate('PluginTester')}
renderControl={() => <ChevronRight />}
/>
<SettingItem
title={t('settings.items.test_onboarding')}
icon="play-circle"
onPress={() => navigation.navigate('Onboarding')}
renderControl={() => <ChevronRight />}
/>
<SettingItem
title={t('settings.items.reset_onboarding')}
icon="refresh-ccw"
onPress={handleResetOnboarding}
renderControl={() => <ChevronRight />}
/>
<SettingItem
title={t('settings.items.reset_campaigns')}
description={t('settings.items.reset_campaigns_desc')}
icon="refresh-cw"
onPress={handleResetCampaigns}
renderControl={() => <ChevronRight />}
isLast
/>
</SettingsCard>
<SettingsCard title={t('settings.sections.danger_zone')}>
<SettingItem
title={t('settings.items.clear_all_data')}
description={t('settings.items.clear_all_data_desc')}
icon="trash-2"
onPress={handleClearAllData}
isLast
/>
</SettingsCard>
</ScrollView>
<SettingsCard title={t('settings.sections.danger_zone')}>
<SettingItem
title={t('settings.items.clear_all_data')}
description={t('settings.items.clear_all_data_desc')}
icon="trash-2"
onPress={handleClearAllData}
isLast
/>
</SettingsCard>
</ScrollView>
<CustomAlert
visible={alertVisible}
title={alertTitle}
message={alertMessage}
actions={alertActions}
onClose={() => setAlertVisible(false)}
/>
</View>
);
<CustomAlert
visible={alertVisible}
title={alertTitle}
message={alertMessage}
actions={alertActions}
onClose={() => setAlertVisible(false)}
/>
</View>
);
};
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;