import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

class VoiceAnimation extends StatelessWidget {
  /// 是否正在播放
  final bool isPlaying;

  /// Lottie 动画资源路径
  final String animationAsset;

  ///  静态图标
  final IconData idleIcon;

  /// 动画和图标的大小
  final double size;

  const VoiceAnimation({
    super.key,
    required this.isPlaying,
    this.animationAsset = 'assets/animation/voice.json',
    this.idleIcon = Icons.multitrack_audio, // 静态图标
    this.size = 24.0,
  });

  @override
  Widget build(BuildContext context) {
    if (isPlaying) {
      return Lottie.asset(
        animationAsset,
        width: size,
        height: size,
        repeat: true,
      );
    } else {
      return Icon(
        idleIcon,
        size: size,
      );
    }
  }
}
