Skip to content

Commit

Permalink
归档支持滚动到顶部;页面间距优化;重新解析提示改为底部提示;文章详情页面提示语增加解析器版本
Browse files Browse the repository at this point in the history
  • Loading branch information
vito-go committed Mar 17, 2024
1 parent db5dce8 commit a57222e
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 26 deletions.
12 changes: 12 additions & 0 deletions mywords-flutter/lib/pages/article_archived_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:mywords/common/global_event.dart';
import 'package:mywords/libso/funcs.dart';

import 'package:mywords/widgets/article_list.dart';
Expand All @@ -19,12 +20,23 @@ class _State extends State<ArticleArchivedPage> {
appBar: AppBar(
title: const Text("已归档文章"),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
actions: [
IconButton(
onPressed: () {
// 归档置顶
addToGlobalEvent(GlobalEvent(
eventType: GlobalEventType.articleListScrollToTop,
param: 2));
},
icon: const Icon(Icons.vertical_align_top_outlined))
],
),
body: const ArticleListView(
getFileInfos: getArchivedFileInfoList,
toEndSlide: ToEndSlide.unarchive,
leftLabel: '恢复',
leftIconData: Icons.restore,
pageNo: 2,
));
}
}
13 changes: 6 additions & 7 deletions mywords-flutter/lib/pages/article_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class _State extends State<ArticleListPage> with AutomaticKeepAliveClientMixin {
super.dispose();
controller.dispose();
focus.dispose();
valueNotifier.dispose();
globalEventSubscription?.cancel();
valueNotifierChart.dispose();
}
Expand Down Expand Up @@ -156,8 +157,9 @@ class _State extends State<ArticleListPage> with AutomaticKeepAliveClientMixin {

Widget get todaySubtitle {
final style = prefs.isDark
? TextStyle(color: Colors.orange.shade300,fontWeight: FontWeight.bold)
: TextStyle(color: Theme.of(context).primaryColor,fontWeight: FontWeight.bold);
? TextStyle(color: Colors.orange.shade300, fontWeight: FontWeight.bold)
: TextStyle(
color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold);
return RichText(
text: TextSpan(
text: "1级: ",
Expand Down Expand Up @@ -225,16 +227,13 @@ class _State extends State<ArticleListPage> with AutomaticKeepAliveClientMixin {
}
return const SizedBox(height: 5);
}),
Expanded(
const Expanded(
child: ArticleListView(
refresh: () {
myPrint("刷新图标数据");
valueNotifierChart.value = UniqueKey();
},
getFileInfos: showFileInfoList,
toEndSlide: ToEndSlide.archive,
leftLabel: '归档',
leftIconData: Icons.archive,
pageNo: 1,
)),
];

Expand Down
11 changes: 6 additions & 5 deletions mywords-flutter/lib/pages/article_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class ArticlePageState extends State<ArticlePage> {
article = respData.data!;
levelCountMap = _levelDistribute();
if (!context.mounted) return;
myToast(context, "重新从本地文件解析成功!");
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text('重新从本地文件解析成功!')));
setState(() {});
});
}
Expand Down Expand Up @@ -346,12 +347,12 @@ class ArticlePageState extends State<ArticlePage> {
children.add(Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Tooltip(
showDuration: Duration(seconds: 15),
Tooltip(
showDuration: const Duration(seconds: 30),
message:
"说明: 格式为[单词序号]{单词频次},例如: [3]{9} actor, 排序后actor为第9个单词,在文中出现的频次是9次。\n筛选功能可以按照等级过滤单词。",
"解析器版本: ${parseVersion()}\n说明: 格式为[单词序号]{单词频次},例如: [3]{9} actor, 排序后actor为第9个单词,在文中出现的频次是9次。\n筛选功能可以按照等级过滤显示单词。",
triggerMode: TooltipTriggerMode.tap,
child: Icon(Icons.info),
child: const Icon(Icons.info),
),
const Text("分级筛选"),
buildShowLevel(0, label: "0", onTap: () {
Expand Down
2 changes: 1 addition & 1 deletion mywords-flutter/lib/pages/dict_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class _State extends State<DictDatabase> {
);
return Scaffold(
appBar: appBar,
body: Padding(padding: const EdgeInsets.all(10), child: body),
body: body,
);
}
}
4 changes: 2 additions & 2 deletions mywords-flutter/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class _State extends State<Home> {
onTap: (int i) {
if (idx == i && i == 0) {
// 滚动置顶
addToGlobalEvent(
GlobalEvent(eventType: GlobalEventType.articleListScrollToTop));
addToGlobalEvent(GlobalEvent(
eventType: GlobalEventType.articleListScrollToTop, param: 1));
}
if (idx == i) return;
_pageController.jumpToPage(i);
Expand Down
2 changes: 1 addition & 1 deletion mywords-flutter/lib/pages/proxy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class _State extends State<NetProxy> {
);
return Scaffold(
appBar: appBar,
body: Padding(padding: const EdgeInsets.all(10), child: body),
body: body,
);
}
}
16 changes: 8 additions & 8 deletions mywords-flutter/lib/widgets/article_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ enum ToEndSlide { archive, unarchive }
class ArticleListView extends StatefulWidget {
const ArticleListView({
super.key,
this.refresh,
required this.getFileInfos,
required this.toEndSlide,
required this.leftLabel,
required this.leftIconData,
required this.pageNo,
});

final VoidCallback? refresh;
final String leftLabel;
final IconData leftIconData;
final ToEndSlide toEndSlide;
final int pageNo; // 页码,用来做监听事件区分,1, 2, 3

final RespData<List<FileInfo>> Function() getFileInfos;

Expand Down Expand Up @@ -140,9 +140,7 @@ class _State extends State<ArticleListView> {
),
onTap: () {
pushTo(context, ArticlePage(fileName: item.fileName))
.then((value) {
if (widget.refresh != null) widget.refresh!();
});
.then((value) {});
},
minLeadingWidth: 0,
leading:
Expand Down Expand Up @@ -187,7 +185,6 @@ class _State extends State<ArticleListView> {
await initFileInfos();
if (!context.mounted) return;
myToast(context, "Successfully!");
if (widget.refresh != null) widget.refresh!();
});
}

Expand Down Expand Up @@ -237,10 +234,13 @@ class _State extends State<ArticleListView> {
initFileInfos();
break;
case GlobalEventType.updateKnownWord:

break;
case GlobalEventType.articleListScrollToTop:
if (fileInfos.isNotEmpty) {
if (widget.pageNo == event.param && fileInfos.isNotEmpty) {
controller.animateTo(0,
duration: const Duration(milliseconds: 150), curve: Curves.linear);
duration: const Duration(milliseconds: 150),
curve: Curves.linear);
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions mywords-go/cmd/flutter/main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"
"path/filepath"
"testing"
Expand All @@ -23,6 +22,5 @@ func TestMain(m *testing.M) {
panic(err)
}
os.WriteFile("apple.html", []byte(content), 0644)
fmt.Println(content)
//select {}
}

0 comments on commit a57222e

Please sign in to comment.