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', '目录下没有日志文件': 'No log files in this directory',
'读取失败:{0}': 'Failed to read: {0}', '读取失败:{0}': 'Failed to read: {0}',
'自动刷新并跟随底部(每 5 秒)': 'Auto refresh & follow bottom (every 5s)', '自动刷新并跟随底部(每 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; 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 { class UserAgreementDialog extends StatefulWidget {
final VoidCallback onAgree; 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 @override
State<UserAgreementDialog> createState() => _UserAgreementDialogState(); State<UserAgreementDialog> createState() => _UserAgreementDialogState();
@@ -13,6 +20,7 @@ class UserAgreementDialog extends StatefulWidget {
class _UserAgreementDialogState extends State<UserAgreementDialog> { class _UserAgreementDialogState extends State<UserAgreementDialog> {
bool _isChecked = false; bool _isChecked = false;
bool get _readOnly => widget.readOnly;
/// 强制阅读:倒计时 10 秒 + 滚动到底,两者都满足才能勾选同意。 /// 强制阅读:倒计时 10 秒 + 滚动到底,两者都满足才能勾选同意。
static const int _readSeconds = 10; static const int _readSeconds = 10;
@@ -24,6 +32,11 @@ class _UserAgreementDialogState extends State<UserAgreementDialog> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (widget.readOnly) {
_countdown = 0;
_readToEnd = true;
return;
}
_timer = Timer.periodic(const Duration(seconds: 1), (t) { _timer = Timer.periodic(const Duration(seconds: 1), (t) {
if (!mounted) return t.cancel(); if (!mounted) return t.cancel();
setState(() => _countdown--); 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 { String get _buttonLabel {
if (_readOnly) return S.t('我知道了');
if (_countdown > 0) return S.f('请仔细阅读守则({0}s)', [_countdown]); if (_countdown > 0) return S.f('请仔细阅读守则({0}s)', [_countdown]);
if (!_readToEnd) return S.t('请阅读至守则底部'); if (!_readToEnd) return S.t('请阅读至守则底部');
return S.t('同意并进入'); return S.t('同意并进入');
@@ -59,7 +74,7 @@ class _UserAgreementDialogState extends State<UserAgreementDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return PopScope( return PopScope(
canPop: false, canPop: _readOnly,
child: Dialog( child: Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
insetPadding: const EdgeInsets.symmetric(horizontal: 20), insetPadding: const EdgeInsets.symmetric(horizontal: 20),
@@ -152,8 +167,8 @@ class _UserAgreementDialogState extends State<UserAgreementDialog> {
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
// 同意勾选(倒计时结束且阅读到底后才可勾选) // 同意勾选(倒计时结束且阅读到底后才可勾选);只读模式不显示
GestureDetector( if (!_readOnly) GestureDetector(
onTap: _countdown <= 0 && _readToEnd onTap: _countdown <= 0 && _readToEnd
? () { ? () {
setState(() { setState(() {
@@ -197,7 +212,11 @@ class _UserAgreementDialogState extends State<UserAgreementDialog> {
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: FilledButton( child: FilledButton(
onPressed: _canAgree ? widget.onAgree : null, onPressed: !_canAgree
? null
: (_readOnly
? () => Navigator.of(context).pop()
: widget.onAgree),
style: FilledButton.styleFrom( style: FilledButton.styleFrom(
backgroundColor: const Color(0xFF28A745), backgroundColor: const Color(0xFF28A745),
disabledBackgroundColor: const Color(0xFFCCCCCC), disabledBackgroundColor: const Color(0xFFCCCCCC),
+85
View File
@@ -26,6 +26,9 @@ class _DownloadPageState extends State<DownloadPage> {
static const _mcVersions = ['1.21.4', '1.21.1', '1.20.6', '1.20.4', '1.20.1', '1.19.4', '1.18.2', '1.16.5']; static const _mcVersions = ['1.21.4', '1.21.1', '1.20.6', '1.20.4', '1.20.1', '1.19.4', '1.18.2', '1.16.5'];
static const _loaders = ['fabric', 'forge', 'quilt', 'neoforge', 'paper', 'bukkit', 'spigot']; static const _loaders = ['fabric', 'forge', 'quilt', 'neoforge', 'paper', 'bukkit', 'spigot'];
/// 任务队列视图:false=卡片列表,true=进度条视图。
bool _barView = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@@ -78,6 +81,11 @@ class _DownloadPageState extends State<DownloadPage> {
MaterialPageRoute(builder: (_) => const DownloadSettingsPage()), MaterialPageRoute(builder: (_) => const DownloadSettingsPage()),
), ),
), ),
IconButton(
icon: Icon(_barView ? Icons.view_list_outlined : Icons.equalizer),
tooltip: _barView ? S.t('卡片视图') : S.t('进度条视图'),
onPressed: () => setState(() => _barView = !_barView),
),
], ],
bottom: const TabBar(tabs: [Tab(text: '搜索下载'), Tab(text: '任务队列')]), bottom: const TabBar(tabs: [Tab(text: '搜索下载'), Tab(text: '任务队列')]),
), ),
@@ -235,12 +243,89 @@ class _DownloadPageState extends State<DownloadPage> {
} }
} }
/// 进度条视图:每个任务一条横向进度条 + 百分比。
Widget _buildBarList(DownloadProvider dp, List tasks) {
return ListView.builder(
padding: const EdgeInsets.symmetric(vertical: 8),
itemCount: tasks.length,
itemBuilder: (context, i) {
final t = tasks[i];
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text('${i + 1}. ${t.fileName}',
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyMedium),
),
Text('${(t.progress * 100).toStringAsFixed(0)}%',
style: Theme.of(context).textTheme.bodySmall),
const SizedBox(width: 4),
_statusChip(t.status),
],
),
const SizedBox(height: 6),
LinearProgressIndicator(
value: t.status == DownloadStatus.completed ? 1 : t.progress,
minHeight: 8,
borderRadius: BorderRadius.circular(4),
),
const SizedBox(height: 4),
Row(
children: [
Text(
'${_fmt(t.receivedBytes)} / ${_fmt(t.totalBytes)}'
'${t.status == DownloadStatus.running ? " · ${_fmt(t.speed)}/s" : ""}',
style: Theme.of(context).textTheme.bodySmall,
),
const Spacer(),
if (t.status == DownloadStatus.running)
IconButton(
icon: const Icon(Icons.pause, size: 20),
tooltip: S.t('暂停'),
onPressed: () => dp.manager.pause(t.id),
),
if (t.status == DownloadStatus.paused)
IconButton(
icon: const Icon(Icons.play_arrow, size: 20),
tooltip: S.t('继续'),
onPressed: () => dp.manager.resume(t.id),
),
if (t.status == DownloadStatus.failed)
IconButton(
icon: const Icon(Icons.replay, size: 20),
tooltip: S.t('重试'),
onPressed: () => dp.manager.retry(t.id),
),
IconButton(
icon: const Icon(Icons.close, size: 20),
tooltip: S.t('取消'),
onPressed: () => dp.manager.cancel(t.id),
),
],
),
if (t.error != null)
Text(t.error!,
style: TextStyle(
color: Theme.of(context).colorScheme.error, fontSize: 12)),
],
),
);
},
);
}
Widget _buildQueueTab(DownloadProvider dp) { Widget _buildQueueTab(DownloadProvider dp) {
return AnimatedBuilder( return AnimatedBuilder(
animation: dp.manager, animation: dp.manager,
builder: (context, _) { builder: (context, _) {
final tasks = dp.manager.tasks; final tasks = dp.manager.tasks;
if (tasks.isEmpty) return const Center(child: T('暂无下载任务')); if (tasks.isEmpty) return const Center(child: T('暂无下载任务'));
if (_barView) return _buildBarList(dp, tasks);
return ListView.builder( return ListView.builder(
itemCount: tasks.length, itemCount: tasks.length,
itemBuilder: (context, i) { itemBuilder: (context, i) {
+108
View File
@@ -0,0 +1,108 @@
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
import '../../core/l10n/strings.dart';
import '../../core/utils/update_service.dart';
/// 关于软件页:版本与检查更新 + 开发者信息 + 开源许可。
class AboutPage extends StatefulWidget {
const AboutPage({super.key});
@override
State<AboutPage> createState() => _AboutPageState();
}
class _AboutPageState extends State<AboutPage> {
String _currentVersion = '';
bool _checkingUpdate = false;
@override
void initState() {
super.initState();
_loadVersion();
}
Future<void> _loadVersion() async {
final info = await PackageInfo.fromPlatform();
if (mounted) setState(() => _currentVersion = info.version);
}
Future<void> _checkUpdate() async {
setState(() => _checkingUpdate = true);
try {
final updateInfo = await UpdateService.fetchInfo(userAgent: _currentVersion);
if (!mounted) return;
setState(() => _checkingUpdate = false);
if (updateInfo == null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: T('获取更新信息失败')),
);
return;
}
UpdateService.showUpdateDialog(context, updateInfo, _currentVersion);
} catch (e) {
if (!mounted) return;
setState(() => _checkingUpdate = false);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(S.f('检查更新失败:{0}', [e]))),
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: T('关于软件')),
body: ListView(
children: [
const SizedBox(height: 24),
Column(
children: [
const Icon(Icons.extension, size: 64),
const SizedBox(height: 8),
T('ZV Manager', style: Theme.of(context).textTheme.titleLarge),
Text(S.f('版本 {0}', [_currentVersion]),
style: Theme.of(context).textTheme.bodySmall),
],
),
const SizedBox(height: 16),
const Divider(),
ListTile(
leading: const Icon(Icons.system_update_outlined),
title: T('检查更新'),
trailing: _checkingUpdate
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2))
: const Icon(Icons.chevron_right),
onTap: _checkingUpdate ? null : _checkUpdate,
),
const Divider(),
const ListTile(
leading: Icon(Icons.person_outline),
title: T('创造者'),
subtitle: T('开发者:Z有3笔,协作者:venti1112'),
),
const Divider(),
ListTile(
leading: const Icon(Icons.fact_check_outlined),
title: T('开源许可'),
trailing: const Icon(Icons.chevron_right),
onTap: () => showLicensePage(context: context),
),
const Divider(),
Padding(
padding: const EdgeInsets.all(16),
child: Text(
S.t('ZV Manager 是一款 Minecraft 服务器远程管理工具,本软件与 Mojang、微软无任何隶属关系。'),
style: Theme.of(context).textTheme.bodySmall,
textAlign: TextAlign.center,
),
),
],
),
);
}
}
+21 -54
View File
@@ -1,18 +1,18 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'dart:io'; import 'dart:io';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import '../../core/theme/app_theme.dart'; import '../../core/theme/app_theme.dart';
import '../../core/utils/update_service.dart';
import '../../core/utils/background_service.dart'; import '../../core/utils/background_service.dart';
import '../../core/widgets/background_widget.dart'; import '../../core/widgets/background_widget.dart';
import '../../providers/theme_provider.dart'; import '../../providers/theme_provider.dart';
import '../../providers/wallpaper_provider.dart'; import '../../providers/wallpaper_provider.dart';
import 'help_page.dart'; import 'help_page.dart';
import 'server_log_page.dart'; import 'server_log_page.dart';
import 'about_page.dart';
import '../../core/widgets/user_agreement_dialog.dart';
import 'download_settings_page.dart'; import 'download_settings_page.dart';
import '../../providers/language_provider.dart'; import '../../providers/language_provider.dart';
import '../../core/l10n/strings.dart'; import '../../core/l10n/strings.dart';
@@ -24,8 +24,6 @@ class SettingsPage extends StatefulWidget {
} }
class _SettingsPageState extends State<SettingsPage> { class _SettingsPageState extends State<SettingsPage> {
String _currentVersion = '';
bool _checkingUpdate = false;
String? _currentBgType; String? _currentBgType;
String? _currentBgPath; String? _currentBgPath;
bool _videoSoundEnabled = false; bool _videoSoundEnabled = false;
@@ -33,16 +31,10 @@ class _SettingsPageState extends State<SettingsPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_loadVersion();
_loadCurrentBg(); _loadCurrentBg();
_loadVideoSound(); _loadVideoSound();
} }
Future<void> _loadVersion() async {
final info = await PackageInfo.fromPlatform();
if (mounted) setState(() => _currentVersion = info.version);
}
Future<void> _loadCurrentBg() async { Future<void> _loadCurrentBg() async {
final data = await BackgroundService.getBackground(); final data = await BackgroundService.getBackground();
if (mounted) { if (mounted) {
@@ -58,30 +50,6 @@ class _SettingsPageState extends State<SettingsPage> {
if (mounted) setState(() => _videoSoundEnabled = enabled); if (mounted) setState(() => _videoSoundEnabled = enabled);
} }
Future<void> _checkUpdate() async {
setState(() => _checkingUpdate = true);
try {
final updateInfo = await UpdateService.fetchInfo(userAgent: _currentVersion);
if (!mounted) return;
setState(() => _checkingUpdate = false);
if (updateInfo == null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: T('获取更新信息失败')),
);
return;
}
UpdateService.showUpdateDialog(context, updateInfo, _currentVersion);
} catch (e) {
if (!mounted) return;
setState(() => _checkingUpdate = false);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(S.f('检查更新失败:{0}', [e]))),
);
}
}
// ==================== 背景相关方法 ==================== // ==================== 背景相关方法 ====================
void _showBackgroundPicker() { void _showBackgroundPicker() {
@@ -358,31 +326,30 @@ class _SettingsPageState extends State<SettingsPage> {
), ),
const Divider(), const Divider(),
// ---------- 检查更新 ---------- // ---------- 用户须知 ----------
ListTile( ListTile(
leading: const Icon(Icons.system_update_outlined), leading: const Icon(Icons.gavel_outlined),
title: T('检查更新'), title: T('用户须知'),
subtitle: Text(S.f('当前版本: {0}', [_currentVersion])), subtitle: T('查看用户守则全部条款'),
trailing: _checkingUpdate trailing: const Icon(Icons.chevron_right),
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2)) onTap: () => showDialog(
: const Icon(Icons.chevron_right), context: context,
onTap: _checkingUpdate ? null : _checkUpdate, barrierDismissible: true,
builder: (_) => UserAgreementDialog.readView(),
),
), ),
const Divider(), const Divider(),
// ---------- 关于 ---------- // ---------- 关于软件(检查更新 + 创造者 + 开源许可) ----------
const ListTile(
leading: Icon(Icons.info_outline),
title: T('关于'),
subtitle: T('开发者:Z有3笔,协作者:venti1112'),
),
const Divider(),
// ---------- 开源许可 ----------
ListTile( ListTile(
leading: const Icon(Icons.fact_check_outlined), leading: const Icon(Icons.info_outline),
title: T('开源许可'), title: T('关于软件'),
onTap: () => showLicensePage(context: context), subtitle: T('版本、检查更新、创造者与开源许可'),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
MaterialPageRoute(builder: (_) => const AboutPage()),
),
), ),
], ],
), ),