import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class CustomDropdown extends StatelessWidget{
  final List<Widget> items;
  final values;
  final onChanged;
  final value;
  final String? hint;
  final String? label;
  final double radius;
  final double height;
  final double width;
  final Color? color;

  const CustomDropdown({
    super.key,
    required this.items,
    this.values,
    required this.onChanged,
    this.value,
    this.hint,
    this.label,
    this.radius = 12,
    this.width = double.infinity,
    this.height = 70,
    this.color
  });

  @override
  Widget build(BuildContext context) {

    return Column(
      spacing: 8,
      children: [
        if (label != null) Align(
          alignment: Alignment.bottomLeft,
          child: Text(
            label!,
            style: TextStyle(fontSize: 14, letterSpacing: 0),
          ),
        ),
        SizedBox(
          width: width,
          height: height,
          child: Center(child: DropdownButtonFormField(
            dropdownColor: Colors.white,
            decoration: InputDecoration(
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.all(Radius.circular(radius)),
                borderSide: BorderSide(color: color??Color(0xFF4B4B4B))
              )
            ),
            //underline: Container(),
            initialValue: value,
            onChanged: onChanged,
            hint: Text(hint??""),
            items: List<DropdownMenuItem>.generate(items.length, (int index){
              return DropdownMenuItem(value: (values!=null)?values[index]:index, child: items[index]);
            })
          )),
        )
      ],
    ) ;
  }
}