import 'package:flutter/material.dart';
import 'package:rkm/models/equipe_cidadao.dart';
import 'package:rkm/widgets/dropdown_button_cidadao.dart';
import 'package:rkm/widgets/text_default.dart';
import '../config/color_palette.dart';
import 'dropdown_button_default.dart';

class DropdownWithSubtitleCidadao extends StatelessWidget {
  String subtitle;
  String hintDropdown;
  EquipeCidadao? select;
  double widthSubtitle;
  double widthDropdown;
  double widthContainerDropdown;
  List<EquipeCidadao> list;
  var onChanged;
  var onTapDelete;
  bool showDelete;
  Color colorBorder;

  DropdownWithSubtitleCidadao({
    required this.subtitle,
    required this.select,
    required this.widthDropdown,
    required this.widthContainerDropdown,
    required this.widthSubtitle,
    required this.hintDropdown,
    required this.onChanged,
    required this.list,
    this.colorBorder = ColorPalette.white,
    this.onTapDelete = null,
    this.showDelete = false
});

  @override
  Widget build(BuildContext context) {
    return  Container(
      margin: EdgeInsets.symmetric(horizontal: 10),
      padding: const EdgeInsets.symmetric(vertical: 5.0),
      child: Column(
        children: [
          Container(
            width: widthDropdown,
            child: TextDefault(
              textAlign: TextAlign.start,
              text: subtitle,
              color: ColorPalette.black54,
              fontSize: 12,
            ),
          ),
          Container(
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5),
                border: Border.all(color: colorBorder)
            ),
            margin: EdgeInsets.symmetric(horizontal: 5),
            padding: EdgeInsets.symmetric(horizontal: 2),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                DropDownButtonCidadao(
                  title: hintDropdown,
                  fontSize: 14,
                  width: widthDropdown,
                  widthContainer: widthContainerDropdown,
                  select: select,
                  list: list,
                  onChanged: onChanged,
                ),
                select!=null &&showDelete?GestureDetector(
                    onTap: onTapDelete,
                    child: Icon(Icons.delete,color: ColorPalette.appBar,)
                ):Container(width: 23,)
              ],
            ),
          ),
        ],
      ),
    );
  }
}
