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

import '../../config/theme/dark_theme_colors.dart';
import '../constants/iconfont/iconfont.dart';

class InfiniteRotateIcon extends StatefulWidget {
  const InfiniteRotateIcon({super.key});

  @override
  State<InfiniteRotateIcon> createState() => _InfiniteRotateIconState();
}

class _InfiniteRotateIconState extends State<InfiniteRotateIcon>
    with SingleTickerProviderStateMixin {
  late final AnimationController _controller;

  @override
  void initState() {
    super.initState();

    // 创建动画控制器
    _controller = AnimationController(
      vsync: this,
      duration: const Duration(seconds: 2), // 转一圈的时长
    )..repeat(); // 无限循环
  }

  @override
  void dispose() {
    _controller.dispose(); // 防止内存泄漏
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: RotationTransition(
        turns: _controller, // 控制旋转角度（0~1）
        child: Icon(
          IconFont.icon20, // 可换成任意图标或图片
          size: 20.w,
          color: DarkThemeColors.subscriptionSelectColor,
        ),
      ),
    );
  }
}
