import 'package:flutter/material.dart';

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

import 'package:pweb/pages/payout_page/send/content/back_section.dart';
import 'package:pweb/pages/payout_page/send/content/recipient_section.dart';
import 'package:pweb/pages/payout_page/send/content/send_section.dart';
import 'package:pweb/pages/payout_page/send/content/source_section.dart';
import 'package:pweb/utils/dimensions.dart';
import 'package:pweb/widgets/sidebar/destinations.dart';
import 'package:pweb/models/state/control_state.dart';
import 'package:pweb/models/state/visibility.dart';

class PaymentPageContentSections extends StatelessWidget {
  final AppDimensions dimensions;
  final String sourceOfFundsTitle;
  final ValueChanged<Recipient?>? onBack;
  final Recipient? recipient;
  final RecipientsProvider recipientProvider;
  final String searchQuery;
  final List<Recipient> filteredRecipients;
  final PayoutDestination fallbackDestination;
  final ControlState sendState;
  final int cooldownRemainingSeconds;
  final TextEditingController searchController;
  final FocusNode searchFocusNode;
  final ValueChanged<String> onSearchChanged;
  final ValueChanged<Recipient> onRecipientSelected;
  final VoidCallback onRecipientCleared;
  final VoidCallback onSend;
  final VoidCallback onAddRecipient;
  final VoidCallback onAddPaymentMethod;
  final VisibilityState paymentDetailsVisibility;
  final VoidCallback onTogglePaymentDetails;

  const PaymentPageContentSections({
    super.key,
    required this.dimensions,
    required this.sourceOfFundsTitle,
    required this.onBack,
    required this.recipient,
    required this.recipientProvider,
    required this.searchQuery,
    required this.filteredRecipients,
    required this.fallbackDestination,
    required this.sendState,
    required this.cooldownRemainingSeconds,
    required this.searchController,
    required this.searchFocusNode,
    required this.onSearchChanged,
    required this.onRecipientSelected,
    required this.onRecipientCleared,
    required this.onSend,
    required this.onAddRecipient,
    required this.onAddPaymentMethod,
    required this.paymentDetailsVisibility,
    required this.onTogglePaymentDetails,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        PaymentPageBackSection(
          onBack: onBack,
          recipient: recipient,
          fallbackDestination: fallbackDestination,
        ),
        SizedBox(height: dimensions.paddingSmall),
        PaymentPageSourceSection(
          dimensions: dimensions,
          title: sourceOfFundsTitle,
        ),
        SizedBox(height: dimensions.paddingXLarge),
        PaymentPageRecipientSection(
          dimensions: dimensions,
          recipient: recipient,
          recipientProvider: recipientProvider,
          searchQuery: searchQuery,
          filteredRecipients: filteredRecipients,
          searchController: searchController,
          searchFocusNode: searchFocusNode,
          onSearchChanged: onSearchChanged,
          onRecipientSelected: onRecipientSelected,
          onRecipientCleared: onRecipientCleared,
          onAddRecipient: onAddRecipient,
          onAddPaymentMethod: onAddPaymentMethod,
          paymentDetailsVisibility: paymentDetailsVisibility,
          onTogglePaymentDetails: onTogglePaymentDetails,
        ),
        SizedBox(height: dimensions.paddingXLarge),
        PaymentPageSendSection(
          dimensions: dimensions,
          sendState: sendState,
          cooldownRemainingSeconds: cooldownRemainingSeconds,
          onSend: onSend,
        ),
      ],
    );
  }
}
