import 'package:flutter/material.dart';

import 'package:dotted_border/dotted_border.dart';

import 'package:pweb/pages/dashboard/buttons/balance/add/dialog.dart';
import 'package:pweb/pages/dashboard/buttons/balance/config.dart';

import 'package:pweb/generated/i18n/app_localizations.dart';


class AddBalanceCard extends StatelessWidget {
  final VoidCallback? onTap;

  const AddBalanceCard({super.key, this.onTap});

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final colorScheme = theme.colorScheme;
    final textTheme = theme.textTheme;
    final loc = AppLocalizations.of(context)!;

    final borderRadius = BorderRadius.circular(WalletCardConfig.borderRadius);

    final subtitle = '${loc.paymentTypeLedger} / ${loc.paymentTypeManagedWallet}';
    final effectiveOnTap = onTap ?? () => showAddBalanceDialog(context);

    return ClipRRect(
      borderRadius: borderRadius,
      child: DottedBorder(
        options: RoundedRectDottedBorderOptions(
          radius: Radius.circular(WalletCardConfig.borderRadius),
          dashPattern: const [8, 5],
          strokeWidth: 1.6,
          color: colorScheme.primary.withAlpha(110),
        ),
        child: Material(
          color: colorScheme.primary.withAlpha(14),
          child: InkWell(
            onTap: effectiveOnTap,
            child: SizedBox.expand(
              child: Padding(
                padding: WalletCardConfig.contentPadding,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Container(
                      width: 48,
                      height: 48,
                      decoration: BoxDecoration(
                        shape: BoxShape.circle,
                        color: colorScheme.primary.withAlpha(28),
                      ),
                      child: Icon(
                        Icons.add_rounded,
                        size: 28,
                        color: colorScheme.primary,
                      ),
                    ),
                    const SizedBox(height: 8),
                    Text(
                      loc.actionAddNew,
                      style: textTheme.titleMedium?.copyWith(
                        fontWeight: FontWeight.w700,
                      ),
                    ),
                    const SizedBox(height: 4),
                    Text(
                      subtitle,
                      textAlign: TextAlign.center,
                      style: textTheme.bodySmall?.copyWith(
                        color: colorScheme.onSurfaceVariant,
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
