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/layout.dart';
import 'package:pweb/pages/payout_page/send/content/sections.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';

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

class PaymentPageContent extends StatelessWidget {
  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 PaymentPageContent({
    super.key,
    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) {
    final dimensions = AppDimensions();
    final loc = AppLocalizations.of(context)!;
    final maxWidth = dimensions.maxContentWidth + 180;

    return PaymentPageContentLayout(
      maxWidth: maxWidth,
      padding: EdgeInsets.only(
        left: dimensions.paddingSmall,
        right: dimensions.paddingSmall,
        bottom: dimensions.paddingLarge,
      ),
      child: PaymentPageContentSections(
        dimensions: dimensions,
        sourceOfFundsTitle: loc.sourceOfFunds,
        onBack: onBack,
        recipient: recipient,
        recipientProvider: recipientProvider,
        searchQuery: searchQuery,
        filteredRecipients: filteredRecipients,
        fallbackDestination: fallbackDestination,
        sendState: sendState,
        cooldownRemainingSeconds: cooldownRemainingSeconds,
        searchController: searchController,
        searchFocusNode: searchFocusNode,
        onSearchChanged: onSearchChanged,
        onRecipientSelected: onRecipientSelected,
        onRecipientCleared: onRecipientCleared,
        onSend: onSend,
        onAddRecipient: onAddRecipient,
        onAddPaymentMethod: onAddPaymentMethod,
        paymentDetailsVisibility: paymentDetailsVisibility,
        onTogglePaymentDetails: onTogglePaymentDetails,
      ),
    );
  }
}
