mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-16 13:23:41 +00:00
temp
This commit is contained in:
1 parent
8835c2855a
commit
5303e44ead
17 files changed
+293
-51
No files matched your search
@@ -1,11 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
/// GpIconButton - 简单的图标按钮组件
|
||||
///
|
||||
/// 用于TaskItem的操作按钮,支持鼠标悬浮效果
|
||||
class GpIconButton extends StatefulWidget {
|
||||
/// 图标
|
||||
final IconData icon;
|
||||
/// 图标(支持 IconData 或 String 路径)
|
||||
final dynamic icon;
|
||||
|
||||
/// 点击回调
|
||||
final VoidCallback? onTap;
|
||||
@@ -53,13 +54,57 @@ class _GpIconButtonState extends State<GpIconButton> {
|
||||
? const Color(0xFF4883A2)
|
||||
: Colors.transparent, // 悬浮背景色
|
||||
),
|
||||
child: Icon(
|
||||
widget.icon,
|
||||
color: widget.color ?? Colors.white,
|
||||
size: widget.size ?? 20.0,
|
||||
),
|
||||
child: _buildIcon(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIcon() {
|
||||
// 如果是字符串,认为是资源路径
|
||||
if (widget.icon is String) {
|
||||
final String path = widget.icon as String;
|
||||
// 支持 svg 资源
|
||||
if (path.toLowerCase().endsWith('.svg')) {
|
||||
return Center(
|
||||
child: SvgPicture.asset(
|
||||
path,
|
||||
width: widget.size ?? 20.0,
|
||||
height: widget.size ?? 20.0,
|
||||
fit: BoxFit.contain,
|
||||
colorFilter: ColorFilter.mode(
|
||||
widget.color ?? Colors.white,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Center(
|
||||
child: Image.asset(
|
||||
path,
|
||||
width: widget.size ?? 20.0,
|
||||
height: widget.size ?? 20.0,
|
||||
color: widget.color,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 如果是IconData,使用Icon组件
|
||||
if (widget.icon is IconData) {
|
||||
return Icon(
|
||||
widget.icon as IconData,
|
||||
color: widget.color ?? Colors.white,
|
||||
size: widget.size ?? 20.0,
|
||||
);
|
||||
}
|
||||
|
||||
// 如果是Widget,直接使用
|
||||
if (widget.icon is Widget) {
|
||||
return Center(child: widget.icon as Widget);
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
/// GpOutlineButton - 线框按钮组件
|
||||
///
|
||||
@@ -74,9 +75,26 @@ class GpOutlineButton extends StatelessWidget {
|
||||
|
||||
// 如果是字符串,认为是资源路径
|
||||
if (icon is String) {
|
||||
final String path = icon as String;
|
||||
// 支持 svg 资源
|
||||
if (path.toLowerCase().endsWith('.svg')) {
|
||||
return Center(
|
||||
child: SvgPicture.asset(
|
||||
path,
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
fit: BoxFit.contain,
|
||||
colorFilter:
|
||||
iconColor != null
|
||||
? ColorFilter.mode(iconColor!, BlendMode.srcIn)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Center(
|
||||
child: Image.asset(
|
||||
icon as String,
|
||||
path,
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
color: iconColor,
|
||||
|
||||
@@ -60,21 +60,21 @@ class _TaskScreenState extends State<TaskScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
GpOutlineButton(
|
||||
icon: 'assets/icons/pause.png',
|
||||
icon: 'assets/icons/resume.svg',
|
||||
onTap: () {
|
||||
// 处理开始按钮点击事件
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
GpOutlineButton(
|
||||
icon: 'assets/icons/pause.png',
|
||||
icon: 'assets/icons/pause.svg',
|
||||
onTap: () {
|
||||
// 处理暂停按钮点击事件
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
GpOutlineButton(
|
||||
icon: 'assets/icons/pause.png',
|
||||
icon: 'assets/icons/delete.svg',
|
||||
onTap: () {
|
||||
// 处理删除按钮点击事件
|
||||
},
|
||||
@@ -109,23 +109,23 @@ class _TaskScreenState extends State<TaskScreen> {
|
||||
bottomRightStatusText: '下载中', // 状态文本
|
||||
actionButtons: [
|
||||
GpIconButton(
|
||||
icon: Icons.pause,
|
||||
icon: 'assets/icons/item_pause.svg',
|
||||
onTap: () => print('暂停任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.delete,
|
||||
icon: 'assets/icons/item_delete.svg',
|
||||
onTap: () => print('删除任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.folder_open,
|
||||
onTap: () => print('打开所在位置 $index'),
|
||||
icon: 'assets/icons/item_reveal.svg',
|
||||
onTap: () => print('打开所在·位置 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.info,
|
||||
icon: 'assets/icons/item_info.svg',
|
||||
onTap: () => print('查看信息 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.more_vert,
|
||||
icon: 'assets/icons/item_more.svg',
|
||||
onTap: () => print('更多操作 $index'),
|
||||
),
|
||||
],
|
||||
@@ -149,23 +149,23 @@ class _TaskScreenState extends State<TaskScreen> {
|
||||
bottomRightStatusText: '已完成', // 状态文本
|
||||
actionButtons: [
|
||||
GpIconButton(
|
||||
icon: Icons.pause,
|
||||
onTap: () => print('暂停任务 $index'),
|
||||
icon: 'assets/icons/item_resume.svg',
|
||||
onTap: () => print('重新下载任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.delete,
|
||||
icon: 'assets/icons/item_delete.svg',
|
||||
onTap: () => print('删除任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.folder_open,
|
||||
icon: 'assets/icons/item_reveal.svg',
|
||||
onTap: () => print('打开所在位置 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.info,
|
||||
icon: 'assets/icons/item_info.svg',
|
||||
onTap: () => print('查看信息 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.more_vert,
|
||||
icon: 'assets/icons/item_more.svg',
|
||||
onTap: () => print('更多操作 $index'),
|
||||
),
|
||||
],
|
||||
@@ -189,23 +189,23 @@ class _TaskScreenState extends State<TaskScreen> {
|
||||
bottomRightStatusText: '失败', // 状态文本
|
||||
actionButtons: [
|
||||
GpIconButton(
|
||||
icon: Icons.pause,
|
||||
onTap: () => print('暂停任务 $index'),
|
||||
icon: 'assets/icons/item_resume.svg',
|
||||
onTap: () => print('重试任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.delete,
|
||||
icon: 'assets/icons/item_delete.svg',
|
||||
onTap: () => print('删除任务 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.folder_open,
|
||||
icon: 'assets/icons/item_reveal.svg',
|
||||
onTap: () => print('打开所在位置 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.info,
|
||||
icon: 'assets/icons/item_info.svg',
|
||||
onTap: () => print('查看信息 $index'),
|
||||
),
|
||||
GpIconButton(
|
||||
icon: Icons.more_vert,
|
||||
icon: 'assets/icons/item_more.svg',
|
||||
onTap: () => print('更多操作 $index'),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user