import 'package:flutter/material.dart';

import 'package:pweb/pages/payment_methods/manage/advanced.dart';
import 'package:pweb/controllers/payments/payment_config.dart';
import 'package:pweb/pages/payment_methods/manage/header.dart';
import 'package:pweb/pages/payment_methods/manage/list.dart';


class MethodsWidget extends StatefulWidget {
  const MethodsWidget({super.key});

  @override
  State<MethodsWidget> createState() => _MethodsWidgetState();
}

class _MethodsWidgetState extends State<MethodsWidget> {
  late final PaymentConfigController controller;

  @override
  void initState() {
    super.initState();
    controller = PaymentConfigController(context);
  }

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return Card(
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
      elevation: theme.cardTheme.elevation ?? 4,
      color: theme.colorScheme.onSecondary,
      child: SafeArea(
        child: Padding(
          padding: const EdgeInsets.all(16),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              PaymentConfigHeader(onAdd: controller.addMethod),
              const SizedBox(height: 12),
              PaymentConfigList(controller: controller),
              const SizedBox(height: 12),
              const PaymentConfigAdvanced(),
            ],
          ),
        ),
      ),
    );
  }
}