utils/sync_settings_ui/lib/src/backup_slot.dart
Krzysztof kuhy Rudnicki 23c693da4e Add sync_settings_ui: shared Firebase-only sync settings screen
Extracts the near-identical "Sync settings" UI duplicated across 5 apps
(todo, diet_guard_app, workout_app, wake_alarm/phone_app, home_inventory)
into a single tested package. Firebase sync (primary) + optional local
backup slot; GitHub mirror UI was dropped per kuhy's explicit decision
mid-build in favor of Firebase-only, so existing apps keep their local
GitHub code untouched, just disconnected from this shared screen.

100% line coverage, flutter analyze clean under very_good_analysis.
Generalized check_no_crdt_sync_override.sh to guard any utils git
dependency (crdt_sync, sync_settings_ui), not just crdt_sync by name.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdSp6Nbrs9xvsWkCMDN9a1
2026-08-12 23:10:17 +02:00

31 lines
1.2 KiB
Dart

/// An injectable local export/import delegate for [SyncSettingsScreen]'s
/// optional "Backup" section.
///
/// Deliberately not a shared implementation: the actual export/import format
/// differs per app (todo: Markdown notes; home_inventory: inventory export;
/// workout_app: a permission-gated `BackupService`), so this package only
/// carries the label and the two callbacks. Passing `null` for
/// `SyncSettingsScreen.backup` omits the section entirely (diet_guard,
/// wake_alarm have no local backup at all).
class BackupSlot {
/// Creates a [BackupSlot] labelled [label] (e.g. `'notes'`,
/// `'inventory'`), backed by [export] and [import].
const BackupSlot({
required this.label,
required this.export,
required this.import,
});
/// Noun describing what this exports/imports, used in the section's
/// button text ("Export $label" / "Import $label").
final String label;
/// Writes every local record to the app's chosen destination (a share
/// sheet on mobile, a fixed file path on desktop -- the app's choice, not
/// this package's).
final Future<void> Function() export;
/// Reads records back from wherever [export] wrote them.
final Future<void> Function() import;
}