import 'package:flutter/material.dart';

class ToggleColorContainer extends StatelessWidget {
  final Color initialColor;
  final Color toggledColor;
  final EdgeInsetsGeometry padding;
  final Widget child;
  final double borderRadius;
  final VoidCallback onToggle;
  final bool toggled; // 新增，外部传入是否高亮

  const ToggleColorContainer({
    Key? key,
    required this.initialColor,
    required this.toggledColor,
    required this.padding,
    required this.child,
    required this.onToggle,
    required this.toggled,
    this.borderRadius = 0,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final Color currentColor = toggled ? toggledColor : initialColor;

    return Material(
      color: Colors.transparent,
      child: Ink(
        decoration: BoxDecoration(
          color: currentColor,
          borderRadius: BorderRadius.circular(borderRadius),
        ),
        child: InkWell(
          borderRadius: BorderRadius.circular(borderRadius),
          onTap: onToggle,
          splashColor: Colors.transparent,
          highlightColor: Colors.transparent,
          child: Padding(
            padding: padding,
            child: child,
          ),
        ),
      ),
    );
  }
}
