feat: Implement TTS playback store and enhance reading progress synchronization
- Added ReaderTtsPlaybackStore to manage TTS start requests with a maximum of 4 pending requests. - Updated app configuration to use a production API URL. - Enhanced BookmarkModel to infer type when not provided by the API for backward compatibility. - Introduced methods in LocalStore for saving, loading, and clearing the last route path. - Implemented syncProgress method in BookshelfNotifier to update reading progress and bookmarks from the server. - Modified ReaderScreen to handle chapter navigation and TTS playback more effectively, including auto-start logic. - Updated TtsPlayerWidget to accept additional parameters for chapter navigation. - Enhanced TtsNotifier to handle new parameters for TTS requests and manage playback state. - Improved SplashScreen to restore the last visited route after splash screen display.
This commit is contained in:
@@ -1,25 +1,48 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../app/router/route_names.dart';
|
||||
import '../../../core/storage/local_store.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
class SplashScreen extends ConsumerStatefulWidget {
|
||||
const SplashScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SplashScreen> createState() => _SplashScreenState();
|
||||
ConsumerState<SplashScreen> createState() => _SplashScreenState();
|
||||
}
|
||||
|
||||
class _SplashScreenState extends State<SplashScreen> {
|
||||
class _SplashScreenState extends ConsumerState<SplashScreen> {
|
||||
Timer? _redirectTimer;
|
||||
|
||||
bool _isRestorableRoute(String path) {
|
||||
if (path.isEmpty || path == RouteNames.splash) return false;
|
||||
return path == RouteNames.home ||
|
||||
path == RouteNames.login ||
|
||||
path == RouteNames.search ||
|
||||
path.startsWith('${RouteNames.search}?') ||
|
||||
path == RouteNames.genres ||
|
||||
path == RouteNames.bookshelf ||
|
||||
path == RouteNames.profile ||
|
||||
path == RouteNames.settings ||
|
||||
path.startsWith('/novel/') ||
|
||||
path.startsWith('/reader/') ||
|
||||
path.startsWith('/comments/');
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_redirectTimer = Timer(const Duration(milliseconds: 700), () {
|
||||
_redirectTimer = Timer(const Duration(milliseconds: 700), () async {
|
||||
if (!mounted) return;
|
||||
final lastPath = await ref.read(localStoreProvider).loadLastRoutePath();
|
||||
if (!mounted) return;
|
||||
if (lastPath != null && _isRestorableRoute(lastPath)) {
|
||||
context.go(lastPath);
|
||||
return;
|
||||
}
|
||||
context.go(RouteNames.home);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user