import 'package:app/global/theme/base/app_theme_ext.dart';
import 'package:flutter/material.dart';

import '../config/color.dart';
import '../config/config.dart';


class Tag extends StatelessWidget {
  final String text;
  final Color? color;
  final ThemeType type;
  final Effect effect;
  final EdgeInsets padding;

  const Tag({
    super.key,
    required this.text,
    this.color,
    this.type = ThemeType.primary,
    this.effect = Effect.dark,
    this.padding = const EdgeInsets.symmetric(vertical: 3, horizontal: 6),
  });

  @override
  Widget build(BuildContext context) {
    ///颜色
    var baseColor = switch (type) {
      ThemeType.primary => Theme.of(context).primaryColor,
      ThemeType.success => context.success,
      ThemeType.warning => context.warning,
      ThemeType.danger => context.danger,
      ThemeType.info => context.info,
    };
    if (color != null) {
      baseColor = color!;
    }

    ColorResolver colorResolver = resolveEffectColors(baseColor, effect);

    return Container(
      padding: padding,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(5),
        color: colorResolver.bg,
        border: Border.all(
          color: colorResolver.border,
          width: 1,
        ),
      ),
      child: Text(
        text,
        style: TextStyle(
          color: colorResolver.font,
          fontSize: 12,
        ),
      ),
    );
  }
}
