
import 'package:flutter/material.dart';

import 'package:pweb/models/wallet/wallet_transaction.dart';


class TypeChip extends StatelessWidget {
  final WalletTransactionType type;

  const TypeChip({super.key, required this.type});

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final isTopUp = type == WalletTransactionType.topUp;
    final bg = isTopUp
        ? theme.colorScheme.secondaryContainer
        : theme.colorScheme.errorContainer;

    final fg = bg.computeLuminance() > 0.5 ? Colors.black : Colors.white;

    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
      decoration: BoxDecoration(
        color: bg,
        borderRadius: BorderRadius.circular(12),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Icon(
            isTopUp ? Icons.arrow_downward_rounded : Icons.arrow_upward_rounded,
            size: 16,
            color: fg,
          ),
          const SizedBox(width: 6),
          Text(
            type.label(context),
            style: TextStyle(
              color: fg,
              fontWeight: FontWeight.w600,
            ),
          ),
        ],
      ),
    );
  }
}
