Skip to content

Commit

Permalink
Choose category
Browse files Browse the repository at this point in the history
  • Loading branch information
niuhuan committed May 22, 2022
1 parent b04717f commit 2e2d27b
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 28 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion ci/version.code.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.1
v0.0.2
3 changes: 2 additions & 1 deletion ci/version.info.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- [x] 可以阅读
- [x] 修复更新错误
- [x] 可以选择分类
43 changes: 43 additions & 0 deletions lib/basic/cates.dart
Original file line number Diff line number Diff line change
@@ -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);
}
9 changes: 7 additions & 2 deletions lib/basic/methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ class Methods {
.v;
}

Future<FetchComicResult> fetchComic(String tag, int pageNumber) async {
Future<FetchComicResult> 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);
Expand Down
24 changes: 13 additions & 11 deletions lib/configs/versions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ class _VersionInfoState extends State<VersionInfo> {
height: 1.3,
),
),
VersionBadged(child: "dirty" == _version
"dirty" == _version
? _buildDirty()
: _buildNewVersion(_latestVersion)),
: _buildNewVersion(_latestVersion),
Expanded(child: Container()),
],
),
Expand All @@ -129,15 +129,14 @@ class _VersionInfoState extends State<VersionInfo> {
TextSpan(
children: [
WidgetSpan(
child: Badged(
child: VersionBadged(
child: Container(
padding: const EdgeInsets.only(right: 12),
child: Text(
latestVersion,
style: const TextStyle(height: 1.3),
),
),
badge: "1",
),
),
const TextSpan(text: " "),
Expand Down Expand Up @@ -183,14 +182,17 @@ class _VersionInfoState extends State<VersionInfo> {
}

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),
),
);
}
Expand Down
54 changes: 49 additions & 5 deletions lib/screens/browser_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -21,23 +23,65 @@ class _BrowserScreenState extends State<BrowserScreen>
@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<FetchComicResult> _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),
);
}
}
2 changes: 1 addition & 1 deletion lib/screens/components/badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class _VersionBadgedState extends State<VersionBadged> {
Widget build(BuildContext context) {
return Badged(
child: widget.child,
badge: latestVersion == null ? null : "1",
badge: latestVersion() == null ? null : "1",
);
}
}
5 changes: 3 additions & 2 deletions protos/properties.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2e2d27b

Please sign in to comment.