Skip to content

Commit 3954a3b

Browse files
committed
✨ setting: comic info chapter reversed
1 parent 4adb696 commit 3954a3b

5 files changed

Lines changed: 63 additions & 2 deletions

File tree

ci/version.info.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
v0.0.19
22
- [x] ✨ 安卓使用音量键翻页
3+
- [x] ✨ 详情展示章节排序反转(设置项)
34
- [x] ♻️ 默认浏览模式改成封面
45
- [x] ♻️ 设置界面一些颜色的优化
56
- [x] ♻️ 恢复访问
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import 'package:flutter/material.dart';
2+
3+
import '../../src/rust/api/api.dart' as api;
4+
import '../../src/rust/udto.dart';
5+
import '../screens/components/commons.dart';
6+
7+
const _propertyName = "chapterOrderNewest";
8+
late bool _chapterOrderNewest;
9+
10+
Future initChapterOrderNewest() async {
11+
_chapterOrderNewest = false;
12+
final st = await api.loadProperty(k: _propertyName);
13+
if (st.isNotEmpty) {
14+
try {
15+
_chapterOrderNewest = bool.parse(st);
16+
} catch (e) {}
17+
}
18+
}
19+
20+
bool get currentChapterOrderNewest => _chapterOrderNewest;
21+
22+
Future chooseChapterOrderNewest(BuildContext context) async {
23+
final Map<String, bool> map = {};
24+
map["是"] = true;
25+
map["否"] = false;
26+
final newChapterOrderNewest = await chooseMapDialog(
27+
context,
28+
title: "详情展示章节排序反转",
29+
values: map,
30+
);
31+
if (newChapterOrderNewest != null) {
32+
await api.saveProperty(k: _propertyName, v: "$newChapterOrderNewest");
33+
_chapterOrderNewest = newChapterOrderNewest;
34+
}
35+
}
36+
37+
Widget chapterOrderNewestSwitch() {
38+
return StatefulBuilder(
39+
builder: (BuildContext context, void Function(void Function()) setState) {
40+
return SwitchListTile(
41+
title: const Text("详情展示章节排序反转"),
42+
value: currentChapterOrderNewest,
43+
onChanged: (value) async {
44+
await api.saveProperty(k: _propertyName, v: "$value");
45+
setState(() {
46+
_chapterOrderNewest = value;
47+
});
48+
},
49+
);
50+
},
51+
);
52+
}

lib/configs/configs.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'package:kobi/configs/versions.dart';
1414

1515
import 'api_host.dart';
1616
import 'cache_time.dart';
17+
import 'chapter_order_newest.dart';
1718
import 'collect_ordering.dart';
1819

1920
Future initConfigs() async {
@@ -29,6 +30,7 @@ Future initConfigs() async {
2930
await initLogin();
3031
await initVersion();
3132
await initNoPagerAnimation();
33+
await initChapterOrderNewest();
3234
await initComicPagerType();
3335
await initComicGridColumns();
3436
await initListVolume();

lib/screens/comic_info_screen.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:developer';
22
import 'dart:ui';
33

44
import 'package:flutter/material.dart';
5+
import 'package:kobi/configs/chapter_order_newest.dart';
56
import 'package:kobi/configs/login.dart';
67
import 'package:kobi/screens/components/commnet_card.dart';
78
import 'package:kobi/screens/components/content_loading.dart';
@@ -442,9 +443,9 @@ class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
442443
elevation: 0,
443444
color: Colors.grey.shade500.withOpacity(.3),
444445
textColor: Theme.of(context).textTheme.bodyMedium?.color,
446+
onPressed: _continueRead,
445447
child: Text(
446448
"继续阅读 : ${_viewLog!.chapterName} (${_viewLog!.pageRank + 1})"),
447-
onPressed: _continueRead,
448449
),
449450
),
450451
],
@@ -466,8 +467,8 @@ class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
466467
elevation: 0,
467468
color: Colors.grey.shade500.withOpacity(.3),
468469
textColor: Theme.of(context).textTheme.bodyMedium?.color,
469-
child: const Text("从头开始"),
470470
onPressed: _startRead,
471+
child: const Text("从头开始"),
471472
),
472473
),
473474
],
@@ -507,6 +508,9 @@ class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
507508
}
508509

509510
List<Widget> _groupChapters(List<UIComicChapter> value) {
511+
if (currentChapterOrderNewest) {
512+
value = value.reversed.toList();
513+
}
510514
return [
511515
Container(
512516
margin: const EdgeInsets.only(

lib/screens/settings_screen.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
44
import 'package:kobi/configs/api_host.dart';
55
import 'package:kobi/configs/app_orientation.dart';
66
import 'package:kobi/configs/app_theme.dart';
7+
import 'package:kobi/configs/chapter_order_newest.dart';
78
import 'package:kobi/configs/collect_ordering.dart';
89
import 'package:kobi/configs/comic_grid_columns.dart';
910
import 'package:kobi/configs/comic_pager_type.dart';
@@ -30,6 +31,7 @@ class SettingsScreen extends StatelessWidget {
3031
noPagerAnimationSwitch(),
3132
comicPagerTypeSetting(context),
3233
comicGridColumnsSetting(context),
34+
chapterOrderNewestSwitch(),
3335
if (Platform.isAndroid) listVolumeSwitch(),
3436
],
3537
),

0 commit comments

Comments
 (0)