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

class UnreadCountView extends StatelessWidget {
  const UnreadCountView({
    Key? key,
    this.count = 0,
    this.size = 18,
    this.margin,
  }) : super(key: key);
  final int count;
  final double size;
  final EdgeInsetsGeometry? margin;

  @override
  Widget build(BuildContext context) {
    return Visibility(
      visible: count > 0,
      child: Container(
        alignment: Alignment.center,
        margin: margin,
        padding: count > 99 ? const EdgeInsets.symmetric(horizontal: 4) : null,
        constraints: BoxConstraints(
          minWidth: size,
          minHeight: size,
          maxHeight: size,
        ),
        decoration: BoxDecoration(
          color: Styles.c_FF381F,
          borderRadius: BorderRadius.circular(9),
        ),
        child: Text(
          '${count > 99 ? '99+' : count}',
          style: const TextStyle(
            fontSize: 12,
            color: Color(0xFFFFFFFF),
          ),
          textAlign: TextAlign.center,
        ),
      ),
    );
  }
}
