2025-09-10 17:33:26 +08:00
|
|
|
|
import 'package:ai_chat_assistant/utils/assets_util.dart';
|
2025-08-12 17:40:39 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'mini_audio_wave.dart';
|
|
|
|
|
|
|
|
|
|
|
|
/// 浮动图标与声波动画组合组件
|
|
|
|
|
|
///
|
|
|
|
|
|
/// 将ai_hd_clean.png图片和AudioWaveLargeMini声波效果组合成一个独立组件
|
|
|
|
|
|
class FloatingIconWithWave extends StatelessWidget {
|
|
|
|
|
|
/// 动画控制器,用于驱动声波动画
|
|
|
|
|
|
final AnimationController animationController;
|
|
|
|
|
|
|
|
|
|
|
|
/// 图标大小
|
|
|
|
|
|
final double iconSize;
|
|
|
|
|
|
|
|
|
|
|
|
/// 声波颜色,默认为白色
|
|
|
|
|
|
final Color waveColor;
|
|
|
|
|
|
|
|
|
|
|
|
/// 构造函数
|
|
|
|
|
|
const FloatingIconWithWave({
|
|
|
|
|
|
super.key,
|
|
|
|
|
|
required this.animationController,
|
|
|
|
|
|
required this.iconSize,
|
|
|
|
|
|
this.waveColor = Colors.white,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return SizedBox(
|
|
|
|
|
|
width: iconSize,
|
|
|
|
|
|
height: iconSize,
|
|
|
|
|
|
child: Stack(
|
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
// 背景图片
|
2025-09-19 11:40:38 +08:00
|
|
|
|
AssetsUtil.getImageWidget(
|
|
|
|
|
|
'ai_hd_clean.png',
|
2025-08-12 17:40:39 +08:00
|
|
|
|
width: iconSize,
|
|
|
|
|
|
height: iconSize,
|
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
|
),
|
|
|
|
|
|
// 声波动画,距离底部13px的位置
|
|
|
|
|
|
Positioned(
|
|
|
|
|
|
bottom: 13 * (iconSize / 198), // 按比例计算距离底部的位置
|
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
|
width: 96 * (iconSize / 144), // 最宽不超过96px(按图片原始宽度比例)
|
|
|
|
|
|
height: 27 * (iconSize / 198), // 最高不超过27px(按图片原始高度比例)
|
|
|
|
|
|
child: AudioWaveLargeMini(
|
|
|
|
|
|
animationController: animationController,
|
|
|
|
|
|
waveColor: waveColor,
|
|
|
|
|
|
barSpacing: 2.5, // 减小间距以适应更小的宽度
|
|
|
|
|
|
minHeightRatio: 0.4, // 调整最小高度比例
|
|
|
|
|
|
maxHeightRatio: 1.0, // 保持最大高度比例
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|