import 'package:flutter/material.dart';

import 'package:pshared/models/currency.dart';
import 'package:pshared/models/payment/chain_network.dart';
import 'package:pshared/utils/currency.dart';
import 'package:pshared/utils/l10n/chain.dart';

import 'package:pweb/pages/dashboard/buttons/balance/add/constants.dart';
import 'package:pweb/utils/text_field_styles.dart';

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


class ManagedWalletFields extends StatelessWidget {
  final CurrencyCode currency;
  final ChainNetwork network;
  final ValueChanged<CurrencyCode?>? onCurrencyChanged;
  final ValueChanged<ChainNetwork?>? onNetworkChanged;

  const ManagedWalletFields({
    super.key,
    required this.currency,
    required this.network,
    required this.onCurrencyChanged,
    required this.onNetworkChanged,
  });

  @override
  Widget build(BuildContext context) {
    final l10n = AppLocalizations.of(context)!;
    return Column(
      spacing: 12,
      children: [
        DropdownButtonFormField<CurrencyCode>(
          initialValue: currency,
          decoration: getInputDecoration(context, l10n.currency, true),
          items: [
            DropdownMenuItem(
              value: managedCurrencyDefault,
              child: Text(currencyCodeToString(managedCurrencyDefault)),
            ),
          ],
          onChanged: onCurrencyChanged,
        ),
        DropdownButtonFormField<ChainNetwork>(
          initialValue: network,
          decoration: getInputDecoration(context, l10n.walletTopUpNetworkLabel, true),
          items: [
            DropdownMenuItem(
              value: managedNetworkDefault,
              child: Text(managedNetworkDefault.localizedName(context)),
            ),
          ],
          onChanged: onNetworkChanged,
        ),
      ],
    );
  }
}
