mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 12:53: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,
|
||||
|
||||
Reference in new issue
Block a user