import '../sources/source.dart'; import 'reader_direction.dart'; /// Built-in reader prefs per catalog source (used when a title has no override). class SourceReaderDefaults { const SourceReaderDefaults._(); /// ComicLand → vertical webtoon; MangaRead / MangaTown → horizontal paged. static ReaderMode modeFor(String sourceId) { switch (SourceId.tryParse(sourceId)) { case SourceId.mangaread: case SourceId.mangatown: return ReaderMode.paged; case SourceId.comicland: case null: return ReaderMode.webtoon; } } /// MangaRead / MangaTown → RTL; ComicLand falls back to global Settings. static ReadingDirection? directionFor(String sourceId) { switch (SourceId.tryParse(sourceId)) { case SourceId.mangaread: case SourceId.mangatown: return ReadingDirection.rtl; case SourceId.comicland: case null: return null; } } /// Resolve stored title mode, else [modeFor]. static ReaderMode resolveMode(String sourceId, String? storedMode) { final raw = storedMode?.trim() ?? ''; if (raw == 'paged' || raw == 'webtoon') { return ReaderMode.fromStorage(raw); } return modeFor(sourceId); } /// Resolve stored title direction, else [directionFor], else [globalFallback]. static ReadingDirection resolveDirection( String sourceId, String? storedDirection, { required ReadingDirection globalFallback, }) { final raw = storedDirection?.trim() ?? ''; if (raw == 'ltr' || raw == 'rtl') { return ReadingDirection.fromStorage(raw); } return directionFor(sourceId) ?? globalFallback; } }