import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

import 'package:pshared/provider/recipient/pmethods.dart';
import 'package:pshared/models/payment/wallet.dart';

import 'package:pweb/pages/payment_methods/manage/widget.dart';
import 'package:pweb/pages/payout_page/wallet/widget.dart';

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


class PaymentConfigPage extends StatelessWidget {
  final Function(Wallet) onWalletTap;

  const PaymentConfigPage({super.key, required this.onWalletTap});

  @override
  Widget build(BuildContext context) {
    final provider = context.watch<PaymentMethodsProvider>();
    final loc = AppLocalizations.of(context)!;

    if (provider.isLoading) {
      return const Center(child: CircularProgressIndicator());
    }

    if (provider.error != null) {
      return Center(child: Text(loc.notificationError(provider.error ?? loc.noErrorInformation)));
    }

    return Column(
      children: [
        MethodsWidget(),
        Expanded(
          child: WalletWidgets(onWalletTap: onWalletTap),
        ),
      ],
    );
  }
}
