feat: add sync mode setting — summaries only vs full data download

This commit is contained in:
Davide Scaini
2026-04-24 21:52:25 +02:00
parent bb44b80e97
commit a306682b52
3 changed files with 89 additions and 8 deletions
+41 -4
View File
@@ -9,10 +9,11 @@ import { deleteRemoteActivities, getSetting, setSetting, useSetting } from '@/db
export default function SettingsScreen() {
const db = useSQLiteContext();
const storedUrl = useSetting('instance_url') ?? '';
const storedHandle = useSetting('handle') ?? '';
const storedPath = useSetting('auto_import_path') ?? '';
const storedToken = useSetting('api_token');
const storedUrl = useSetting('instance_url') ?? '';
const storedHandle = useSetting('handle') ?? '';
const storedPath = useSetting('auto_import_path') ?? '';
const storedToken = useSetting('api_token');
const storedSyncMode = (useSetting('sync_mode') ?? 'summaries') as 'summaries' | 'full';
const [instanceUrl, setInstanceUrl] = useState(storedUrl);
const [handle, setHandle] = useState(storedHandle);
@@ -174,6 +175,26 @@ export default function SettingsScreen() {
</Section>
)}
<Section title="Sync">
<View style={styles.modeRow}>
<ModeButton
label="Summaries only"
active={storedSyncMode === 'summaries'}
onPress={() => setSetting(db, 'sync_mode', 'summaries')}
/>
<ModeButton
label="Full data"
active={storedSyncMode === 'full'}
onPress={() => setSetting(db, 'sync_mode', 'full')}
/>
</View>
<Text style={styles.hint}>
{storedSyncMode === 'full'
? 'Downloads map route and elevation chart for every activity during sync. Uses more storage and takes longer.'
: 'Syncs activity summaries only. Map and chart are fetched on demand when you open an activity.'}
</Text>
</Section>
<Section title="Data">
<Pressable
style={[styles.resetButton, resetArmed && styles.resetButtonArmed]}
@@ -231,6 +252,17 @@ function Field({
);
}
function ModeButton({ label, active, onPress }: { label: string; active: boolean; onPress: () => void }) {
return (
<Pressable
style={[styles.modeButton, active && styles.modeButtonActive]}
onPress={onPress}
>
<Text style={[styles.modeButtonText, active && styles.modeButtonTextActive]}>{label}</Text>
</Pressable>
);
}
function Row({ label, value }: { label: string; value: string }) {
return (
<View style={styles.row}>
@@ -282,6 +314,11 @@ const styles = StyleSheet.create({
disconnectText: { color: '#71717a', fontSize: 14 },
msgOk: { color: '#86efac', fontSize: 13, paddingHorizontal: 12, paddingBottom: 10 },
msgErr: { color: '#fca5a5', fontSize: 13, paddingHorizontal: 12, paddingBottom: 10 },
modeRow: { flexDirection: 'row', gap: 8, padding: 12 },
modeButton: { flex: 1, paddingVertical: 9, borderRadius: 8, borderWidth: 1, borderColor: '#3f3f46', alignItems: 'center' },
modeButtonActive: { backgroundColor: '#1e3a5f', borderColor: '#2563eb' },
modeButtonText: { color: '#71717a', fontSize: 13, fontWeight: '500' },
modeButtonTextActive: { color: '#60a5fa' },
resetButton: {
margin: 12, paddingVertical: 10, alignItems: 'center',
borderRadius: 8, borderWidth: 1, borderColor: '#3f3f46',