pikapika/lib/screens/AboutScreen.dart

230 lines
6.5 KiB
Dart
Raw Normal View History

2021-11-11 09:05:48 +00:00
import 'package:flutter/gestures.dart';
2021-09-29 23:57:09 +00:00
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
2021-11-11 09:05:48 +00:00
import 'package:pikapika/basic/Cross.dart';
import 'package:pikapika/basic/config/Version.dart';
import 'package:pikapika/screens/components/Badge.dart';
2022-03-19 04:12:27 +00:00
import 'components/RightClickPop.dart';
2021-11-11 09:05:48 +00:00
const _releasesUrl = "https://github.com/niuhuan/pikapika/releases";
2021-09-29 23:57:09 +00:00
2021-11-04 03:45:22 +00:00
// 关于
2021-11-11 09:05:48 +00:00
class AboutScreen extends StatefulWidget {
2022-03-17 03:31:25 +00:00
const AboutScreen({Key? key}) : super(key: key);
2021-11-11 09:05:48 +00:00
@override
State<StatefulWidget> createState() => _AboutScreenState();
}
class _AboutScreenState extends State<AboutScreen> {
@override
void initState() {
versionEvent.subscribe(_onVersion);
super.initState();
}
@override
void dispose() {
versionEvent.unsubscribe(_onVersion);
super.dispose();
}
void _onVersion(dynamic a) {
setState(() {});
}
2021-09-29 23:57:09 +00:00
@override
2022-03-19 04:12:27 +00:00
Widget build(BuildContext context){
return RightClickPop(buildScreen(context));
}
Widget buildScreen(BuildContext context) {
2021-09-29 23:57:09 +00:00
var size = MediaQuery.of(context).size;
var min = size.width < size.height ? size.width : size.height;
2021-11-11 09:05:48 +00:00
var _currentVersion = currentVersion();
var _latestVersion = latestVersion();
var _latestVersionInfo = latestVersionInfo();
2021-11-11 09:05:48 +00:00
var _dirty = dirtyVersion();
2021-09-29 23:57:09 +00:00
return Scaffold(
appBar: AppBar(
2022-03-17 03:31:25 +00:00
title: const Text('关于'),
2021-09-29 23:57:09 +00:00
),
body: ListView(
children: [
2022-03-17 03:31:25 +00:00
SizedBox(
2021-09-29 23:57:09 +00:00
width: min / 2,
height: min / 2,
child: Center(
child: SvgPicture.asset(
'lib/assets/github.svg',
width: min / 3,
height: min / 3,
color: Colors.grey.shade500,
),
),
),
2021-11-11 09:05:48 +00:00
Container(height: 20),
2022-03-19 04:12:27 +00:00
const Divider(),
2021-09-29 23:57:09 +00:00
Container(
2022-03-19 04:12:27 +00:00
padding: const EdgeInsets.only(left: 20, right: 20),
2021-11-11 09:05:48 +00:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'软件版本 : $_currentVersion',
2022-03-19 04:12:27 +00:00
style: const TextStyle(
2021-11-11 09:05:48 +00:00
height: 1.3,
),
),
Row(
children: [
2022-03-19 04:12:27 +00:00
const Text(
2021-11-11 09:05:48 +00:00
"检查更新 : ",
style: TextStyle(
height: 1.3,
),
),
_dirty ? _buildDirty() : _buildNewVersion(_latestVersion),
Expanded(child: Container()),
],
),
_buildNewVersionInfo(_latestVersionInfo),
2021-11-11 09:05:48 +00:00
],
2021-09-29 23:57:09 +00:00
),
),
2022-03-19 04:12:27 +00:00
const Divider(),
2021-11-11 09:05:48 +00:00
autoUpdateCheckSetting(),
2022-03-19 04:12:27 +00:00
const Divider(),
2021-09-29 23:57:09 +00:00
Container(
2022-03-19 04:12:27 +00:00
padding: const EdgeInsets.all(20),
child: const SelectableText(
2021-09-29 23:57:09 +00:00
"提示 : \n"
"1. 详情页的作者/上传者/分类/标签都可以点击\n"
"2. 详情页的作者/上传者/标题长按可以复制\n"
"3. 使用分页而不是瀑布流点击页码可以快速翻页\n"
"4. 下载指的是缓存到本地, 需要导出才可以分享\n"
"5. 下载长按可以删除\n",
style: TextStyle(
height: 1.3,
),
),
),
2022-03-19 04:12:27 +00:00
const Divider(),
2021-11-11 09:05:48 +00:00
],
),
);
}
_buildNewVersion(String? latestVersion) {
if (latestVersion != null) {
return Text.rich(
TextSpan(
children: [
WidgetSpan(
child: Badged(
child: Container(
2022-03-19 04:12:27 +00:00
padding: const EdgeInsets.only(right: 12),
2021-11-11 09:05:48 +00:00
child: Text(
latestVersion,
2022-03-19 04:12:27 +00:00
style: const TextStyle(height: 1.3),
2021-11-11 09:05:48 +00:00
),
),
badge: "1",
),
),
2022-03-19 04:12:27 +00:00
const TextSpan(text: " "),
2021-11-11 09:05:48 +00:00
TextSpan(
text: "去下载",
style: TextStyle(
height: 1.3,
color: Theme.of(context).colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () => openUrl(_releasesUrl),
),
],
),
);
}
return Text.rich(
TextSpan(
children: [
2022-03-19 04:12:27 +00:00
const TextSpan(text: "未检测到新版本", style: TextStyle(height: 1.3)),
2021-11-11 09:05:48 +00:00
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Container(
2022-03-19 04:12:27 +00:00
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.only(left: 3, right: 3),
decoration: const BoxDecoration(
2021-11-11 09:05:48 +00:00
borderRadius: BorderRadius.all(Radius.circular(20)),
),
),
),
TextSpan(
text: "检查更新",
style: TextStyle(
height: 1.3,
color: Theme.of(context).colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () => manualCheckNewVersion(context),
),
2021-09-29 23:57:09 +00:00
],
),
);
}
2021-11-11 09:05:48 +00:00
Widget _buildDirty() {
return Text.rich(
TextSpan(
text: "下载RELEASE版",
style: TextStyle(
height: 1.3,
color: Theme.of(context).colorScheme.primary,
),
recognizer: TapGestureRecognizer()..onTap = () => openUrl(_releasesUrl),
),
);
}
Widget _buildNewVersionInfo(String? latestVersionInfo) {
if (latestVersionInfo != null) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2022-03-19 04:12:27 +00:00
const Divider(),
const Text("更新内容:"),
Container(
2022-03-19 04:12:27 +00:00
padding: const EdgeInsets.all(15),
child: Text(
latestVersionInfo,
2022-03-19 04:12:27 +00:00
style: const TextStyle(),
),
),
],
);
}
2021-11-19 02:09:20 +00:00
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2022-03-19 04:12:27 +00:00
const Divider(),
2021-11-19 02:09:20 +00:00
Container(
2022-03-19 04:12:27 +00:00
padding: const EdgeInsets.all(15),
2021-11-19 02:09:20 +00:00
child: Text.rich(
TextSpan(
text: "去RELEASE仓库",
style: TextStyle(
height: 1.3,
color: Theme.of(context).colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () => openUrl(_releasesUrl),
),
),
),
],
);
}
2021-09-29 23:57:09 +00:00
}