import 'package:flutter/material.dart';
import 'package:rkm/widgets/text_default.dart';
import '../config/color_palette.dart';
import '../config/const_variable.dart';
import '../models/drop_down_data_string_model.dart';

class DropDownEtniaIndigena extends StatelessWidget {
  var onChanged;
  DropDownDataStringModel? select;
  String title;
  double fontSize;
  List<DropDownDataStringModel> list;
  double width;
  double widthContainer;

  DropDownEtniaIndigena({
    required this.onChanged,
    required this.select,
    required this.title,
    required this.list,
    required this.width,
    this.fontSize = 15,
    this.widthContainer = 300
});

  @override
  Widget build(BuildContext context) {

    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          width: width,
          margin: EdgeInsets.symmetric(horizontal: 5),
          padding: EdgeInsets.symmetric(horizontal: 2),
          child: TextDefault(
            textAlign: TextAlign.start,
            text: title,
            color: ColorPalette.black54,
            fontSize: 12,
          ),
        ),
        Container(
          width: width*0.95,
          alignment: Alignment.centerLeft,
          margin: EdgeInsets.symmetric(horizontal: 10),
          decoration: BoxDecoration(
            color: Colors.white,
              borderRadius: BorderRadius.circular(5),
              border: Border.all(color: Colors.white)
          ),
          padding: EdgeInsets.symmetric(horizontal: 5),
          child: DropdownButtonHideUnderline(
            child: DropdownButton(
              dropdownColor: Colors.white,
                hint: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 0.0),
                  child: TextDefault(text: '-SELECIONE-',fontSize: ConstVariable().fontSizeInput,textAlign: TextAlign.end,color: Colors.black,),
                ),
                value: select,
                items: list.map((value) => DropdownMenuItem<DropDownDataStringModel>(
                  value: value,
                  child: Container(
                    alignment: Alignment.centerLeft,
                    color: Colors.white,
                    height: 50,
                    width: width*0.88,
                    child: Padding(
                      padding: EdgeInsets.symmetric(horizontal: 0.0),
                      child: TextDefault(
                        text: value.title,
                        maxLines: 2,
                        fontSize: fontSize,
                        color: Colors.black,
                      ),
                    ),
                  ),
                )
                ).toList(),
                onChanged:onChanged
            ),
          ),
        ),
      ],
    );
  }
}
