mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-14 12:23:43 +00:00
temp
This commit is contained in:
1 parent
2ab5a4bb53
commit
8835c2855a
11 files changed
+851
-47
No files matched your search
@@ -1,60 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GradientButton extends StatelessWidget {
|
||||
final String text;
|
||||
final VoidCallback onPressed;
|
||||
final IconData? icon; // 添加可选图标参数
|
||||
|
||||
const GradientButton({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.onPressed,
|
||||
this.icon,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 120,
|
||||
height: 40,
|
||||
child: ElevatedButton(
|
||||
onPressed: onPressed,
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(143),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
child: Ink(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Color(0xFF3ACBBE), Color(0xFF2CDB90)],
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
),
|
||||
borderRadius: BorderRadius.all(Radius.circular(143)),
|
||||
),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (icon != null) Icon(icon, size: 16.0, color: Colors.white),
|
||||
if (icon != null) const SizedBox(width: 4.0), // 图标和文本之间的间距
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFFFFFFFE),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'gradient_button.dart';
|
||||
import '../../../components/gp_gradient_button.dart';
|
||||
import '../../../components/gp_outline_button.dart';
|
||||
import '../../../components/gp_icon_button.dart';
|
||||
import '../widgets/task_item.dart';
|
||||
import 'task_tabs.dart';
|
||||
|
||||
class TaskScreen extends StatefulWidget {
|
||||
@@ -32,7 +35,7 @@ class _TaskScreenState extends State<TaskScreen> {
|
||||
padding: const EdgeInsets.only(left: 16.0, top: 16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
GradientButton(
|
||||
GpGradientButton(
|
||||
text: '创建任务',
|
||||
icon: Icons.add, // 添加加号图标
|
||||
onPressed: () {
|
||||
@@ -49,7 +52,37 @@ class _TaskScreenState extends State<TaskScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(height: 16),
|
||||
// 操作按钮列表
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 24.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
GpOutlineButton(
|
||||
icon: 'assets/icons/pause.png',
|
||||
onTap: () {
|
||||
// 处理开始按钮点击事件
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
GpOutlineButton(
|
||||
icon: 'assets/icons/pause.png',
|
||||
onTap: () {
|
||||
// 处理暂停按钮点击事件
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
GpOutlineButton(
|
||||
icon: 'assets/icons/pause.png',
|
||||
onTap: () {
|
||||
// 处理删除按钮点击事件
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Expanded(child: _buildTaskList(_selectedTabIndex)),
|
||||
],
|
||||
),
|
||||
@@ -60,16 +93,126 @@ class _TaskScreenState extends State<TaskScreen> {
|
||||
// 根据选中的标签页显示不同的任务列表
|
||||
switch (tabIndex) {
|
||||
case 0:
|
||||
return const Center(
|
||||
child: Text('下载中的任务列表', style: TextStyle(color: Colors.white)),
|
||||
return ListView.separated(
|
||||
itemCount: 3, // 示例显示3个任务项
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||
itemBuilder:
|
||||
(context, index) => TaskItem(
|
||||
icon: Icons.download, // 添加下载图标
|
||||
taskName: '下载任务 ${index + 1}', // 添加任务名称
|
||||
progress: (index + 1) * 0.25, // 添加进度值 (0.25, 0.5, 0.75)
|
||||
fileSizeText:
|
||||
'${(2.1 + index * 0.1).toStringAsFixed(1)}MB/2.4MB', // 示例文件大小
|
||||
bottomRightIcon: Icons.speed, // 添加速度图标
|
||||
bottomRightGradientText:
|
||||
'${(1.5 + index * 0.3).toStringAsFixed(1)}MB/s', // 下载速度
|
||||
bottomRightStatusText: '下载中', // 状态文本
|
||||
actionButtons: [
|
||||
GpIconButton(
|
||||
icon: Icons.pause,
|
||||
onTap: () => print('暂停任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.delete,
|
||||
onTap: () => print('删除任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.folder_open,
|
||||
onTap: () => print('打开所在位置 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.info,
|
||||
onTap: () => print('查看信息 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.more_vert,
|
||||
onTap: () => print('更多操作 $index'),
|
||||
),
|
||||
],
|
||||
onTap: () {
|
||||
print('任务项 $index 被点击');
|
||||
},
|
||||
),
|
||||
);
|
||||
case 1:
|
||||
return const Center(
|
||||
child: Text('已完成的任务列表', style: TextStyle(color: Colors.white)),
|
||||
return ListView.separated(
|
||||
itemCount: 2, // 示例显示2个任务项
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||
itemBuilder:
|
||||
(context, index) => TaskItem(
|
||||
icon: Icons.check_circle, // 添加完成图标
|
||||
taskName: '已完成任务 ${index + 1}', // 添加任务名称
|
||||
progress: 1.0, // 已完成任务进度为100%
|
||||
fileSizeText: '2.4MB/2.4MB - 已完成', // 添加完成信息
|
||||
bottomRightIcon: Icons.check, // 添加完成图标
|
||||
bottomRightGradientText: '完成时间', // 完成时间文本
|
||||
bottomRightStatusText: '已完成', // 状态文本
|
||||
actionButtons: [
|
||||
GpIconButton(
|
||||
icon: Icons.pause,
|
||||
onTap: () => print('暂停任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.delete,
|
||||
onTap: () => print('删除任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.folder_open,
|
||||
onTap: () => print('打开所在位置 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.info,
|
||||
onTap: () => print('查看信息 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.more_vert,
|
||||
onTap: () => print('更多操作 $index'),
|
||||
),
|
||||
],
|
||||
onTap: () {
|
||||
print('已完成任务项 $index 被点击');
|
||||
},
|
||||
),
|
||||
);
|
||||
case 2:
|
||||
return const Center(
|
||||
child: Text('失败的任务列表', style: TextStyle(color: Colors.white)),
|
||||
return ListView.separated(
|
||||
itemCount: 1, // 示例显示1个任务项
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||
itemBuilder:
|
||||
(context, index) => TaskItem(
|
||||
icon: Icons.error, // 添加错误图标
|
||||
taskName: '失败任务 ${index + 1}', // 添加任务名称
|
||||
progress: 0.3, // 失败任务的部分进度
|
||||
fileSizeText: '1.2MB/4.0MB - 任务失败', // 添加失败信息
|
||||
bottomRightIcon: Icons.error_outline, // 添加错误图标
|
||||
bottomRightGradientText: '重试', // 重试文本
|
||||
bottomRightStatusText: '失败', // 状态文本
|
||||
actionButtons: [
|
||||
GpIconButton(
|
||||
icon: Icons.pause,
|
||||
onTap: () => print('暂停任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.delete,
|
||||
onTap: () => print('删除任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.folder_open,
|
||||
onTap: () => print('打开所在位置 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.info,
|
||||
onTap: () => print('查看信息 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.more_vert,
|
||||
onTap: () => print('更多操作 $index'),
|
||||
),
|
||||
],
|
||||
onTap: () {
|
||||
print('失败任务项 $index 被点击');
|
||||
},
|
||||
),
|
||||
);
|
||||
default:
|
||||
return Container();
|
||||
|
||||
Reference in new issue
Block a user