102 lines
2.9 KiB
Dart
102 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart' show rootBundle;
|
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
|
|
|
class ChangelogPage extends StatefulWidget {
|
|
const ChangelogPage({super.key});
|
|
|
|
@override
|
|
State<ChangelogPage> createState() => _ChangelogPageState();
|
|
}
|
|
|
|
class _ChangelogPageState extends State<ChangelogPage> {
|
|
String _markdownContent = '';
|
|
bool _isLoading = true;
|
|
String? _error;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadChangelog();
|
|
}
|
|
|
|
Future<void> _loadChangelog() async {
|
|
try {
|
|
final content = await rootBundle.loadString('assets/CHANGELOG.md');
|
|
setState(() {
|
|
_markdownContent = content;
|
|
_isLoading = false;
|
|
});
|
|
} catch (e) {
|
|
setState(() {
|
|
_error = '无法加载更新日志: $e';
|
|
_isLoading = false;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: AppBar(
|
|
title: const Text(
|
|
'更新日志',
|
|
style: TextStyle(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
backgroundColor: Colors.white,
|
|
elevation: 0,
|
|
foregroundColor: Colors.black,
|
|
iconTheme: const IconThemeData(color: Colors.black),
|
|
),
|
|
body: _isLoading
|
|
? const Center(child: CircularProgressIndicator())
|
|
: _error != null
|
|
? Center(
|
|
child: Text(
|
|
_error!,
|
|
style: const TextStyle(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
)
|
|
: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Markdown(
|
|
data: _markdownContent,
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
styleSheet: MarkdownStyleSheet(
|
|
h1: const TextStyle(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.w700,
|
|
color: Colors.black,
|
|
),
|
|
h2: const TextStyle(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.black87,
|
|
),
|
|
p: const TextStyle(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
fontSize: 16,
|
|
color: Colors.black87,
|
|
),
|
|
listBullet: const TextStyle(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
fontSize: 16,
|
|
color: Colors.black87,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|