Skip to content

Commit 90ca789

Browse files
author
liuchuancong
committed
fix(添加markDown 显示)
1 parent f9ad106 commit 90ca789

8 files changed

Lines changed: 149 additions & 65 deletions

File tree

.vscode/launch.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"name": "Flutter with Proxy",
66
"request": "launch",
77
"type": "dart",
8-
"env": {
9-
"http_proxy": "http://127.0.0.1:7890",
10-
"https_proxy": "http://127.0.0.1:7890",
11-
"HTTP_PROXY": "http://127.0.0.1:7890",
12-
"HTTPS_PROXY": "http://127.0.0.1:7890"
13-
}
8+
// "env": {
9+
// "http_proxy": "http://127.0.0.1:7890",
10+
// "https_proxy": "http://127.0.0.1:7890",
11+
// "HTTP_PROXY": "http://127.0.0.1:7890",
12+
// "HTTPS_PROXY": "http://127.0.0.1:7890"
13+
// }
1414
}
1515
]
1616
}

lib/common/utils/version_util.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:http/http.dart' as http;
55
class VersionUtil {
66
static const String version = '2.0.5';
77
static const String projectUrl = 'https://github.com/liuchuancong/pure_live';
8-
static const String releaseUrl = 'https://api.github.com/repos/liuchuancong/pure_live/releases';
8+
static const String releaseUrl = 'https://api.github.com/repos/liuchuancong/pure_live/releases?per_page=30';
99
static const String issuesUrl = 'https://github.com/liuchuancong/pure_live/issues';
1010
static const String kanbanUrl =
1111
'https://jackiu-notes.notion.site/50bc0d3d377445eea029c6e3d4195671?v=663125e639b047cea5e69d8264926b8b';

lib/modules/about/about_page.dart

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import 'package:get/get.dart';
22
import 'widgets/version_dialog.dart';
33
import 'package:pure_live/common/index.dart';
44
import 'package:url_launcher/url_launcher.dart';
5+
import 'package:markdown_widget/config/configs.dart';
6+
import 'package:markdown_widget/widget/markdown_block.dart';
57

68
class AboutPage extends StatefulWidget {
79
const AboutPage({super.key});
@@ -29,7 +31,6 @@ class _AboutPageState extends State<AboutPage> {
2931
},
3032
),
3133
ListTile(title: Text(S.of(context).what_is_new), onTap: showNewFeaturesDialog),
32-
ListTile(title: Text(S.of(context).check_update), onTap: () => showCheckUpdateDialog(context)),
3334
ListTile(
3435
title: const Text('历史记录'),
3536
subtitle: const Text('历史版本更新记录'),
@@ -59,7 +60,7 @@ class _AboutPageState extends State<AboutPage> {
5960
void showCheckUpdateDialog(BuildContext context) async {
6061
showDialog(
6162
context: Get.context!,
62-
builder: (context) => VersionUtil.hasNewVersion() ? NewVersionDialog() : const NoNewVersionDialog(),
63+
builder: (context) => VersionUtil.hasNewVersion() ? NewVersionDialog() : NoNewVersionDialog(),
6364
);
6465
}
6566

@@ -73,21 +74,41 @@ class _AboutPageState extends State<AboutPage> {
7374
}
7475

7576
void showNewFeaturesDialog() {
77+
final config = Get.isDarkMode ? MarkdownConfig.darkConfig : MarkdownConfig.defaultConfig;
78+
final mediaQuery = MediaQuery.of(context);
79+
final maxWidth = mediaQuery.size.width * 0.9;
80+
final maxHeight = mediaQuery.size.height * 0.7;
7681
showDialog(
7782
context: context,
78-
builder: (context) => AlertDialog(
79-
title: Text(S.of(context).what_is_new),
80-
content: Column(
81-
crossAxisAlignment: CrossAxisAlignment.start,
82-
mainAxisSize: MainAxisSize.min,
83-
children: [
84-
Text('Version ${VersionUtil.latestVersion}'),
85-
const SizedBox(height: 20),
86-
Text(VersionUtil.latestUpdateLog, style: Theme.of(context).textTheme.bodySmall),
87-
const SizedBox(height: 10),
88-
],
89-
),
90-
),
83+
builder: (context) {
84+
return AlertDialog(
85+
title: Text(S.of(context).what_is_new),
86+
content: ConstrainedBox(
87+
constraints: BoxConstraints(maxWidth: maxWidth, maxHeight: maxHeight),
88+
child: SingleChildScrollView(
89+
child: Column(
90+
crossAxisAlignment: CrossAxisAlignment.start,
91+
mainAxisSize: MainAxisSize.min,
92+
children: [
93+
TextButton(
94+
onPressed: () {
95+
Navigator.pop(context);
96+
launchUrl(
97+
Uri.parse('https://github.com/liuchuancong/pure_live'),
98+
mode: LaunchMode.externalApplication,
99+
);
100+
},
101+
child: const Text('本软件开源免费', style: TextStyle(fontSize: 20)),
102+
),
103+
MarkdownBlock(data: VersionUtil.latestUpdateLog, config: config),
104+
const SizedBox(height: 10),
105+
],
106+
),
107+
),
108+
),
109+
actionsAlignment: MainAxisAlignment.start,
110+
);
111+
},
91112
);
92113
}
93114
}

lib/modules/about/version_history.dart

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import 'package:get/get.dart';
12
import 'package:pure_live/common/index.dart';
3+
import 'package:markdown_widget/config/configs.dart';
4+
import 'package:markdown_widget/widget/markdown_block.dart';
25

36
class VersionHistoryPage extends StatefulWidget {
47
const VersionHistoryPage({super.key});
@@ -16,33 +19,28 @@ class _VersionHistoryPageState extends State<VersionHistoryPage> {
1619

1720
List<Widget> getRichTextList() {
1821
List<VersionHistoryModel> versions = loadHistoryList();
22+
final config = Get.isDarkMode ? MarkdownConfig.darkConfig : MarkdownConfig.defaultConfig;
1923
return versions
20-
.map((e) => Padding(
21-
padding: const EdgeInsets.all(16.0),
22-
child: Column(
23-
mainAxisAlignment: MainAxisAlignment.start,
24-
crossAxisAlignment: CrossAxisAlignment.start,
25-
children: [
26-
Text(
27-
e.version,
28-
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
29-
),
30-
Text(
31-
e.updateBody,
32-
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
33-
),
34-
],
35-
),
36-
))
24+
.map(
25+
(e) => Padding(
26+
padding: const EdgeInsets.all(16.0),
27+
child: Column(
28+
mainAxisAlignment: MainAxisAlignment.start,
29+
crossAxisAlignment: CrossAxisAlignment.start,
30+
children: [
31+
Text(e.version, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
32+
MarkdownBlock(data: e.updateBody, config: config),
33+
],
34+
),
35+
),
36+
)
3737
.toList();
3838
}
3939

4040
@override
4141
Widget build(BuildContext context) {
4242
return Scaffold(
43-
appBar: AppBar(
44-
title: const Text('版本历史更新'),
45-
),
43+
appBar: AppBar(title: const Text('版本历史更新')),
4644
body: ListView(
4745
scrollDirection: Axis.vertical,
4846
physics: const AlwaysScrollableScrollPhysics(),

lib/modules/about/widgets/version_dialog.dart

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:get/get.dart';
22
import 'package:pure_live/common/index.dart';
33
import 'package:url_launcher/url_launcher.dart';
4+
import 'package:markdown_widget/config/configs.dart';
5+
import 'package:markdown_widget/widget/markdown_block.dart';
46

57
class NoNewVersionDialog extends StatelessWidget {
68
const NoNewVersionDialog({super.key});
@@ -26,38 +28,48 @@ class NewVersionDialog extends StatelessWidget {
2628
const NewVersionDialog({super.key, this.entry});
2729

2830
final OverlayEntry? entry;
31+
2932
@override
3033
Widget build(BuildContext context) {
34+
final mediaQuery = MediaQuery.of(context);
35+
final maxWidth = mediaQuery.size.width * 0.9;
36+
final maxHeight = mediaQuery.size.height * 0.7;
37+
final config = Get.isDarkMode ? MarkdownConfig.darkConfig : MarkdownConfig.defaultConfig;
3138
return AlertDialog(
3239
title: Text(S.of(context).check_update),
33-
content: Column(
34-
crossAxisAlignment: CrossAxisAlignment.start,
35-
mainAxisSize: MainAxisSize.min,
36-
children: [
37-
Text(S.of(context).new_version_info(VersionUtil.latestVersion)),
38-
const SizedBox(height: 20),
39-
Text(VersionUtil.latestUpdateLog, style: Theme.of(context).textTheme.bodySmall),
40-
const SizedBox(height: 10),
41-
TextButton(
42-
onPressed: () {
43-
if (entry != null) {
44-
entry!.remove();
45-
} else {
46-
Navigator.pop(context);
47-
}
48-
launchUrl(Uri.parse('https://github.com/liuchuancong/pure_live'), mode: LaunchMode.externalApplication);
49-
},
50-
child: const Text('本软件开源免费'),
40+
content: ConstrainedBox(
41+
constraints: BoxConstraints(maxWidth: maxWidth, maxHeight: maxHeight),
42+
child: SingleChildScrollView(
43+
child: Column(
44+
crossAxisAlignment: CrossAxisAlignment.start,
45+
mainAxisSize: MainAxisSize.min,
46+
children: [
47+
TextButton(
48+
onPressed: () {
49+
if (entry != null) {
50+
entry!.remove();
51+
} else {
52+
Navigator.pop(context);
53+
}
54+
launchUrl(
55+
Uri.parse('https://github.com/liuchuancong/pure_live'),
56+
mode: LaunchMode.externalApplication,
57+
);
58+
},
59+
child: const Text('本软件开源免费', style: TextStyle(fontSize: 20)),
60+
),
61+
MarkdownBlock(data: VersionUtil.latestUpdateLog, config: config),
62+
const SizedBox(height: 10),
63+
],
5164
),
52-
],
65+
),
5366
),
5467
actionsAlignment: MainAxisAlignment.start,
5568
actions: <Widget>[
5669
Row(
5770
mainAxisSize: MainAxisSize.max,
5871
mainAxisAlignment: MainAxisAlignment.spaceBetween,
5972
children: [
60-
// RoutePath.kVersionPage
6173
TextButton(
6274
child: Text(S.of(context).cancel),
6375
onPressed: () {

lib/modules/version/version_page.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'package:get/get.dart';
22
import 'package:flutter/material.dart';
33
import 'package:pure_live/plugins/update.dart';
4+
import 'package:markdown_widget/config/configs.dart';
5+
import 'package:pure_live/common/utils/version_util.dart';
6+
import 'package:markdown_widget/widget/markdown_block.dart';
47
import 'package:pure_live/common/global/platform_utils.dart';
58
import 'package:pure_live/modules/version/version_controller.dart';
69

@@ -13,15 +16,12 @@ class VersionPage extends GetView<VersionController> {
1316
appBar: AppBar(title: const Text('版本更新')),
1417
body: Obx(() {
1518
if (controller.loading.value) {
16-
// ✅ 加载状态:在整个 body 区域居中(非滚动内)
1719
return Center(child: CircularProgressIndicator.adaptive());
1820
}
19-
2021
final hasAnyContent =
2122
(PlatformUtils.isDesktop && controller.windowsUrl.value.isNotEmpty == true) ||
2223
(PlatformUtils.isMobile &&
2324
(controller.apkUrl.value.isNotEmpty == true || controller.apkUrl2.value.isNotEmpty == true));
24-
2525
if (!hasAnyContent) {
2626
return const Center(
2727
child: Padding(
@@ -48,6 +48,10 @@ class VersionPage extends GetView<VersionController> {
4848
const SizedBox(height: 24),
4949
_buildDownloadSection(title: 'ARM32 (armeabi-v7a) 版本', urls: controller.apkUrl.value),
5050
],
51+
MarkdownBlock(
52+
data: VersionUtil.latestUpdateLog,
53+
config: Get.isDarkMode ? MarkdownConfig.darkConfig : MarkdownConfig.defaultConfig,
54+
),
5155
],
5256
),
5357
),

pubspec.lock

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,14 @@ packages:
568568
url: "https://pub.flutter-io.cn"
569569
source: hosted
570570
version: "2.0.0"
571+
flutter_highlight:
572+
dependency: transitive
573+
description:
574+
name: flutter_highlight
575+
sha256: "7b96333867aa07e122e245c033b8ad622e4e3a42a1a2372cbb098a2541d8782c"
576+
url: "https://pub.flutter-io.cn"
577+
source: hosted
578+
version: "0.7.0"
571579
flutter_inappwebview:
572580
dependency: "direct main"
573581
description:
@@ -840,6 +848,14 @@ packages:
840848
url: "https://pub.flutter-io.cn"
841849
source: hosted
842850
version: "3.0.1"
851+
highlight:
852+
dependency: transitive
853+
description:
854+
name: highlight
855+
sha256: "5353a83ffe3e3eca7df0abfb72dcf3fa66cc56b953728e7113ad4ad88497cf21"
856+
url: "https://pub.flutter-io.cn"
857+
source: hosted
858+
version: "0.7.0"
843859
hive_ce:
844860
dependency: "direct main"
845861
description:
@@ -1048,6 +1064,22 @@ packages:
10481064
url: "https://pub.flutter-io.cn"
10491065
source: hosted
10501066
version: "1.9.0"
1067+
markdown:
1068+
dependency: transitive
1069+
description:
1070+
name: markdown
1071+
sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1"
1072+
url: "https://pub.flutter-io.cn"
1073+
source: hosted
1074+
version: "7.3.0"
1075+
markdown_widget:
1076+
dependency: "direct main"
1077+
description:
1078+
name: markdown_widget
1079+
sha256: b52c13d3ee4d0e60c812e15b0593f142a3b8a2003cde1babb271d001a1dbdc1c
1080+
url: "https://pub.flutter-io.cn"
1081+
source: hosted
1082+
version: "2.3.2+8"
10511083
matcher:
10521084
dependency: transitive
10531085
description:
@@ -1577,6 +1609,14 @@ packages:
15771609
url: "https://pub.flutter-io.cn"
15781610
source: hosted
15791611
version: "0.2.0"
1612+
scroll_to_index:
1613+
dependency: transitive
1614+
description:
1615+
name: scroll_to_index
1616+
sha256: b707546e7500d9f070d63e5acf74fd437ec7eeeb68d3412ef7b0afada0b4f176
1617+
url: "https://pub.flutter-io.cn"
1618+
source: hosted
1619+
version: "3.0.1"
15801620
share_handler:
15811621
dependency: "direct main"
15821622
description:
@@ -2039,6 +2079,14 @@ packages:
20392079
url: "https://pub.flutter-io.cn"
20402080
source: hosted
20412081
version: "2.2.0"
2082+
visibility_detector:
2083+
dependency: transitive
2084+
description:
2085+
name: visibility_detector
2086+
sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420
2087+
url: "https://pub.flutter-io.cn"
2088+
source: hosted
2089+
version: "0.4.0+2"
20422090
vm_service:
20432091
dependency: transitive
20442092
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ dependencies:
105105
rxdart: ^0.28.0
106106
hive_ce: ^2.15.1
107107
hive_ce_flutter: ^2.3.3
108+
markdown_widget: ^2.3.2+8
108109
dev_dependencies:
109110
flutter_test:
110111
sdk: flutter

0 commit comments

Comments
 (0)