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

class DropDownButtonCity extends StatelessWidget {
  var onChanged;
  String? select;
  bool validator;
  String error;

  DropDownButtonCity({
    required this.onChanged,
    required this.select,
    required this.error,
    required this.validator
});

  @override
  Widget build(BuildContext context) {

    double width = MediaQuery.of(context).size.width;

    return Column(
      children: [
        Container(
          width: width*0.6,
          margin: ConstVariable().marginHightInput,
          padding: ConstVariable().paddingWidth,
          decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(ConstVariable().radiusBorderInput),
              border: Border.all(
                color: validator?ColorPalette.white:ColorPalette.red
              ),
              color: ColorPalette.white
          ),
          child: DropdownButtonHideUnderline(
            child: DropdownButton(
                hint: TextDefault(text: 'Cidade',fontSize: ConstVariable().fontSizeInput),
                value: select,
                items: ConstVariable().itensCity.map((value) => DropdownMenuItem(
                  value: value.nameCityFront,
                  child: TextDefault(
                    text: value.nameCityFront,
                  ),
                )
                ).toList(),
                onChanged:onChanged
            ),
          ),
        ),
        Container(
          alignment: Alignment.centerLeft,
          padding: EdgeInsets.symmetric(horizontal: 15),
          child: TextDefault(
            text: validator?'':error,
            color: ColorPalette.red,
            fontSize: 12
          )
        ),
      ],
    );
  }
}
