import 'dart:async';

import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';

class BreathingLightWithoutAnimate extends FStatefulWidget {
  final double size;

  const BreathingLightWithoutAnimate({super.key, required this.size});

  @override
  FState<BreathingLightWithoutAnimate> createState() => _LightState();
}

class _LightState extends FState<BreathingLightWithoutAnimate> {
  static final _fullColor = Colors.green;
  static final _thinColor = _fullColor.withOpacity(.1);
  late Timer _timer;
  bool isShow = true;

  @override
  void initState() {
    _timer = Timer.periodic(const Duration(milliseconds: 800), (timer) {
      setState(() {
        isShow = !isShow;
      });
    });
    super.initState();
  }

  @override
  void dispose() {
    _timer.cancel();
    super.dispose();
  }

  @override
  FWidget build(BuildContext context) {
    return FContainer(
      width: widget.size,
      height: widget.size,
      decoration: BoxDecoration(
        color: isShow ? _fullColor : _thinColor,
        shape: BoxShape.circle,
      ),
    );
  }
}
