feat: navigation store feat: implement OPDS entry caching system Add comprehensive caching for OPDS publications with local image storage and Dublin Core Terms metadata extraction. This enables offline viewing, fixes Library screen to show book titles and covers, and improves overall UX. - Add publications table with full metadata (title, authors, series, publisher, ISBN, language) - Implement local image cache service for covers and thumbnails - Extract DCTerms metadata (series, publisher, language, ISBN) from OPDS feeds - Link reading progress to cached publications - Update Library screen to display cached publication data and covers - Cache publications automatically when starting to read - Fix navigation stack issues by using context.push() instead of context.go() - Add explicit back button to EPUB reader with proper PopScope handling - Implement UNIQUE constraint on reading_progress to prevent duplicates - Save reading progress on screen dispose for both EPUB and image readers Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
part 'navigation_provider.g.dart';
|
|
|
|
/// Key for storing last tab index in SharedPreferences
|
|
const String _lastTabIndexKey = 'last_tab_index';
|
|
|
|
/// Default tab index (Library tab)
|
|
const int _defaultTabIndex = 0;
|
|
|
|
/// Provider for navigation state management and persistence
|
|
@riverpod
|
|
class NavigationState extends _$NavigationState {
|
|
@override
|
|
int build() {
|
|
_loadLastTabIndex();
|
|
return _defaultTabIndex; // Default value until loaded
|
|
}
|
|
|
|
/// Load last tab index from SharedPreferences
|
|
Future<void> _loadLastTabIndex() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final lastIndex = prefs.getInt(_lastTabIndexKey);
|
|
|
|
if (lastIndex != null && lastIndex >= 0 && lastIndex <= 2) {
|
|
state = lastIndex;
|
|
}
|
|
}
|
|
|
|
/// Set tab index and persist to SharedPreferences
|
|
Future<void> setTabIndex(int index) async {
|
|
if (index < 0 || index > 2) {
|
|
return; // Invalid index, ignore
|
|
}
|
|
|
|
state = index;
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await prefs.setInt(_lastTabIndexKey, index);
|
|
}
|
|
}
|