c3e6d66f43
- 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.
72 lines
1.9 KiB
Dart
72 lines
1.9 KiB
Dart
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 ConsumerStatefulWidget {
|
|
const SplashScreen({super.key});
|
|
|
|
@override
|
|
ConsumerState<SplashScreen> createState() => _SplashScreenState();
|
|
}
|
|
|
|
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), () 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);
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_redirectTimer?.cancel();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const Scaffold(
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.menu_book_rounded, size: 48),
|
|
SizedBox(height: 12),
|
|
Text('Reader App'),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|