Skip to content

Commit

Permalink
优化文章页面Padding; 优化网址解析, 进行http(s)://前缀匹配; 优化重复解析提示 (vito-go#5)
Browse files Browse the repository at this point in the history
* 文章预览页 padding

* 优化网址解析,进行http(s)://前缀匹配;

* 优化重复解析提示

* 文章详情页 Padding

* build-la

---------

Co-authored-by: github.com/vito-go
  • Loading branch information
vito-go authored Mar 22, 2024
1 parent a57222e commit 5540e8a
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 55 deletions.
31 changes: 20 additions & 11 deletions mywords-flutter/lib/pages/article_list_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:mywords/common/prefs/prefs.dart';
Expand Down Expand Up @@ -53,44 +54,52 @@ class _State extends State<ArticleListPage> with AutomaticKeepAliveClientMixin {
List<FileInfo> get fileInfos => showFileInfoList().data ?? [];

void search() async {
if (valueNotifier.value) {
return;
}
if (controller.text == "") {
myToast(context, "网址不能为空");
return;
}
if (valueNotifier.value) {
return;
int indexStart = controller.text.indexOf("https://");
if (indexStart == -1) {
indexStart = controller.text.indexOf("http://");
}
final uri = Uri.tryParse(controller.text);
if (uri == null) {
myToast(context, "not a url");
return;
if (indexStart == -1) {
myToast(context, "网址有误,请检查");
}
final String www=controller.text.substring(indexStart).trim();

myPrint(www);
if (www!=controller.text){
controller.text=www;
}
final www = controller.text.trim();
final idx = fileInfos.indexWhere((element) => element.sourceUrl == www);
if (idx != -1) {
final fileName = fileInfos[idx].fileName;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('您已经解析过该网址,是否重新解析?'),
title: const Text("提示"),
content: const Text('您已经解析过该网址,是否重新解析?'),
actions: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
TextButton(
onPressed: () {
Navigator.of(context).pop();
pushTo(context, ArticlePage(fileName: fileName));
},
child: const Text("查看")),
ElevatedButton(
TextButton(
onPressed: () async {
Navigator.of(context).pop();
computeParse(www);
},
child: const Text("重新解析")),
ElevatedButton(
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
Expand Down
84 changes: 45 additions & 39 deletions mywords-flutter/lib/pages/article_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,43 @@ class ArticlePageState extends State<ArticlePage> {
);
}

Widget get getHeaderRow => Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Tooltip(
showDuration: const Duration(seconds: 30),
message:
"解析器版本: ${parseVersion()}\n说明: 格式为[单词序号]{单词频次},例如: [3]{9} actor, 排序后actor为第9个单词,在文中出现的频次是9次。\n筛选功能可以按照等级过滤显示单词。",
triggerMode: TooltipTriggerMode.tap,
child: const Icon(Icons.info),
),
const Text("分级筛选"),
buildShowLevel(0, label: "0", onTap: () {
showLevel = 0;
setState(() {});
}, showLevel: showLevel),
buildShowLevel(1, label: "1", showLevel: showLevel, onTap: () {
showLevel = 1;
setState(() {});
}),
buildShowLevel(2, label: "2", showLevel: showLevel, onTap: () {
showLevel = 2;
setState(() {});
}),
buildShowLevel(3, label: "3", showLevel: showLevel, onTap: () {
showLevel = 3;
setState(() {});
}),
Switch(
value: showSentence,
onChanged: (v) {
setState(() {
showSentence = v;
});
})
],
);

Widget staticsRichText(int totalCount, int netCount) {
return RichText(
text: TextSpan(
Expand Down Expand Up @@ -342,48 +379,17 @@ class ArticlePageState extends State<ArticlePage> {
if (preview) {
children.add(Expanded(
child: buildSelectionWordArea(
HtmlWidget(art.htmlContent, renderMode: RenderMode.listView))));
Padding(
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 10),
child:
HtmlWidget(art.htmlContent, renderMode: RenderMode.listView)),
)));
} else {
children.add(Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Tooltip(
showDuration: const Duration(seconds: 30),
message:
"解析器版本: ${parseVersion()}\n说明: 格式为[单词序号]{单词频次},例如: [3]{9} actor, 排序后actor为第9个单词,在文中出现的频次是9次。\n筛选功能可以按照等级过滤显示单词。",
triggerMode: TooltipTriggerMode.tap,
child: const Icon(Icons.info),
),
const Text("分级筛选"),
buildShowLevel(0, label: "0", onTap: () {
showLevel = 0;
setState(() {});
}, showLevel: showLevel),
buildShowLevel(1, label: "1", showLevel: showLevel, onTap: () {
showLevel = 1;
setState(() {});
}),
buildShowLevel(2, label: "2", showLevel: showLevel, onTap: () {
showLevel = 2;
setState(() {});
}),
buildShowLevel(3, label: "3", showLevel: showLevel, onTap: () {
showLevel = 3;
setState(() {});
}),
Switch(
value: showSentence,
onChanged: (v) {
setState(() {
showSentence = v;
});
})
],
));
children.add(const SizedBox(height: 10));
children.add(getHeaderRow);
children.add(const SizedBox(height: 8));
children.add(Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 8, right: 8),
padding: const EdgeInsets.only(left: 16, right: 16),
child: buildWords(wordInfos))));
}
final body = Column(
Expand Down
19 changes: 14 additions & 5 deletions mywords-flutter/lib/pages/statistic_chart.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:mywords/libso/funcs.dart';
import 'package:mywords/util/util.dart';
import 'package:mywords/widgets/line_chart.dart';

class StatisticChart extends StatefulWidget {
Expand All @@ -14,10 +15,7 @@ class StatisticChart extends StatefulWidget {
class _State extends State<StatisticChart> with SingleTickerProviderStateMixin {
List<Widget> get myTabs => [
const Text("每日统计"),
const Tooltip(
message: "请注意:每日学习的单词可能存在重复,因此您累计学习的数量可能与已知单词总数不一致。",
child: Text("累计统计"),
)
const Text("累计统计"),
];

List<Widget> get tableWidgets {
Expand Down Expand Up @@ -49,6 +47,15 @@ class _State extends State<StatisticChart> with SingleTickerProviderStateMixin {
);
}

Widget get toolTipAccumulate {
return const Tooltip(
showDuration: Duration(seconds: 30),
message: "请注意:每日学习的单词可能与往日学习的存在重复,因此您累计学习的数量可能与已知单词总数不一致。",
triggerMode: TooltipTriggerMode.tap,
child: Icon(Icons.help),
);
}

@override
void initState() {
super.initState();
Expand All @@ -65,7 +72,9 @@ class _State extends State<StatisticChart> with SingleTickerProviderStateMixin {
),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
actions: [
Padding(padding: const EdgeInsets.only(right: 16), child: toolTipToday)
Padding(padding: const EdgeInsets.only(right: 16), child: toolTipToday),
Padding(
padding: const EdgeInsets.only(right: 20), child: toolTipAccumulate)
],
);
return DefaultTabController(
Expand Down
2 changes: 2 additions & 0 deletions mywords-flutter/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ clean:
rm -rf linux-deb/opt/mywords/*
rm -rf android/app/jniLibs/*

build-la:build-apk build-linux

build-apk:
- mkdir bin
flutter build apk --target-platform android-arm64
Expand Down

0 comments on commit 5540e8a

Please sign in to comment.