Skip to content

Commit 36a44f2

Browse files
committed
add changeLog pop
1 parent 6262cc2 commit 36a44f2

File tree

7 files changed

+92
-8
lines changed

7 files changed

+92
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Changelog
22

3-
## INDEVLOPING VERSION - 2025-11-?
3+
## INDEVLOPING VERSION - 2025-11-? - (000108)
44

55
### Added
66

77
- 实现了通过FSRS算法进行规律学习功能(基本实现)
88
- 添加了ChangeLog
9+
- 添加了软件更新内容提示
910

1011
### Improvement
1112

@@ -23,13 +24,13 @@
2324

2425
> 我之前怎么蠢到直接拿YYYYMMDD做int相减啊
2526
26-
## v0.1.7 - 2025-10-27
27+
## v0.1.7 - 2025-10-27 - (000107)
2728

2829
### Added
2930

3031
- 添加了自主听写功能
3132

32-
## v0.1.6 - 2025-10-22
33+
## v0.1.6 - 2025-10-22 - (000106)
3334

3435
### Added
3536

@@ -40,7 +41,7 @@
4041
- 一些UI改善
4142
- ...
4243

43-
## v0.1.5 - 2025-10-19
44+
## v0.1.5 - 2025-10-19 - (000105)
4445

4546
### Added
4647

@@ -50,7 +51,7 @@
5051
- 添加的抗遗忘学习(目前仅UI 具体实现在TODO #5
5152
- 其他细节更新
5253

53-
## v0.1.4 - 2025-10-18
54+
## v0.1.4 - 2025-10-18 - (000104)
5455

5556
### Added
5657

lib/funcs/utili.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,22 @@ extension ListExtensions on List {
163163

164164
int getStrokeDays(Map<String, dynamic> settingData) {
165165
return (settingData["learning"]["lastDate"] - DateTime.now().difference(DateTime(2025, 11, 1)).inDays > 1) ? "0" : (settingData["learning"]["lastDate"] - settingData["learning"]["startDate"] + 1);
166+
}
167+
168+
extension ZFillExtension on num {
169+
String zfill(int width) => _zfillImpl(this, width);
170+
}
171+
172+
String _zfillImpl(num value, int width) {
173+
if (width <= 0) return value.toString();
174+
175+
String raw = value.toString();
176+
bool isNegative = raw.startsWith('-');
177+
if (isNegative) raw = raw.substring(1);
178+
179+
int padding = width - raw.length - (isNegative ? 1 : 0);
180+
if (padding <= 0) return isNegative ? '-$raw' : raw;
181+
182+
String zeros = '0' * padding;
183+
return isNegative ? '-$zeros$raw' : '$zeros$raw';
166184
}

lib/main.dart

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import 'package:arabic_learning/funcs/ui.dart';
2+
import 'package:arabic_learning/funcs/utili.dart';
13
import 'package:arabic_learning/vars/global.dart';
24
import 'package:arabic_learning/vars/license_storage.dart';
35
import 'package:arabic_learning/vars/statics_var.dart';
46
import 'package:flutter/foundation.dart';
57
import 'package:flutter/material.dart';
68
import 'package:convex_bottom_bar/convex_bottom_bar.dart';
79
import 'package:flutter/services.dart';
10+
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
11+
import 'package:http/http.dart' as http;
812
import 'package:window_manager/window_manager.dart';
913
import 'package:provider/provider.dart';
1014
import 'package:url_launcher/url_launcher.dart';
@@ -194,7 +198,6 @@ class _MyHomePageState extends State<MyHomePage> {
194198
Widget build(BuildContext context) {
195199
final gob = context.watch<Global>();
196200
if(gob.firstStart) {
197-
198201
return Scaffold(
199202
body: PopScope(
200203
canPop: false,
@@ -293,6 +296,48 @@ class _MyHomePageState extends State<MyHomePage> {
293296
),
294297
body: LayoutBuilder(
295298
builder: (context, constraints) {
299+
if(gob.updateLogRequire) {
300+
gob.updateLogRequire = false;
301+
Future.delayed(Duration(seconds: 2), () async {
302+
late http.Response githubResponse;
303+
try {
304+
githubResponse = await http.get(Uri.parse("https://github.com/OctagonalStar/arabic_learning/raw/refs/heads/main/CHANGELOG.md"));
305+
} catch (e){
306+
return;
307+
}
308+
if(githubResponse.statusCode == 200 && context.mounted) {
309+
showModalBottomSheet(
310+
context: context,
311+
shape: RoundedSuperellipseBorder(side: BorderSide(width: 1.0, color: Theme.of(context).colorScheme.onSurface), borderRadius: StaticsVar.br),
312+
enableDrag: true,
313+
isDismissible: false,
314+
isScrollControlled: true,
315+
builder: (context) {
316+
return Material(
317+
child: Column(
318+
children: [
319+
TextContainer(text: "更新内容 软件版本: ${StaticsVar.appVersion.zfill(6)}"),
320+
SizedBox(
321+
height: MediaQuery.of(context).size.height * 0.8,
322+
child: Markdown(data: githubResponse.body)
323+
),
324+
ElevatedButton(
325+
style: ElevatedButton.styleFrom(
326+
fixedSize: Size(double.infinity, MediaQuery.of(context).size.height * 0.07)
327+
),
328+
onPressed: () {
329+
Navigator.pop(context);
330+
},
331+
child: Text("知道了")
332+
)
333+
],
334+
)
335+
);
336+
},
337+
);
338+
}
339+
});
340+
}
296341
// 根据屏幕宽度决定使用哪种布局
297342
if (constraints.maxWidth > _desktopBreakpoint) {
298343
Provider.of<Global>(context, listen: false).isWideScreen = true;

lib/vars/global.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,21 @@ class Global with ChangeNotifier {
129129

130130
void conveySetting() {
131131
Map<String, dynamic> oldSetting = jsonDecode(prefs.getString("settingData")!) as Map<String, dynamic>;
132-
if(oldSetting["LastVersion"]??"" != _settingData["LastVersion"]) {
132+
if(oldSetting["LastVersion"] != _settingData["LastVersion"]) {
133133
updateLogRequire = true;
134+
oldSetting["LastVersion"] = _settingData["LastVersion"];
134135
} else {
135136
updateLogRequire = false;
136137
}
137138
_settingData = deepMerge(_settingData, oldSetting);
139+
if(updateLogRequire) updateSetting(_settingData);
138140
}
139141

140142
Future<void> init() async {
141143
prefs = await SharedPreferences.getInstance();
142144
firstStart = prefs.getString("settingData") == null;
143145
if(firstStart) {
146+
updateLogRequire = false;
144147
await prefs.setString("wordData", jsonEncode({"Words": [], "Classes": {}}));
145148
wordData = jsonDecode(jsonEncode({"Words": [], "Classes": {}})) as Map<String, dynamic>;
146149
} else {

lib/vars/statics_var.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:just_audio/just_audio.dart';
66

77
class StaticsVar {
88
static const String appName = 'Ar 学';
9-
static const double appVersion = 0.010702;
9+
static const int appVersion = 000108;
1010
static const String modelPath = 'arabicLearning/tts/model/vits-piper-ar_JO-kareem-medium';
1111
static const Map<String, dynamic> tempConfig = {"SelectedClasses": []};
1212
static const String onlineDictOwner = 'JYinherit';

pubspec.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ packages:
206206
url: "https://pub.flutter-io.cn"
207207
source: hosted
208208
version: "5.0.0"
209+
flutter_markdown_plus:
210+
dependency: "direct main"
211+
description:
212+
name: flutter_markdown_plus
213+
sha256: "7f349c075157816da399216a4127096108fd08e1ac931e34e72899281db4113c"
214+
url: "https://pub.flutter-io.cn"
215+
source: hosted
216+
version: "1.0.5"
209217
flutter_plugin_android_lifecycle:
210218
dependency: transitive
211219
description:
@@ -344,6 +352,14 @@ packages:
344352
url: "https://pub.flutter-io.cn"
345353
source: hosted
346354
version: "5.1.1"
355+
markdown:
356+
dependency: transitive
357+
description:
358+
name: markdown
359+
sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1"
360+
url: "https://pub.flutter-io.cn"
361+
source: hosted
362+
version: "7.3.0"
347363
matcher:
348364
dependency: transitive
349365
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dependencies:
4747
archive: ^4.0.7
4848
dio: ^5.9.0
4949
fsrs: ^2.0.1
50+
flutter_markdown_plus: ^1.0.5
5051
# fl_chart: ^1.1.1
5152
# 暂时不用
5253
# 25.10.31 注释: 感觉依赖项好多,后续可以考虑精简

0 commit comments

Comments
 (0)