diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 9a1b599..f0526f2 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -218,13 +218,16 @@ jobs: env: ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' run: | - curl -JOL https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage - chmod a+x appimagetool-x86_64.AppImage - mkdir -p ${GITHUB_WORKSPACE}/bin - mv appimagetool-x86_64.AppImage ${GITHUB_WORKSPACE}/bin/appimagetool - echo ::add-path::${GITHUB_WORKSPACE}/bin sudo apt-get update sudo apt-get install -y libgl1-mesa-dev xorg-dev + mkdir -p ${GITHUB_WORKSPACE}/bin + cd ${GITHUB_WORKSPACE}/bin + echo ::add-path::${GITHUB_WORKSPACE}/bin + curl -LO https://www.ghproxy.com/https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage + chmod a+x appimagetool-x86_64.AppImage + sed 's|AI\x02|\x00\x00\x00|g' -i appimagetool-x86_64.AppImage + ./appimagetool-x86_64.AppImage --appimage-extract + mv squashfs-root appimagetool - name: Install hover (desktop) if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'linux' || matrix.config.target == 'windows' || matrix.config.target == 'macos') diff --git a/ci/version.code.txt b/ci/version.code.txt index 95e94cd..90ab6e9 100644 --- a/ci/version.code.txt +++ b/ci/version.code.txt @@ -1 +1 @@ -v0.0.1 \ No newline at end of file +v0.0.2 \ No newline at end of file diff --git a/ci/version.info.txt b/ci/version.info.txt index ef7e17c..89cb95a 100644 --- a/ci/version.info.txt +++ b/ci/version.info.txt @@ -1 +1,2 @@ -- [x] 可以阅读 +- [x] 修复更新错误 +- [x] 可以选择分类 diff --git a/lib/basic/cates.dart b/lib/basic/cates.dart new file mode 100644 index 0000000..c1e3fad --- /dev/null +++ b/lib/basic/cates.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; +import 'package:wax/basic/commons.dart'; +import 'package:wax/screens/browser_screen.dart'; + +const catesNvMap = { + "全部漫画": "", + "同人誌": "5", + "同人誌 - 漢化": "1", + "同人誌 - 日語": "12", + "同人誌 - English": "16", + "同人誌 - CG畫集": "2", + "同人誌 - Cosplay": "3", + "單行本": "6", + "單行本 - 漢化": "9", + "單行本 - 日語": "13", + "單行本 - English": "17", + "雜誌&短篇": "7", + "韓漫": "19", + "韓漫 - 漢化": "20", + "韓漫 - 生肉": "21", +}; + +const catesVnMap = { + "": "全部漫画", + "5": "同人誌", + "1": "同人誌 - 漢化", + "12": "同人誌 - 日語", + "16": "同人誌 - English", + "2": "同人誌 - CG畫集", + "3": "同人誌 - Cosplay", + "6": "單行本", + "9": "單行本 - 漢化", + "13": "單行本 - 日語", + "17": "單行本 - English", + "7": "雜誌&短篇", + "19": "韓漫", + "20": "韓漫 - 漢化", + "21": "韓漫 - 生肉", +}; + +Future chooseCate(BuildContext context) async { + return chooseMapDialog(context, title: "选择分类", values: catesNvMap); +} diff --git a/lib/basic/methods.dart b/lib/basic/methods.dart index 2287c05..c6fe2e8 100644 --- a/lib/basic/methods.dart +++ b/lib/basic/methods.dart @@ -43,12 +43,17 @@ class Methods { .v; } - Future fetchComic(String tag, int pageNumber) async { + Future fetchComic( + String filterName, + String filterValue, + int pageNumber, + ) async { final buff = await _flatInvoke( "fetchComic", FetchComicQuery( host: host, - tag: tag, + filterName: filterName, + filterValue: filterValue, pageNumber: $fixnum.Int64.fromInts(0, pageNumber), )); return FetchComicResult.fromBuffer(buff); diff --git a/lib/configs/versions.dart b/lib/configs/versions.dart index c3b6cdd..a321af4 100644 --- a/lib/configs/versions.dart +++ b/lib/configs/versions.dart @@ -111,9 +111,9 @@ class _VersionInfoState extends State { height: 1.3, ), ), - VersionBadged(child: "dirty" == _version + "dirty" == _version ? _buildDirty() - : _buildNewVersion(_latestVersion)), + : _buildNewVersion(_latestVersion), Expanded(child: Container()), ], ), @@ -129,7 +129,7 @@ class _VersionInfoState extends State { TextSpan( children: [ WidgetSpan( - child: Badged( + child: VersionBadged( child: Container( padding: const EdgeInsets.only(right: 12), child: Text( @@ -137,7 +137,6 @@ class _VersionInfoState extends State { style: const TextStyle(height: 1.3), ), ), - badge: "1", ), ), const TextSpan(text: " "), @@ -183,14 +182,17 @@ class _VersionInfoState extends State { } Widget _buildDirty() { - return Text.rich( - TextSpan( - text: "下载RELEASE版 ", - style: TextStyle( - height: 1.3, - color: Theme.of(context).colorScheme.primary, + return VersionBadged( + child: Text.rich( + TextSpan( + text: "下载RELEASE版 ", + style: TextStyle( + height: 1.3, + color: Theme.of(context).colorScheme.primary, + ), + recognizer: TapGestureRecognizer() + ..onTap = () => openUrl(_releasesUrl), ), - recognizer: TapGestureRecognizer()..onTap = () => openUrl(_releasesUrl), ), ); } diff --git a/lib/screens/browser_screen.dart b/lib/screens/browser_screen.dart index 370663f..1782836 100644 --- a/lib/screens/browser_screen.dart +++ b/lib/screens/browser_screen.dart @@ -2,7 +2,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:wax/basic/methods.dart'; +import 'package:wax/protos/properties.pb.dart'; +import '../basic/cates.dart'; import 'components/actions.dart'; import 'components/browser_bottom_sheet.dart'; import 'components/comic_pager.dart'; @@ -21,23 +23,65 @@ class _BrowserScreenState extends State @override bool get wantKeepAlive => true; + late final _tag = widget.tag; + var _cate = ""; + @override Widget build(BuildContext context) { super.build(context); return Scaffold( appBar: AppBar( - title: Text(widget.tag == "" ? "浏览" : widget.tag), + title: Text(_title()), actions: [ ...alwaysInActions(), const BrowserBottomSheetAction(), + chooseCateAction(context), ], ), body: ComicPager( - // key: Key("$_slug:$_sortBy"), - onPage: (int page) async { - return methods.fetchComic(widget.tag, page); - }, + key: Key("$_tag:$_cate"), + onPage: _onPage, ), ); } + + String _title() { + if (_tag != "") { + return _tag; + } + if (_cate != "") { + return catesVnMap[_cate] ?? ""; + } + return "全部漫画"; + } + + Future _onPage(int page) async { + if (_tag != "") { + return methods.fetchComic( + "tag", + _tag, + page, + ); + } + if (_cate != "") { + return methods.fetchComic( + "cate", + _cate, + page, + ); + } + return methods.fetchComic("", "", page); + } + + Widget chooseCateAction(BuildContext context) { + return IconButton( + onPressed: () async { + final c = await chooseCate(context); + setState(() { + _cate = c; + }); + }, + icon: const Icon(Icons.category), + ); + } } diff --git a/lib/screens/components/badge.dart b/lib/screens/components/badge.dart index 97b3460..da4350c 100644 --- a/lib/screens/components/badge.dart +++ b/lib/screens/components/badge.dart @@ -74,7 +74,7 @@ class _VersionBadgedState extends State { Widget build(BuildContext context) { return Badged( child: widget.child, - badge: latestVersion == null ? null : "1", + badge: latestVersion() == null ? null : "1", ); } } diff --git a/protos/properties.proto b/protos/properties.proto index a6ffa18..4eb27c8 100644 --- a/protos/properties.proto +++ b/protos/properties.proto @@ -17,8 +17,9 @@ message LoadPropertyResult { message FetchComicQuery { string host = 1; - string tag = 2; - int64 pageNumber = 3; + string filterName = 2; + string filterValue = 3; + int64 pageNumber = 4; } message FetchComicResult {