Skip to content

Commit

Permalink
Fix chaper order in reader
Browse files Browse the repository at this point in the history
  • Loading branch information
niuhuan committed Mar 29, 2022
1 parent 7cdce44 commit 9709d88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions lib/screens/comic_reader_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,9 @@ abstract class _ComicReaderState extends State<_ComicReader> {
if (widget.chapter.series.isEmpty) {
return false;
}
widget.chapter.series.sort((a, b) => a.sort.compareTo(b.sort));
widget.chapter.series.sort(
(a, b) => int.parse(a.sort).compareTo(int.parse(b.sort)),
);
int index = widget.chapter.series
.map((e) => e.id)
.toList()
Expand All @@ -730,7 +732,9 @@ abstract class _ComicReaderState extends State<_ComicReader> {

void _onNextAction() {
if (_hasNextEp()) {
widget.chapter.series.sort((a, b) => a.sort.compareTo(b.sort));
widget.chapter.series.sort(
(a, b) => int.parse(a.sort).compareTo(int.parse(b.sort)),
);
final ids = widget.chapter.series.map((e) => e.id).toList();
int index = ids.indexOf(widget.chapter.id);
index++;
Expand Down Expand Up @@ -761,7 +765,9 @@ class _EpChooserState extends State<_EpChooser> {
}

var entries = widget.chapter.series;
entries.sort((a, b) => a.sort.compareTo(b.sort));
entries.sort(
(a, b) => int.parse(a.sort).compareTo(int.parse(b.sort)),
);
var widgets = [
Container(height: 20),
...entries.map((e) {
Expand Down
6 changes: 3 additions & 3 deletions lib/screens/components/continue_read_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ContinueReadButton extends StatefulWidget {
}

class _ContinueReadButtonState extends State<ContinueReadButton> {

@override
Widget build(BuildContext context) {
return FutureBuilder(
Expand All @@ -42,8 +41,9 @@ class _ContinueReadButtonState extends State<ContinueReadButton> {
if (widget.album.series.isEmpty) {
widget.onChoose(widget.album.id, 0);
} else {
widget.album.series
.sort((a, b) => a.sort.compareTo(b.sort));
widget.album.series.sort(
(a, b) => int.parse(a.sort).compareTo(int.parse(b.sort)),
);
widget.onChoose(widget.album.series[0].id, 0);
}
};
Expand Down

0 comments on commit 9709d88

Please sign in to comment.