import 'package:flutter/material.dart';
import 'package:flyinsono/lab/color/lab_colors.dart';

class ShowMoreIcon extends StatefulWidget {
  const ShowMoreIcon({
    super.key,
    required this.isLeft,
    required this.onTap,
  });

  final bool isLeft;
  final VoidCallback onTap;

  @override
  State<ShowMoreIcon> createState() => _ShowMoreIconState();
}

class _ShowMoreIconState extends State<ShowMoreIcon> {
  bool _isHover = false;

  @override
  Widget build(BuildContext context) {
    Color backgroundColor = _isHover ? LabColors.base700 : LabColors.base600;
    return MouseRegion(
      cursor: SystemMouseCursors.click,
      onEnter: (_) {
        setState(() {
          _isHover = true;
        });
      },
      onExit: (_) {
        setState(() {
          _isHover = false;
        });
      },
      child: GestureDetector(
          onTap: widget.onTap,
          child: Container(
            width: 20,
            margin: EdgeInsets.symmetric(vertical: 5),
            decoration: BoxDecoration(
              color: backgroundColor,
              borderRadius: BorderRadius.circular(3),
            ),
            child: Center(
              child: Icon(
                widget.isLeft
                    ? Icons.keyboard_double_arrow_left
                    : Icons.keyboard_double_arrow_right,
                color: LabColors.base300,
                size: 20,
              ),
            ),
          )),
    );
  }

  // 备用样式
  final style1 = BoxDecoration(
    // 左右渐变
    gradient: LinearGradient(
      begin: Alignment.centerRight,
      end: Alignment.centerLeft,
      colors: [
        LabColors.base900,
        LabColors.base800.withOpacity(0.1),
      ],
    ),
  );
}
