import 'package:mohem_flutter_app/theme/colors.dart';
import 'package:mohem_flutter_app/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/theme/colors.dart';
import 'package:mohem_flutter_app/utils/utils.dart';

import '../txt.dart';

class DropdownField extends StatefulWidget {
  String? hint;
  List<String>? list;

  DropdownField({this.hint, this.list});

  @override
  State<DropdownField> createState() => _DropdownFieldState();
}

class _DropdownFieldState extends State<DropdownField> {
  String? dropdownValue;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: containerColorRadiusBorderWidth(
        Colors.transparent,
        4,
        borderColor,
        0.5,
      ),
      margin: EdgeInsets.all(2),
      padding: EdgeInsets.only(left: 8, right: 8),
      child: DropdownButton<String>(
        value: dropdownValue,
        icon: const Icon(Icons.keyboard_arrow_down_sharp),
        elevation: 16,
        iconSize: 16,
        iconEnabledColor: borderColor,
        iconDisabledColor: borderColor,
        isExpanded: true,
        style: const TextStyle(color: Colors.black),
        hint: Txt(
          widget.hint ?? "",
          txtType: TxtType.heading1,
          bold: false,
          color: borderColor,
        ),
        underline: Container(
          height: 0,
        ),
        onChanged: (String? newValue) {
          setState(() {
            dropdownValue = newValue!;
          });
        },
        items: (widget.list ??
                <String>[
                  'One',
                  'Two',
                  'Free',
                  'Four',
                ])
            .map<DropdownMenuItem<String>>(
          (String value) {
            return DropdownMenuItem<String>(
              value: value,
              child: Txt(
                value,
                txtType: TxtType.heading1,
                bold: false,
              ),
            );
          },
        ).toList(),
      ),
    );
  }
}
