import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

import 'package:pshared/controllers/payment/source.dart';
import 'package:pshared/provider/payment/amount.dart';

import 'package:pweb/controllers/payments/amount_field.dart';
import 'package:pweb/pages/dashboard/payouts/amount/field.dart';


class PaymentAmountWidget extends StatelessWidget {
  const PaymentAmountWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProxyProvider2<
      PaymentAmountProvider,
      PaymentSourceController,
      PaymentAmountFieldController
    >(
      create: (ctx) {
        final initialAmount = ctx.read<PaymentAmountProvider>().amount;
        return PaymentAmountFieldController(initialAmount: initialAmount);
      },
      update: (ctx, amountProvider, source, controller) {
        controller!.update(amountProvider, source);
        return controller;
      },
      child: const PaymentAmountField(),
    );
  }
}
