Skip to content

Commit 0df34ec

Browse files
Merge pull request #39 from OctagonalStar/dev
small fixes
2 parents 68ce251 + 4ad1c8d commit 0df34ec

File tree

7 files changed

+39
-28
lines changed

7 files changed

+39
-28
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414
- 优化了网页端字体加载逻辑
1515
- 重构了Config数据结构 [#27](https://github.com/OctagonalStar/arabic_learning/issues/27)
1616
- 重构了软件运行时数据结构 [#16](https://github.com/OctagonalStar/arabic_learning/issues/16)
17+
- 优化连胜逻辑: FSRS复习也计算为连胜
18+
- 调整了部分按钮的UI设计
19+
- 去除了查看详解时,单词卡片的高斯模糊
1720

1821
### Fix
1922

2023
- 修复了FSRS算法对已经过期的单词无法计数的问题
2124
- 修复了日志中FSRS信息输出错误的问题
2225
- 修复了新用户无法进入的问题
26+
- 修复了FSRS复习界面中,“下一题”动画期间文字溢出的问题
2327

2428
## v0.1.11 - 2025-11-28 - (000111)
2529

ios/Runner/AppDelegate.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import UIKit
77
_ application: UIApplication,
88
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
99
) -> Bool {
10-
if #available(iOS 10.0, *) {
11-
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
12-
}
1310
GeneratedPluginRegistrant.register(with: self)
1411
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
1512
}

lib/funcs/ui.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ void viewAnswer(BuildContext context, WordItem wordData) async {
210210
enableDrag: true,
211211
builder: (context) {
212212
return Container(
213-
padding: EdgeInsets.only(top: mediaQuery.size.height * 0.05),
214213
decoration: BoxDecoration(
215214
color: Theme.of(context).colorScheme.onPrimary,
216215
borderRadius: StaticsVar.br,
217216
),
218217
child: Column(
218+
mainAxisSize: MainAxisSize.min,
219219
children: [
220-
Expanded(child: WordCard(word: wordData)),
220+
WordCard(word: wordData, useMask: false),
221221
ElevatedButton(
222222
onPressed: () {Navigator.pop(context);},
223223
style: ElevatedButton.styleFrom(

lib/funcs/utili.dart

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:convert';
22
import 'package:arabic_learning/vars/config_structure.dart';
33
import 'package:archive/archive.dart';
44
import 'package:flutter_tts/flutter_tts.dart';
5+
import 'package:logging/logging.dart';
56
import 'package:path_provider/path_provider.dart' as path_provider;
67
import 'package:arabic_learning/package_replacement/fake_dart_io.dart' if (dart.library.io) 'dart:io' as io;
78
import 'package:arabic_learning/package_replacement/fake_sherpa_onnx.dart' if (dart.library.io) 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx;
@@ -263,6 +264,7 @@ class _RootPattern {
263264
/// 该模式对应的词性
264265
final ArabicPOS pos;
265266

267+
// ignore: unused_element_parameter
266268
_RootPattern(this.name, String pattern, this.pos, {this.groups = const [1, 2, 3]})
267269
: regex = RegExp(pattern);
268270
}
@@ -392,8 +394,11 @@ class ArabicStemmer {
392394
if (s.length > 3 && (s.startsWith('و') || s.startsWith('ف'))) s = s.substring(1);
393395

394396
if (s.length > 4) {
395-
if (s.endsWith('ات') || s.endsWith('ون') || s.endsWith('ين')) s = s.substring(0, s.length - 2);
396-
else if (s.endsWith('ي')) s = s.substring(0, s.length - 1);
397+
if (s.endsWith('ات') || s.endsWith('ون') || s.endsWith('ين')) {
398+
s = s.substring(0, s.length - 2);
399+
} else if (s.endsWith('ي')) {
400+
s = s.substring(0, s.length - 1);
401+
}
397402
// 注意:这里去掉了对 'ه' (Ha) 的移除,因为我们不再把 'ة' 转为 'ه'
398403
// 如果 'ه' 是原生字母或代词后缀,仍需小心
399404
}
@@ -520,26 +525,25 @@ class VocabularyOptimizer {
520525

521526
/// 1. 初始化: BKSearch.init(['ktb', 'maktaba', ...]);
522527
/// 2. 搜索: var results = BKSearch.search('kitab');
528+
@immutable
523529
class BKSearch {
524530
// 私有构造函数,防止外部实例化
525-
BKSearch._();
531+
const BKSearch._();
526532

527533
// 单例实例
528534
static final VocabularyOptimizer _optimizer = VocabularyOptimizer();
529535
static bool _isInitialized = false;
530536

537+
static final Logger logger = Logger("BKTree");
538+
531539
/// [必须调用] 初始化搜索引擎
532540
/// 通常在 App 启动或加载词库时调用
533541
static void init(List<String> allWords) {
534542
if (_isInitialized) return; // 避免重复初始化
535-
print("正在构建 BK-Tree 搜索索引,词库大小: ${allWords.length}...");
536-
final stopwatch = Stopwatch()..start();
537-
543+
logger.info("正在构建 BK-Tree 搜索索引,词库大小: ${allWords.length}...");
538544
_optimizer.build(allWords);
539-
540-
stopwatch.stop();
541545
_isInitialized = true;
542-
print("BK-Tree 索引构建完成,耗时: ${stopwatch.elapsedMilliseconds}ms");
546+
logger.info("BK-Tree 索引构建完成");
543547
}
544548

545549
/// 普通搜索: 返回所有相似词列表

lib/pages/learning_page.dart

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class LearningPage extends StatelessWidget {
5050
),
5151
Column(
5252
children: [
53-
ElevatedButton.icon(
53+
ElevatedButton(
5454
style: ElevatedButton.styleFrom(
5555
backgroundColor: Theme.of(context).colorScheme.secondaryContainer.withAlpha(150),
5656
foregroundColor: Theme.of(context).colorScheme.onSurface.withAlpha(150),
@@ -61,11 +61,10 @@ class LearningPage extends StatelessWidget {
6161
onPressed: () {
6262
shiftToStudy(context, 2);
6363
},
64-
icon: Icon(Icons.arrow_back, size: 24.0),
65-
label: FittedBox(fit: BoxFit.fitWidth ,child: Text("阿译中专项", style: TextStyle(fontSize: 32.0))),
64+
child: FittedBox(fit: BoxFit.fitWidth ,child: Text("阿译中专项", style: TextStyle(fontSize: 32.0))),
6665
),
6766
SizedBox(height: mediaQuery.size.height * 0.005),
68-
ElevatedButton.icon(
67+
ElevatedButton(
6968
style: ElevatedButton.styleFrom(
7069
backgroundColor: Theme.of(context).colorScheme.secondaryContainer.withAlpha(150),
7170
foregroundColor: Theme.of(context).colorScheme.onSurface.withAlpha(150),
@@ -76,8 +75,7 @@ class LearningPage extends StatelessWidget {
7675
onPressed: () {
7776
shiftToStudy(context, 1);
7877
},
79-
icon: Icon(Icons.arrow_forward, size: 24.0),
80-
label: FittedBox(fit: BoxFit.fitWidth ,child: Text("中译阿专项", style: TextStyle(fontSize: 32.0))),
78+
child: FittedBox(fit: BoxFit.fitWidth ,child: Text("中译阿专项", style: TextStyle(fontSize: 32.0))),
8179
),
8280
],
8381
),
@@ -87,7 +85,7 @@ class LearningPage extends StatelessWidget {
8785
Row(
8886
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
8987
children: [
90-
ElevatedButton.icon(
88+
ElevatedButton(
9189
style: ElevatedButton.styleFrom(
9290
backgroundColor: Theme.of(context).colorScheme.onPrimary.withAlpha(150),
9391
shadowColor: Colors.transparent,
@@ -105,8 +103,15 @@ class LearningPage extends StatelessWidget {
105103
)
106104
);
107105
},
108-
icon: Icon(Icons.history_edu, size: 24.0),
109-
label: FittedBox(fit: BoxFit.fitWidth ,child: Text("规律性学习", style: TextStyle(fontSize: 32.0))),
106+
child: FittedBox(
107+
fit: BoxFit.contain,
108+
child: Column(
109+
children: [
110+
Icon(Icons.history_edu, size: 24.0),
111+
Text("规律性学习", style: TextStyle(fontSize: 32.0)),
112+
],
113+
)
114+
),
110115
),
111116
ElevatedButton(
112117
style: ElevatedButton.styleFrom(
@@ -160,7 +165,7 @@ Future<void> shiftToStudy(BuildContext context, int studyType) async {
160165
if(!context.mounted) return;
161166
context.read<Global>().uiLogger.info("返回完成情况: $finished");
162167
if(finished??false) {
163-
context.read<Global>().saveLearningProgress(words);
168+
context.read<Global>().updateLearningStreak();
164169
}
165170
}
166171

lib/sub_pages_builder/learning_pages/fsrs_pages.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ class _FSRSReviewCardPage extends State<FSRSReviewCardPage> {
269269
});
270270
if(correct == value) {
271271
widget.fsrs.reviewCard(widget.wordID, DateTime.now().difference(start).inMilliseconds, true);
272+
context.read<Global>().updateLearningStreak();
272273
return true;
273274
} else {
274275
widget.fsrs.reviewCard(widget.wordID, DateTime.now().difference(start).inMilliseconds, false);
@@ -310,7 +311,7 @@ class _FSRSReviewCardPage extends State<FSRSReviewCardPage> {
310311
widget.controller.nextPage(duration: Duration(milliseconds: 500), curve: StaticsVar.curve);
311312
},
312313
icon: Icon(Icons.arrow_downward),
313-
label: Text("下一题"),
314+
label: FittedBox(fit: BoxFit.contain, child: Text("下一题")),
314315
)
315316
],
316317
);

lib/vars/global.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ class Global with ChangeNotifier {
270270
notifyListeners();
271271
}
272272

273-
void saveLearningProgress(List<WordItem> words){
274-
logger.info("保存学习进度中");
275-
// 以 2025/11/1 为基准计算天数(因为这个bug是这天修的:} )
273+
void updateLearningStreak(){
276274
final int nowDate = DateTime.now().difference(DateTime(2025, 11, 1)).inDays;
277275
if (nowDate == globalConfig.learning.lastDate) return;
276+
logger.info("保存学习进度中");
277+
// 以 2025/11/1 为基准计算天数(因为这个bug是这天修的:} )
278278
if (nowDate - globalConfig.learning.lastDate > 1) {
279279
globalConfig = globalConfig.copyWith(learning: globalConfig.learning.copyWith(startDate: nowDate));
280280
}

0 commit comments

Comments
 (0)