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

/// 通用 Shimmer 包装器，与首页保持一致的 baseColor / highlightColor
class AppShimmer extends StatelessWidget {
  const AppShimmer({super.key, required this.child});
  final Widget child;

  @override
  Widget build(BuildContext context) {
    final cs = Theme.of(context).colorScheme;
    return Shimmer.fromColors(
      baseColor: cs.onSurface.withAlpha(15),
      highlightColor: cs.onSurface.withAlpha(30),
      child: child,
    );
  }
}

/// 圆角矩形占位块
Widget shimmerBox(double width, double height, {double radius = 4}) {
  return Container(
    width: width,
    height: height,
    decoration: BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadius.circular(radius),
    ),
  );
}

/// 圆形占位块
Widget shimmerCircle(double size) {
  return Container(
    width: size,
    height: size,
    decoration: const BoxDecoration(
      color: Colors.white,
      shape: BoxShape.circle,
    ),
  );
}

/// 通用"填满宽度"占位块（width = double.infinity）
Widget shimmerFill(double height, {double radius = 4, EdgeInsets? margin}) {
  return Container(
    margin: margin,
    height: height,
    decoration: BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadius.circular(radius),
    ),
  );
}
