Skip to content

Commit ecf87ee

Browse files
Merge pull request #69 from OctagonalStar/dev
perf: improves
2 parents 859a9d7 + 49ba86c commit ecf87ee

11 files changed

Lines changed: 60 additions & 52 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@
55
### Added
66

77
- 添加了联机功能
8+
- 添加了停用FSRS(复习)的选项 [#67](https://github.com/OctagonalStar/arabic_learning/pull/67)
89

910
### Improvement
1011

1112
- 优化了单词卡片的排版
1213
- 添加了联机功能对Web的支持
14+
- 优化了单词导入时的去重逻辑 [#67](https://github.com/OctagonalStar/arabic_learning/pull/67)
15+
- 优化复习页面逻辑
16+
- 优化动画流畅性
1317

1418
### Fix
1519

1620
- 修复了自我评级开启时复习页面可能溢出的问题
21+
- 修复了无数据时,从每日单词进入设置发生错误的问题
22+
- 修复了规律学习重复推送同一个单词的问题 [#67](https://github.com/OctagonalStar/arabic_learning/pull/67)
23+
- 修复了新安装无复习任务时 FSRS 设置菜单丢失的问题 [#67](https://github.com/OctagonalStar/arabic_learning/pull/67)
24+
- 修复了单词卡片可能溢出的问题
1725

1826
## v0.1.13 - 2026-2-6 - (000113)
1927

lib/funcs/local_pk_server.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:archive/archive.dart';
66
import 'package:arabic_learning/funcs/utili.dart';
77
import 'package:arabic_learning/vars/config_structure.dart';
88
import 'package:arabic_learning/vars/global.dart';
9-
import 'package:flutter/material.dart' show BuildContext, PageController;
9+
import 'package:flutter/material.dart' show BuildContext, PageController, Durations;
1010
import 'package:logging/logging.dart';
1111
import 'package:arabic_learning/vars/statics_var.dart';
1212
import 'package:flutter/foundation.dart' show ChangeNotifier;
@@ -222,7 +222,7 @@ class PKServer with ChangeNotifier{
222222

223223
void _questStartTime(){
224224
startTime = DateTime.now().add(Duration(seconds: 5));
225-
Future.delayed(Duration(seconds: 5), () => pageController!.nextPage(duration: Duration(milliseconds: 5), curve: StaticsVar.curve));
225+
Future.delayed(Duration(seconds: 5), () => pageController!.nextPage(duration: Durations.medium2, curve: StaticsVar.curve));
226226
_channel!.send(RTCDataChannelMessage(json.encode({
227227
"step": 4,
228228
"startTime": startTime?.add(delay!).toIso8601String()
@@ -302,7 +302,7 @@ class PKServer with ChangeNotifier{
302302
if(sumList.contains(source.getHash(global.wordData.words))) selectableSource.add(source);
303303
logger.fine("[$packageid] 计算得到${source.sourceJsonFileName}在哈希中有匹配");
304304
}
305-
pageController!.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
305+
pageController!.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
306306
} else {
307307
logger.warning("[$packageid] 双端没有任意词库匹配");
308308
exitMessage = "双端没有任意词库匹配";
@@ -328,7 +328,7 @@ class PKServer with ChangeNotifier{
328328
"dictSum": List.generate(selectableSource.length, (int index) => selectableSource[index].getHash(global.wordData.words)),
329329
"time": DateTime.now().toIso8601String()
330330
})));
331-
pageController!.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
331+
pageController!.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
332332
} else {
333333
_channel!.send(RTCDataChannelMessage(json.encode({
334334
"step": 1,
@@ -352,7 +352,7 @@ class PKServer with ChangeNotifier{
352352
}
353353
}
354354
classSelection = ClassSelection(selectedClass: selectedClass, countInReview: false);
355-
pageController!.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
355+
pageController!.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
356356
break;
357357
}
358358
/// 接受对方完成准备 from both
@@ -366,7 +366,7 @@ class PKServer with ChangeNotifier{
366366
case 4: {
367367
startTime = DateTime.parse(data["startTime"]);
368368
Future.delayed(-DateTime.now().difference(startTime!),
369-
()=>pageController!.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve));
369+
()=>pageController!.nextPage(duration: Durations.medium2, curve: StaticsVar.curve));
370370
notifyListeners();
371371
break;
372372
}

lib/funcs/ui.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ List<Widget> classesSelectionList(BuildContext context, Function (ClassItem) onC
174174
/// alart(context, "你点击了按钮",onConfirmed: (){i++}, delayConfirm: Duration(seconds: 1));
175175
/// }
176176
/// ```
177-
void alart(BuildContext context, String e, {Function? onConfirmed, Duration delayConfirm = const Duration(milliseconds: 0)}) {
177+
void alart(BuildContext context, String e, {Function? onConfirmed, Duration delayConfirm = const Duration()}) {
178178
context.read<Global>().uiLogger.info("构建弹出窗口: 携带信息: $e ;确认参数: ${onConfirmed != null}; 延迟: ${delayConfirm.inMilliseconds}");
179179
showDialog(
180180
context: context,
@@ -291,7 +291,7 @@ class TextContainer extends StatelessWidget {
291291
child: (animated)
292292
? TweenAnimationBuilder<double>(
293293
tween: Tween(begin: 0.0, end: text.length.toDouble()),
294-
duration: Duration(milliseconds: 700),
294+
duration: Durations.long4,
295295
curve: StaticsVar.curve,
296296
builder: (context, value, child) {
297297
if(value == text.length.toDouble()) return child!;
@@ -430,7 +430,7 @@ class _ChooseButtonBoxState extends State<ChooseButtonBox> {
430430
color ??= widget.cl ?? Theme.of(context).colorScheme.primaryContainer.withAlpha(150);
431431
return AnimatedContainer(
432432
margin: EdgeInsets.all(8.0),
433-
duration: Duration(milliseconds: widget.isAnimated ? 500 : 0),
433+
duration: widget.isAnimated ? Durations.medium4 : Duration(),
434434
curve: StaticsVar.curve,
435435
decoration: BoxDecoration(
436436
color: color,
@@ -442,7 +442,7 @@ class _ChooseButtonBoxState extends State<ChooseButtonBox> {
442442
bool? ans = widget.chose(widget.index);
443443
if(ans != null) {
444444
color = Colors.amber;
445-
Future.delayed(Duration(milliseconds: widget.isAnimated ? 500 : 0), (){
445+
Future.delayed(widget.isAnimated ? Durations.medium4 : Duration(), (){
446446
setState(() {
447447
if(ans) {
448448
color = Colors.greenAccent;
@@ -560,7 +560,7 @@ class WordCard extends StatelessWidget {
560560
),
561561
child: FittedBox(fit: BoxFit.scaleDown, child: Text("归属课程", style: TextStyle(fontSize: 16))),
562562
),
563-
Expanded(child: Text(word.className, style: TextStyle(fontSize: 18), textAlign: TextAlign.center))
563+
Expanded(child: FittedBox(fit: BoxFit.scaleDown, child: Text(word.className, style: TextStyle(fontSize: 18), textAlign: TextAlign.center)))
564564
],
565565
)
566566
],
@@ -573,13 +573,13 @@ class WordCard extends StatelessWidget {
573573
begin: 1.0,
574574
end: hide ? 1.0 : 0.0
575575
),
576-
duration: Duration(milliseconds: 500),
576+
duration: Durations.extralong2,
577577
curve: StaticsVar.curve,
578578
builder: (context, value, child) {
579579
return ClipRRect(
580580
borderRadius: BorderRadiusGeometry.vertical(bottom: Radius.circular(25.0)),
581581
child: BackdropFilter(
582-
filter: ImageFilter.blur(sigmaX: 10.0 * value,sigmaY: 10.0 * value),
582+
filter: ImageFilter.blur(sigmaX: 15.0 * value,sigmaY: 15.0 * value),
583583
enabled: true,
584584
child: value == 0.0 ? null : ElevatedButton(
585585
style: ElevatedButton.styleFrom(
@@ -862,7 +862,7 @@ class _ChoiceQuestions extends State<ChoiceQuestions> {
862862
),
863863
SizedBox(height: mediaQuery.size.height *0.01),
864864
if(widget.bottomWidget != null) widget.bottomWidget!,
865-
SizedBox(height: mediaQuery.size.height *0.05),
865+
SizedBox(height: mediaQuery.size.height *0.03),
866866
],
867867
),
868868
),
@@ -949,7 +949,7 @@ class _SpellQuestion extends State<SpellQuestion> {
949949
begin: Theme.of(context).colorScheme.onPrimaryFixed,
950950
end: isChecked ? cl.withAlpha(180) : Theme.of(context).colorScheme.onPrimaryFixed
951951
),
952-
duration: Duration(milliseconds: 500),
952+
duration: Durations.medium2,
953953
curve: StaticsVar.curve,
954954
builder: (context, value, child) {
955955
return TextField(

lib/main.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class MyHomePage extends StatefulWidget {
116116
class _MyHomePageState extends State<MyHomePage> {
117117
late List<Widget> _pageList;
118118
final PageController _pageController = PageController(initialPage: 0);
119-
static const Duration _duration = Duration(milliseconds: 500);
120119
bool disPlayedFirst = false;
121120

122121
// 判断是否为桌面端的阈值(可根据需要调整)
@@ -201,7 +200,7 @@ class _MyHomePageState extends State<MyHomePage> {
201200
_onNavigationTapped(index);
202201
},
203202
height: MediaQuery.of(context).size.height * 0.1,
204-
animationDuration: Duration(milliseconds: 500),
203+
animationDuration: Durations.medium2,
205204
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
206205
backgroundColor: Theme.of(context).colorScheme.onPrimary.withAlpha(150),
207206
destinations: const [
@@ -235,7 +234,7 @@ class _MyHomePageState extends State<MyHomePage> {
235234
void _onNavigationTapped(int index) {
236235
_pageController.animateToPage(
237236
index,
238-
duration: _duration,
237+
duration: Durations.medium2,
239238
curve: StaticsVar.curve,
240239
);
241240
}

lib/pages/home_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class _DailyWord extends State<DailyWord> {
181181
playing = false;
182182
} else {
183183
context.read<Global>().uiLogger.info("跳转: DailyWord => SettingPage");
184-
Navigator.of(context).push(MaterialPageRoute(builder: (context) => SettingPage()));
184+
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Scaffold(appBar: AppBar(title: Text("设置")) , body: SettingPage())));
185185
}
186186
},
187187
style: ElevatedButton.styleFrom(

lib/sub_pages_builder/learning_pages/fsrs_pages.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ class MainFSRSPage extends StatelessWidget {
312312
scrollDirection: Axis.vertical,
313313
controller: controller,
314314
itemBuilder: (context, index) {
315+
final wordID = fsrs.getLeastDueCard();
316+
if(wordID == -1) {
317+
return Center(
318+
child: TextContainer(text: "当前无需要复习的内容\n点击右上角可修改配置"),
319+
);
320+
}
315321
if(index == 0) {
316322
return Center(
317323
child: Column(
@@ -322,12 +328,6 @@ class MainFSRSPage extends StatelessWidget {
322328
),
323329
);
324330
}
325-
final wordID = fsrs.getLeastDueCard();
326-
if(wordID == -1) {
327-
return Center(
328-
child: TextContainer(text: "今日复习任务已完成\n(或当前无复习内容)\n点击右上角齿轮可修改配置"),
329-
);
330-
}
331331
return FSRSReviewCardPage(wordID: wordID, fsrs: fsrs, rnd: sharedRnd, controller: controller,);
332332
}
333333
)
@@ -405,7 +405,7 @@ class _FSRSReviewCardPage extends State<FSRSReviewCardPage> {
405405
begin: 0.0,
406406
end: choosed ? 1.0 : 0.0
407407
),
408-
duration: Duration(milliseconds: 500),
408+
duration: Durations.medium2,
409409
curve: StaticsVar.curve,
410410
builder: (context, value, child) {
411411
return Row(
@@ -432,7 +432,7 @@ class _FSRSReviewCardPage extends State<FSRSReviewCardPage> {
432432
shape: RoundedRectangleBorder(borderRadius: StaticsVar.br)
433433
),
434434
onPressed: () {
435-
widget.controller.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
435+
widget.controller.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
436436
},
437437
icon: Icon(Icons.arrow_downward),
438438
label: FittedBox(fit: BoxFit.contain, child: Text("下一题")),
@@ -510,9 +510,9 @@ class _FSRSLearningPageState extends State<FSRSLearningPage> {
510510
label: Text(index == widget.words.length-1 ? "开始答题" : "下一个"),
511511
onPressed: (){
512512
if(index == widget.words.length-1) {
513-
controllerHor.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
513+
controllerHor.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
514514
} else {
515-
controllerLearning.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
515+
controllerLearning.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
516516
}
517517
},
518518
),
@@ -557,7 +557,7 @@ class _FSRSLearningPageState extends State<FSRSLearningPage> {
557557
begin: 0.0,
558558
end: corrected ? 1.0 : 0.0
559559
),
560-
duration: Duration(milliseconds: 500),
560+
duration: Durations.medium2,
561561
curve: StaticsVar.curve,
562562
builder: (context, value, child) {
563563
return Row(
@@ -582,9 +582,9 @@ class _FSRSLearningPageState extends State<FSRSLearningPage> {
582582
),
583583
onPressed: () {
584584
if(index == widget.words.length-1) {
585-
controllerHor.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
585+
controllerHor.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
586586
}
587-
controllerQuestions.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
587+
controllerQuestions.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
588588
},
589589
icon: Icon(index == widget.words.length-1 ? Icons.done_all : Icons.arrow_downward),
590590
label: FittedBox(child: Text(index == widget.words.length-1 ? "完成学习" : "下一题")),

lib/sub_pages_builder/learning_pages/learning_pages_build.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class _InLearningPageState extends State<InLearningPage> {
146146
begin: 0.00,
147147
end: ((controller.hasClients ? controller.page?.ceil() : 0) ?? 0) / (testList.length - 1),
148148
),
149-
duration: const Duration(milliseconds: 500),
149+
duration: Durations.extralong4,
150150
curve: StaticsVar.curve,
151151
builder: (context, value, child) {
152152
return LinearProgressIndicator(
@@ -198,7 +198,7 @@ class _InLearningPageState extends State<InLearningPage> {
198198
shape: RoundedRectangleBorder(borderRadius: StaticsVar.br)
199199
),
200200
onPressed: (){
201-
controller.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
201+
controller.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
202202
correctCount++;
203203
setState(() {});
204204
},
@@ -229,7 +229,7 @@ class _InLearningPageState extends State<InLearningPage> {
229229
isShowNext: clicked,
230230
isLast: controller.page?.ceil() == testList.length - 1,
231231
onNextClicked: (){
232-
controller.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
232+
controller.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
233233
setState(() {
234234
clicked = false;
235235
});
@@ -261,7 +261,7 @@ class _InLearningPageState extends State<InLearningPage> {
261261
isShowNext: clicked,
262262
isLast: controller.page?.ceil() == testList.length - 1,
263263
onNextClicked: (){
264-
controller.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
264+
controller.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
265265
setState(() {
266266
clicked = false;
267267
});
@@ -300,7 +300,7 @@ class _InLearningPageState extends State<InLearningPage> {
300300
isShowNext: clicked,
301301
isLast: controller.page?.ceil() == testList.length - 1,
302302
onNextClicked: (){
303-
controller.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
303+
controller.nextPage(duration: Durations.medium2, curve: StaticsVar.curve);
304304
setState(() {
305305
clicked = false;
306306
});
@@ -337,7 +337,7 @@ class BottomTip extends StatelessWidget {
337337
begin: 0.0,
338338
end: isShowNext ? 1.0 : 0.0,
339339
),
340-
duration: const Duration(milliseconds: 500),
340+
duration: Durations.medium2,
341341
curve: StaticsVar.curve,
342342
builder: (context, value, child) {
343343
return Row(
@@ -636,7 +636,7 @@ class _WordCardOverViewPage extends State<WordCardOverViewPage> {
636636
preferredSize: Size(mediaQuery.size.width, 75),
637637
child: TweenAnimationBuilder<double>(
638638
tween: Tween(begin: 0.0, end: inSearch ? 1.0 : 0.0),
639-
duration: Duration(milliseconds: 300),
639+
duration: Durations.short4,
640640
curve: StaticsVar.curve,
641641
builder: (context, value, child){
642642
return Center(
@@ -809,7 +809,7 @@ class _WordCardOverViewLayout extends State<WordCardOverViewLayout> {
809809
});
810810
jsonController.animateTo(
811811
(66 * jsonIndex).toDouble(),
812-
duration: Duration(milliseconds: 200),
812+
duration: Durations.medium1,
813813
curve: StaticsVar.curve
814814
);
815815
},
@@ -835,18 +835,18 @@ class _WordCardOverViewLayout extends State<WordCardOverViewLayout> {
835835
if(value) {
836836
classController.animateTo(
837837
(64 * classIndex).toDouble(),
838-
duration: Duration(milliseconds: 200),
838+
duration: Durations.medium1,
839839
curve: StaticsVar.curve
840840
);
841841
jsonController.animateTo(
842842
(66 * (jsonIndex + 1)).toDouble(),
843-
duration: Duration(milliseconds: 200),
843+
duration: Durations.medium1,
844844
curve: StaticsVar.curve
845845
);
846846
} else {
847847
jsonController.animateTo(
848848
(66 * jsonIndex).toDouble(),
849-
duration: Duration(milliseconds: 200),
849+
duration: Durations.medium1,
850850
curve: StaticsVar.curve
851851
);
852852
}

lib/sub_pages_builder/setting_pages/debug_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class _DebugPage extends State<DebugPage> {
2525
floatingActionButton: FloatingActionButton(
2626
child: Icon(Icons.arrow_upward),
2727
onPressed: (){
28-
controller.animateTo(0, duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
28+
controller.animateTo(0, duration: Durations.medium2, curve: StaticsVar.curve);
2929
}
3030
),
3131
body: ListView(

0 commit comments

Comments
 (0)