// Author: fengshengxiong
// Date: 2024/6/5
// Description: 跑马灯

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:tone_snap/res/themes/app_colors.dart';
import 'package:tone_snap/utils/obj_util.dart';
import 'package:widget_marquee/widget_marquee.dart';

class MusicItemMarqueeText extends StatelessWidget {
  const MusicItemMarqueeText({
    super.key,
    required this.text,
    this.isTitle = true,
    this.showMarquee = false,
  });

  final String? text;
  final bool isTitle;
  final bool showMarquee;

  @override
  Widget build(BuildContext context) {
    return Visibility(
      visible: showMarquee,
      replacement: Text(
        ObjUtil.getStr(text),
        maxLines: 1,
        overflow: TextOverflow.ellipsis,
        style: TextStyle(
          color: isTitle ? Colors.white : const Color(0x99FFFFFF),
          fontSize: isTitle ? 14.sp : 12.sp,
        ),
      ),
      child: Marquee(
        delay: Duration.zero,
        duration: const Duration(seconds: 40),
        pause: Duration.zero,
        gap: 80,
        child: Text(
          ObjUtil.getStr(text),
          style: TextStyle(
            color: seedColor,
            fontSize: isTitle ? 14.sp : 12.sp,
          ),
        ),
      ),
    );
  }
}
