66613857e8
- Removed the constant chapterPageSize and refactored ChapterListQuery to use a simpler approach for fetching chapters. - Updated the chapter list provider to handle fetching all chapters in a single request with pagination. - Enhanced error handling for fetching chapters by resolving canonical IDs when necessary. - Modified TTS functionality to ensure proper handling of Android fallback reading and improved error management. - Added a new setting to enable/disable TTS on sentence tap. - Updated UI components in the reader screen for better user experience and added navigation buttons for chapters. - Bumped version to 1.0.3+4 in pubspec.yaml.
57 lines
1.5 KiB
Dart
57 lines
1.5 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
import 'novel_model.dart';
|
|
|
|
enum BookmarkType {
|
|
reading('reading'),
|
|
bookmarked('bookmarked');
|
|
|
|
const BookmarkType(this.value);
|
|
final String value;
|
|
|
|
static BookmarkType fromString(String? str) {
|
|
return values.firstWhere(
|
|
(e) => e.value == str,
|
|
orElse: () => BookmarkType.bookmarked,
|
|
);
|
|
}
|
|
}
|
|
|
|
class BookmarkModel extends Equatable {
|
|
const BookmarkModel({
|
|
required this.id,
|
|
required this.novelId,
|
|
this.type = BookmarkType.bookmarked,
|
|
this.lastChapterId,
|
|
this.lastChapterNumber,
|
|
this.readChapters = const [],
|
|
this.novel,
|
|
});
|
|
|
|
final String id;
|
|
final String novelId;
|
|
final BookmarkType type;
|
|
final String? lastChapterId;
|
|
final int? lastChapterNumber;
|
|
final List<int> readChapters;
|
|
final NovelModel? novel;
|
|
|
|
factory BookmarkModel.fromJson(Map<String, dynamic> json) => BookmarkModel(
|
|
id: json['id'] as String,
|
|
novelId: json['novelId'] as String,
|
|
type: BookmarkType.fromString(json['type'] as String?),
|
|
lastChapterId: json['lastChapterId'] as String?,
|
|
lastChapterNumber: json['lastChapterNumber'] as int?,
|
|
readChapters: (json['readChapters'] as List<dynamic>?)
|
|
?.map((e) => (e as num).toInt())
|
|
.toList() ??
|
|
[],
|
|
novel: json['novel'] != null
|
|
? NovelModel.fromJson(json['novel'] as Map<String, dynamic>)
|
|
: null,
|
|
);
|
|
|
|
@override
|
|
List<Object?> get props => [id, novelId, type];
|
|
}
|