import 'package:flutter/material.dart';

import 'package:pweb/pages/dashboard/payouts/multiple/sections/upload_csv/widget.dart';
import 'package:pweb/pages/dashboard/payouts/multiple/sections/history/widget.dart';
import 'package:pweb/pages/dashboard/payouts/multiple/sections/sample/widget.dart';


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

  static const double _spacing = 12;
  static const double _bottomSpacing = 40;

  static final List<Widget> _cards = const [
    FileFormatSampleSection(),
    UploadCSVSection(),
    UploadHistorySection(),
  ];

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        for (int i = 0; i < _cards.length; i++) ...[
          _StyledCard(child: _cards[i]),
          if (i < _cards.length - 1) const SizedBox(height: _spacing),
        ],
        const SizedBox(height: _bottomSpacing),
      ],
    );
  }
}

class _StyledCard extends StatelessWidget {
  final Widget child;
  const _StyledCard({required this.child});

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return SizedBox(
      width: double.infinity,
      child: Card(
        margin: const EdgeInsets.all(1),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(12),
        ),
        elevation: 4,
        color: theme.colorScheme.onSecondary,
        child: Padding(
          padding: const EdgeInsets.all(16),
          child: child,
        ),
      ),
    );
  }
}
