import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

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

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


class FeePayerSwitch extends StatelessWidget {
  final double spacing;
  final TextStyle? style;

  const FeePayerSwitch({super.key, required this.spacing, this.style});

  @override
  Widget build(BuildContext context) => Consumer<PaymentAmountProvider>(
    builder: (context, provider, _) => Row(
      spacing: spacing,
      children: [
        Text(AppLocalizations.of(context)!.recipientPaysFee, style: style), 
        Switch(
          value: !provider.payerCoversFee,
          onChanged: (val) => provider.setPayerCoversFee(!val),
        ),
      ],
    ),
  );
}
