2021-09-29 23:57:09 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_search_bar/flutter_search_bar.dart';
|
2021-11-11 03:00:38 +00:00
|
|
|
import 'package:pikapika/basic/Common.dart';
|
|
|
|
import 'package:pikapika/basic/config/ShadowCategories.dart';
|
2022-06-29 19:02:01 +00:00
|
|
|
import 'package:pikapika/basic/config/ShadowCategoriesMode.dart';
|
2021-11-11 03:00:38 +00:00
|
|
|
import 'package:pikapika/basic/store/Categories.dart';
|
|
|
|
import 'package:pikapika/basic/config/ListLayout.dart';
|
|
|
|
import 'package:pikapika/basic/Method.dart';
|
2021-09-29 23:57:09 +00:00
|
|
|
import '../basic/Entities.dart';
|
2023-02-16 08:33:16 +00:00
|
|
|
import '../basic/config/Address.dart';
|
2023-01-31 10:50:51 +00:00
|
|
|
import '../basic/config/IconLoading.dart';
|
2021-09-29 23:57:09 +00:00
|
|
|
import 'SearchScreen.dart';
|
|
|
|
import 'components/ComicPager.dart';
|
2023-02-16 08:14:29 +00:00
|
|
|
import 'components/Common.dart';
|
2022-03-19 04:12:27 +00:00
|
|
|
import 'components/RightClickPop.dart';
|
2021-09-29 23:57:09 +00:00
|
|
|
|
|
|
|
// 漫画列表
|
|
|
|
class ComicsScreen extends StatefulWidget {
|
|
|
|
final String? category; // 指定分类
|
|
|
|
final String? tag; // 指定标签
|
|
|
|
final String? creatorId; // 指定上传者
|
|
|
|
final String? creatorName; // 上传者名称 (仅显示)
|
|
|
|
final String? chineseTeam;
|
|
|
|
|
|
|
|
const ComicsScreen({
|
|
|
|
Key? key,
|
|
|
|
this.category,
|
|
|
|
this.tag,
|
|
|
|
this.creatorId,
|
|
|
|
this.creatorName,
|
|
|
|
this.chineseTeam,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => _ComicsScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ComicsScreenState extends State<ComicsScreen> {
|
2022-03-17 03:31:25 +00:00
|
|
|
late final SearchBar _categorySearchBar = SearchBar(
|
2021-09-29 23:57:09 +00:00
|
|
|
hintText: '搜索分类 - ${categoryTitle(widget.category)}',
|
|
|
|
inBar: false,
|
|
|
|
setState: setState,
|
|
|
|
onSubmitted: (value) {
|
|
|
|
if (value.isNotEmpty) {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
2023-01-31 10:50:51 +00:00
|
|
|
mixRoute(
|
2021-09-29 23:57:09 +00:00
|
|
|
builder: (context) =>
|
|
|
|
SearchScreen(keyword: value, category: widget.category),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
buildDefaultAppBar: (BuildContext context) {
|
|
|
|
return AppBar(
|
2022-03-17 03:31:25 +00:00
|
|
|
title: Text(categoryTitle(widget.category)),
|
2021-09-29 23:57:09 +00:00
|
|
|
actions: [
|
2023-02-16 08:14:29 +00:00
|
|
|
aPopMenu(context),
|
2023-02-16 08:33:16 +00:00
|
|
|
addressActionButton(context),
|
2021-09-29 23:57:09 +00:00
|
|
|
_chooseCategoryAction(),
|
|
|
|
_categorySearchBar.getSearchAction(context),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
Widget _chooseCategoryAction() => IconButton(
|
|
|
|
onPressed: () async {
|
|
|
|
String? category = await chooseListDialog(context, '请选择分类', [
|
|
|
|
categoryTitle(null),
|
|
|
|
...filteredList(
|
|
|
|
storedCategories,
|
2021-11-24 13:22:22 +00:00
|
|
|
(c) {
|
|
|
|
switch (currentShadowCategoriesMode()) {
|
|
|
|
case ShadowCategoriesMode.BLACK_LIST:
|
|
|
|
if (shadowCategories.contains(c)) return false;
|
|
|
|
break;
|
|
|
|
case ShadowCategoriesMode.WHITE_LIST:
|
|
|
|
if (!shadowCategories.contains(c)) return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
2021-09-29 23:57:09 +00:00
|
|
|
),
|
|
|
|
]);
|
|
|
|
if (category != null) {
|
|
|
|
if (category == categoryTitle(null)) {
|
|
|
|
category = null;
|
|
|
|
}
|
2023-01-31 10:50:51 +00:00
|
|
|
Navigator.of(context).pushReplacement(mixRoute(
|
2021-09-29 23:57:09 +00:00
|
|
|
builder: (context) {
|
|
|
|
return ComicsScreen(
|
|
|
|
category: category,
|
|
|
|
tag: widget.tag,
|
|
|
|
creatorId: widget.creatorId,
|
|
|
|
creatorName: widget.creatorName,
|
|
|
|
chineseTeam: widget.chineseTeam,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
));
|
|
|
|
}
|
|
|
|
},
|
2022-03-19 04:12:27 +00:00
|
|
|
icon: const Icon(Icons.category),
|
2021-09-29 23:57:09 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
Future<ComicsPage> _load(String _currentSort, int _currentPage) {
|
|
|
|
return method.comics(
|
|
|
|
_currentSort,
|
|
|
|
_currentPage,
|
|
|
|
category: widget.category ?? "",
|
|
|
|
tag: widget.tag ?? "",
|
|
|
|
creatorId: widget.creatorId ?? "",
|
|
|
|
chineseTeam: widget.chineseTeam ?? "",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2022-03-19 04:12:27 +00:00
|
|
|
Widget build(BuildContext context){
|
2022-03-25 14:57:30 +00:00
|
|
|
return rightClickPop(
|
|
|
|
child: buildScreen(context),
|
|
|
|
context: context,
|
|
|
|
canPop: true,
|
|
|
|
);
|
2022-03-19 04:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildScreen(BuildContext context) {
|
2021-09-29 23:57:09 +00:00
|
|
|
PreferredSizeWidget? appBar;
|
|
|
|
if (widget.tag == null &&
|
|
|
|
widget.creatorId == null &&
|
|
|
|
widget.chineseTeam == null) {
|
|
|
|
// 只有只传分类或不传参数时时才开放搜索
|
|
|
|
appBar = _categorySearchBar.build(context);
|
|
|
|
} else {
|
|
|
|
var title = "";
|
|
|
|
if (widget.category != null) {
|
|
|
|
title += "${widget.category} ";
|
|
|
|
}
|
|
|
|
if (widget.tag != null) {
|
|
|
|
title += "${widget.tag} ";
|
|
|
|
}
|
|
|
|
if (widget.creatorName != null) {
|
|
|
|
title += "${widget.creatorName} ";
|
|
|
|
}
|
|
|
|
if (widget.chineseTeam != null) {
|
|
|
|
title += "${widget.chineseTeam} ";
|
|
|
|
}
|
|
|
|
appBar = AppBar(
|
|
|
|
title: Text(title),
|
|
|
|
actions: [
|
2023-02-16 08:33:16 +00:00
|
|
|
aPopMenu(context),
|
|
|
|
addressActionButton(context),
|
2021-09-29 23:57:09 +00:00
|
|
|
_chooseCategoryAction(),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
appBar: appBar,
|
|
|
|
body: ComicPager(
|
|
|
|
fetchPage: _load,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|