feat: 下载队列进度条视图切换;设置新增用户须知入口;检查更新/创造者/开源许可合并至关于软件页

This commit is contained in:
ZV Team committed 2026-10-24 10:56:48 +08:00
1 parent eb2f9e9ea7
commit 4277dc9f84
5 files changed
+248 -60

No files matched your search

+9
View File
@@ -405,6 +405,15 @@ class S {
'目录下没有日志文件': 'No log files in this directory',
'读取失败:{0}': 'Failed to read: {0}',
'自动刷新并跟随底部(每 5 秒)': 'Auto refresh & follow bottom (every 5s)',
'卡片视图': 'Card view',
'进度条视图': 'Progress bar view',
'用户须知': 'User Notice',
'查看用户守则全部条款': 'View all terms of the user agreement',
'关于软件': 'About',
'版本、检查更新、创造者与开源许可': 'Version, updates, creators and licenses',
'我知道了': 'Got it',
'创造者': 'Creators',
'ZV Manager 是一款 Minecraft 服务器远程管理工具,本软件与 Mojang、微软无任何隶属关系。': 'ZV Manager is a remote management tool for Minecraft servers. Not affiliated with Mojang or Microsoft.',
};
static String t(String zh) => en ? (_en[zh] ?? zh) : zh;
+25 -6
View File
@@ -5,7 +5,14 @@ import '../l10n/strings.dart';
class UserAgreementDialog extends StatefulWidget {
final VoidCallback onAgree;
const UserAgreementDialog({super.key, required this.onAgree});
/// 只读模式:设置「用户须知」入口使用,无需倒计时/勾选,按钮直接关闭。
final bool readOnly;
const UserAgreementDialog({super.key, required this.onAgree, this.readOnly = false});
/// 只读查看入口。
static Widget readView() =>
UserAgreementDialog(onAgree: () {}, readOnly: true);
@override
State<UserAgreementDialog> createState() => _UserAgreementDialogState();
@@ -13,6 +20,7 @@ class UserAgreementDialog extends StatefulWidget {
class _UserAgreementDialogState extends State<UserAgreementDialog> {
bool _isChecked = false;
bool get _readOnly => widget.readOnly;
/// 强制阅读:倒计时 10 秒 + 滚动到底,两者都满足才能勾选同意。
static const int _readSeconds = 10;
@@ -24,6 +32,11 @@ class _UserAgreementDialogState extends State<UserAgreementDialog> {
@override
void initState() {
super.initState();
if (widget.readOnly) {
_countdown = 0;
_readToEnd = true;
return;
}
_timer = Timer.periodic(const Duration(seconds: 1), (t) {
if (!mounted) return t.cancel();
setState(() => _countdown--);
@@ -48,9 +61,11 @@ class _UserAgreementDialogState extends State<UserAgreementDialog> {
}
}
bool get _canAgree => _isChecked && _countdown <= 0 && _readToEnd;
bool get _canAgree =>
_readOnly || (_isChecked && _countdown <= 0 && _readToEnd);
String get _buttonLabel {
if (_readOnly) return S.t('我知道了');
if (_countdown > 0) return S.f('请仔细阅读守则({0}s)', [_countdown]);
if (!_readToEnd) return S.t('请阅读至守则底部');
return S.t('同意并进入');
@@ -59,7 +74,7 @@ class _UserAgreementDialogState extends State<UserAgreementDialog> {
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
canPop: _readOnly,
child: Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
insetPadding: const EdgeInsets.symmetric(horizontal: 20),
@@ -152,8 +167,8 @@ class _UserAgreementDialogState extends State<UserAgreementDialog> {
),
const SizedBox(height: 16),
// 同意勾选(倒计时结束且阅读到底后才可勾选)
GestureDetector(
// 同意勾选(倒计时结束且阅读到底后才可勾选);只读模式不显示
if (!_readOnly) GestureDetector(
onTap: _countdown <= 0 && _readToEnd
? () {
setState(() {
@@ -197,7 +212,11 @@ class _UserAgreementDialogState extends State<UserAgreementDialog> {
SizedBox(
width: double.infinity,
child: FilledButton(
onPressed: _canAgree ? widget.onAgree : null,
onPressed: !_canAgree
? null
: (_readOnly
? () => Navigator.of(context).pop()
: widget.onAgree),
style: FilledButton.styleFrom(
backgroundColor: const Color(0xFF28A745),
disabledBackgroundColor: const Color(0xFFCCCCCC),