Skip to content

Commit 21c7951

Browse files
authored
v4.3.3 support g-translate; UI optmize (#29)
* v4.3.3 support g-translate; UI optmize * remove useless import
1 parent 2916bcc commit 21c7951

File tree

9 files changed

+68
-57
lines changed

9 files changed

+68
-57
lines changed

mywords-flutter/android/.kotlin/sessions/kotlin-compiler-12494452778444265579.salive

Whitespace-only changes.

mywords-flutter/lib/pages/article_list_page.dart

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
55
import 'package:mywords/libso/handler.dart';
66

77
import 'package:mywords/pages/article_page.dart';
8-
import 'package:mywords/pages/sources.dart';
98
import 'package:mywords/pages/statistic_chart.dart';
109
import 'package:mywords/pages/today_known_words.dart';
1110
import 'package:mywords/util/navigator.dart';
@@ -147,28 +146,18 @@ class _State extends State<ArticleListPage> with AutomaticKeepAliveClientMixin {
147146
controller: controller,
148147
focusNode: focus,
149148
decoration: InputDecoration(
150-
// hintText: "请输入一个英语文章页面网址",
151-
hintText: "Please enter a web page URL",
152-
prefixIcon: IconButton(
153-
onPressed: () {
154-
controller.text = '';
155-
},
156-
icon: const Icon(
157-
Icons.clear,
158-
color: Colors.red,
159-
)),
160-
suffixIcon: Row(
161-
mainAxisSize: MainAxisSize.min,
162-
children: [
163-
searchIcon,
164-
IconButton(
165-
icon: const Icon(Icons.web),
166-
onPressed: () {
167-
pushTo(context, Sources());
168-
},
169-
),
170-
],
171-
)),
149+
// hintText: "请输入一个英语文章页面网址",
150+
hintText: "Please enter a web page URL",
151+
prefixIcon: IconButton(
152+
onPressed: () {
153+
controller.text = '';
154+
},
155+
icon: const Icon(
156+
Icons.clear,
157+
color: Colors.red,
158+
)),
159+
suffixIcon: searchIcon,
160+
),
172161
);
173162
}
174163

@@ -209,7 +198,7 @@ class _State extends State<ArticleListPage> with AutomaticKeepAliveClientMixin {
209198
onPressed: () {
210199
pushTo(context, const ToadyKnownWords());
211200
},
212-
icon: const Icon(Icons.wordpress)),
201+
icon: const Icon(Icons.local_library)),
213202
title: RichText(
214203
text: TextSpan(
215204
// text: "今日学习单词总数: ",

mywords-flutter/lib/pages/home.dart

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter/material.dart';
23
import 'package:mywords/common/prefs/prefs.dart';
34
import 'package:mywords/common/queue.dart';
5+
import 'package:mywords/pages/sources.dart';
46
import 'package:mywords/util/get_scaffold.dart';
57
import 'package:mywords/util/util_native.dart'
68
if (dart.library.html) 'package:mywords/util/util_web.dart';
79
import 'package:mywords/widgets/tool.dart';
810
import 'package:url_launcher/url_launcher_string.dart';
911
import '../common/global.dart';
1012
import '../libso/handler.dart';
13+
import '../util/navigator.dart';
1114
import '../util/util.dart';
1215
import 'article_list_page.dart';
1316
import 'lookup_word.dart';
@@ -53,7 +56,7 @@ class _State extends State<Home> {
5356
const BottomNavigationBarItem(label: ("Tool"), icon: Icon(Icons.settings)),
5457
];
5558

56-
Widget themeIconButton() {
59+
Widget get themeIconButton {
5760
return IconButton(
5861
onPressed: () {
5962
if (prefs.themeMode == ThemeMode.light) {
@@ -139,11 +142,20 @@ class _State extends State<Home> {
139142
icon: const Icon(Icons.refresh));
140143

141144
List<Widget> get actions {
142-
return [
143-
refreshAllButton,
144-
IconButton(onPressed: aboutOnTap, icon: const Icon(Icons.help_outline)),
145-
themeIconButton(),
146-
];
145+
final List<Widget> result = [];
146+
if (platformIsMobileClient()) {
147+
result.add(IconButton(
148+
icon: const Icon(Icons.web),
149+
onPressed: () {
150+
pushTo(context, Sources());
151+
},
152+
));
153+
}
154+
result.add(refreshAllButton);
155+
result.add(IconButton(
156+
onPressed: aboutOnTap, icon: const Icon(Icons.help_outline)));
157+
result.add(themeIconButton);
158+
return result;
147159
}
148160

149161
BottomNavigationBar get bottomBar => BottomNavigationBar(

mywords-flutter/lib/pages/sources.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ class _State extends State<Sources> {
2525
List<String> allSourcesFromDB = [];
2626

2727
Future<void> updateSources() async {
28-
sourceURLs = await handler.getAllSources();
28+
// sourceURLs = await handler.getAllSources();
2929
allSourcesFromDB = await handler.allSourcesFromDB();
30+
setState(() {});
31+
sourceURLs = await compute((_) async {
32+
return await handler.getAllSources();
33+
}, null);
34+
// allSourcesFromDB = await handler.allSourcesFromDB();
3035
init = true;
3136
setState(() {});
3237
}
@@ -72,7 +77,6 @@ class _State extends State<Sources> {
7277
// SliverGridDelegateWithMaxCrossAxisExtent
7378
// SliverGridDelegateWithFixedCrossAxisCount
7479
Widget buildGridView() {
75-
myPrint(MediaQuery.of(context).size.width);
7680
return GridView.builder(
7781
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
7882
maxCrossAxisExtent: 150, childAspectRatio: 1.15),

mywords-flutter/lib/widgets/sources_native.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ class _State extends State<SourcesWebView> {
148148
"You have already parsed this URL\n$url\n${fInfo.title}");
149149
return;
150150
}
151-
blockShowDialog(context, ()async{
151+
blockShowDialog(context, () async {
152152
// newArticleFileInfoBySourceURL
153-
final respData = await compute(handler.newArticleFileInfoBySourceURL, url);
153+
final respData =
154+
await compute(handler.newArticleFileInfoBySourceURL, url);
154155
if (respData.code != 0) {
155156
myToast(context, respData.message);
156157
return;
157158
}
158159
myToast(context, "success");
159160
produceEvent(EventType.updateArticleList);
160161
}());
161-
162162
},
163163
),
164164
];

mywords-flutter/lib/widgets/tool.dart

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import 'package:mywords/pages/known_words.dart';
1212
import 'package:mywords/pages/proxy.dart';
1313
import 'package:mywords/pages/statistic_chart.dart';
1414
import 'package:mywords/util/navigator.dart';
15-
import 'package:mywords/util/util_native.dart';
1615
import 'package:mywords/widgets/private_ip.dart';
1716
import 'package:url_launcher/url_launcher_string.dart';
1817

@@ -370,12 +369,22 @@ class MyToolState extends State<MyTool> with AutomaticKeepAliveClientMixin {
370369
Widget build(BuildContext context) {
371370
super.build(context);
372371
myPrint("build MyTool");
373-
final List<Widget> children = [];
374-
// children.add(buildInfo());
375-
children.addAll([
372+
final List<Widget> children = [
376373
header,
377374
const Divider(),
375+
];
376+
if (platformIsMobileClient()) {
377+
children.add(ListTile(
378+
title: const Text("Sources"),
379+
leading: const Icon(Icons.web),
380+
trailing: const Icon(Icons.navigate_next),
381+
onTap: () {
382+
pushTo(context, const Sources());
383+
},
384+
));
385+
}
378386

387+
children.addAll([
379388
ListTile(
380389
// title: const Text("学习统计"),
381390
title: const Text("Learning Statistics"),
@@ -429,21 +438,11 @@ class MyToolState extends State<MyTool> with AutomaticKeepAliveClientMixin {
429438
),
430439
// buildListTileVacuumDB(),
431440
]);
432-
if (platformIsMobileClient()){
433-
children.add(ListTile(
434-
title: const Text("Sources"),
435-
leading: const Icon(Icons.web),
436-
trailing: const Icon(Icons.navigate_next),
437-
onTap: () {
438-
pushTo(context, const Sources());
439-
},
440-
));
441-
}
442441

443442
if (!kIsWeb) {
444443
children.add(webOnlineListTile);
445444
}
446-
children.add(const PrivateIP());
445+
// children.add(const PrivateIP());
447446
if (false) {
448447
children.add(buildListTileRestoreFromOld());
449448
}
@@ -463,7 +462,6 @@ class MyToolState extends State<MyTool> with AutomaticKeepAliveClientMixin {
463462
},
464463
));
465464

466-
467465
return ListView(children: children);
468466
}
469467

mywords-flutter/lib/widgets/translator.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:mywords/common/prefs/prefs.dart';
44
import 'package:mywords/util/util.dart';
55
import 'package:mywords/util/util_native.dart'
66
if (dart.library.html) 'package:mywords/util/util_web.dart';
7+
import 'package:url_launcher/url_launcher_string.dart';
78

89
import '../libso/handler.dart';
910
import '../libso/types.dart';
@@ -52,7 +53,8 @@ void showTranslation(BuildContext context, String text) async {
5253
children: [
5354
Flexible(child: original),
5455
const Divider(),
55-
Flexible(child: Row(
56+
Flexible(
57+
child: Row(
5658
children: [
5759
Icon(
5860
Icons.error,
@@ -78,9 +80,12 @@ void showTranslation(BuildContext context, String text) async {
7880
children: [
7981
original,
8082
const Divider(),
81-
Flexible(child: Row(
83+
Flexible(
84+
child: Row(
8285
children: [
83-
Flexible(child: SingleChildScrollView(child: SelectableText(translation.result))),
86+
Flexible(
87+
child: SingleChildScrollView(
88+
child: SelectableText(translation.result))),
8489
IconButton(
8590
onPressed: () {
8691
copyToClipBoard(context, translation.result);
@@ -115,7 +120,10 @@ WidgetSpan buildTranslateWidgetSpan(BuildContext context, String text) {
115120
child: Icon(Icons.g_translate,
116121
color: prefs.isDark ? null : Theme.of(context).primaryColor),
117122
onTap: () {
118-
showTranslation(context, text);
123+
final url = Uri.encodeFull(
124+
'https://translate.google.com/?sl=auto&tl=zh-CN&text=$text');
125+
launchUrlString(url);
126+
// showTranslation(context, text);
119127
},
120128
));
121129
return trans;

mywords-flutter/linux-deb/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: mywords
2-
Version: 4.3.1
2+
Version: 4.3.3
33
Section: Education
44
Priority: optional
55
Architecture: amd64

mywords-flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1717
# In Windows, build-name is used as the major, minor, and patch parts
1818
# of the product and file versions while build-number is used as the build suffix.
1919
# version number is versionName; build number is versionCode;
20-
version: 4.3.2+4
20+
version: 4.3.3+4
2121

2222
environment:
2323
sdk: '>=3.2.3 <4.0.0'

0 commit comments

Comments
 (0)